Always call super(..).setUp() from setUp

This commit is contained in:
Calen Pennington
2015-01-28 12:05:53 -05:00
parent b1dfac56f0
commit 03a05fd9d4
129 changed files with 371 additions and 32 deletions

View File

@@ -34,6 +34,7 @@ class OpenEndedPostTest(ModuleStoreTestCase):
"""Test the openended_post management command."""
def setUp(self):
super(OpenEndedPostTest, self).setUp()
self.user = UserFactory()
store = modulestore()
course_items = import_from_xml(store, self.user.id, TEST_DATA_DIR, ['open_ended']) # pylint: disable=maybe-no-member
@@ -135,6 +136,8 @@ class OpenEndedStatsTest(ModuleStoreTestCase):
"""Test the openended_stats management command."""
def setUp(self):
super(OpenEndedStatsTest, self).setUp()
self.user = UserFactory()
store = modulestore()
course_items = import_from_xml(store, self.user.id, TEST_DATA_DIR, ['open_ended']) # pylint: disable=maybe-no-member

View File

@@ -23,6 +23,8 @@ from instructor.access import (allow_access,
class TestInstructorAccessList(ModuleStoreTestCase):
""" Test access listings. """
def setUp(self):
super(TestInstructorAccessList, self).setUp()
self.course = CourseFactory.create()
self.instructors = [UserFactory.create() for _ in xrange(4)]
@@ -45,6 +47,8 @@ class TestInstructorAccessList(ModuleStoreTestCase):
class TestInstructorAccessAllow(ModuleStoreTestCase):
""" Test access allow. """
def setUp(self):
super(TestInstructorAccessAllow, self).setUp()
self.course = CourseFactory.create()
def test_allow(self):
@@ -79,6 +83,8 @@ class TestInstructorAccessAllow(ModuleStoreTestCase):
class TestInstructorAccessRevoke(ModuleStoreTestCase):
""" Test access revoke. """
def setUp(self):
super(TestInstructorAccessRevoke, self).setUp()
self.course = CourseFactory.create()
self.staff = [UserFactory.create() for _ in xrange(4)]
@@ -115,6 +121,8 @@ class TestInstructorAccessForum(ModuleStoreTestCase):
Test forum access control.
"""
def setUp(self):
super(TestInstructorAccessForum, self).setUp()
self.course = CourseFactory.create()
self.mod_role = Role.objects.create(

View File

@@ -109,6 +109,7 @@ class TestCommonExceptions400(TestCase):
"""
def setUp(self):
super(TestCommonExceptions400, self).setUp()
self.request = Mock(spec=HttpRequest)
self.request.META = {}
@@ -152,6 +153,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
def setUp(self):
super(TestInstructorAPIDenyLevels, self).setUp()
self.course = CourseFactory.create()
self.user = UserFactory.create()
CourseEnrollment.enroll(self.user, self.course.id)
@@ -306,6 +308,8 @@ class TestInstructorAPIBulkAccountCreationAndEnrollment(ModuleStoreTestCase, Log
Test Bulk account creation and enrollment from csv file
"""
def setUp(self):
super(TestInstructorAPIBulkAccountCreationAndEnrollment, self).setUp()
self.request = RequestFactory().request()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
@@ -557,6 +561,8 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
def setUp(self):
super(TestInstructorAPIEnrollment, self).setUp()
self.request = RequestFactory().request()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
@@ -1140,6 +1146,8 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe
"""
def setUp(self):
super(TestInstructorAPIBulkBetaEnrollment, self).setUp()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
@@ -1460,6 +1468,8 @@ class TestInstructorAPILevelsAccess(ModuleStoreTestCase, LoginEnrollmentTestCase
"""
def setUp(self):
super(TestInstructorAPILevelsAccess, self).setUp()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
@@ -2158,6 +2168,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
"""
def setUp(self):
super(TestInstructorAPIRegradeTask, self).setUp()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
@@ -2298,6 +2309,8 @@ class TestInstructorSendEmail(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
def setUp(self):
super(TestInstructorSendEmail, self).setUp()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
@@ -2420,6 +2433,8 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase):
return attr_dict
def setUp(self):
super(TestInstructorAPITaskLists, self).setUp()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
@@ -2540,6 +2555,8 @@ class TestInstructorEmailContentList(ModuleStoreTestCase, LoginEnrollmentTestCas
"""
def setUp(self):
super(TestInstructorEmailContentList, self).setUp()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
@@ -2691,6 +2708,8 @@ class TestInstructorAPIAnalyticsProxy(ModuleStoreTestCase, LoginEnrollmentTestCa
self.content = '{"test_content": "robot test content"}'
def setUp(self):
super(TestInstructorAPIAnalyticsProxy, self).setUp()
self.course = CourseFactory.create()
self.instructor = InstructorFactory(course_key=self.course.id)
self.client.login(username=self.instructor.username, password='test')
@@ -3050,6 +3069,8 @@ class TestCourseRegistrationCodes(ModuleStoreTestCase):
"""
Fixtures.
"""
super(TestCourseRegistrationCodes, self).setUp()
self.course = CourseFactory.create()
CourseModeFactory.create(course_id=self.course.id, min_price=50)
self.instructor = InstructorFactory(course_key=self.course.id)

View File

@@ -22,6 +22,8 @@ class TestInstructorAPIEnrollmentEmailLocalization(TestCase):
"""
def setUp(self):
super(TestInstructorAPIEnrollmentEmailLocalization, self).setUp()
# Platform language is English, instructor's language is Chinese,
# student's language is French, so the emails should all be sent in
# French.

View File

@@ -23,6 +23,7 @@ class TestECommerceDashboardViews(ModuleStoreTestCase):
Check for E-commerce view on the new instructor dashboard
"""
def setUp(self):
super(TestECommerceDashboardViews, self).setUp()
self.course = CourseFactory.create()
# Create instructor account

View File

@@ -11,9 +11,8 @@ from mock import patch
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from bulk_email.models import CourseAuthorization
from xmodule.modulestore.tests.django_utils import TEST_DATA_MOCK_MODULESTORE
from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_TOY_MODULESTORE, ModuleStoreTestCase
from student.tests.factories import AdminFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@@ -24,6 +23,7 @@ class TestNewInstructorDashboardEmailViewMongoBacked(ModuleStoreTestCase):
for Mongo-backed courses
"""
def setUp(self):
super(TestNewInstructorDashboardEmailViewMongoBacked, self).setUp()
self.course = CourseFactory.create()
# Create instructor account
@@ -111,7 +111,11 @@ class TestNewInstructorDashboardEmailViewXMLBacked(ModuleStoreTestCase):
"""
Check for email view on the new instructor dashboard
"""
MODULESTORE = TEST_DATA_MIXED_TOY_MODULESTORE
def setUp(self):
super(TestNewInstructorDashboardEmailViewXMLBacked, self).setUp()
self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
# Create instructor account

View File

@@ -36,6 +36,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
class TestSettableEnrollmentState(TestCase):
""" Test the basis class for enrollment tests. """
def setUp(self):
super(TestSettableEnrollmentState, self).setUp()
self.course_key = SlashSeparatedCourseKey('Robot', 'fAKE', 'C-%-se-%-ID')
def test_mes_create(self):
@@ -66,6 +67,7 @@ class TestEnrollmentChangeBase(TestCase):
__metaclass__ = ABCMeta
def setUp(self):
super(TestEnrollmentChangeBase, self).setUp()
self.course_key = SlashSeparatedCourseKey('Robot', 'fAKE', 'C-%-se-%-ID')
def _run_state_change_test(self, before_ideal, after_ideal, action):
@@ -294,6 +296,7 @@ class TestInstructorUnenrollDB(TestEnrollmentChangeBase):
class TestInstructorEnrollmentStudentModule(TestCase):
""" Test student module manipulations. """
def setUp(self):
super(TestInstructorEnrollmentStudentModule, self).setUp()
self.course_key = SlashSeparatedCourseKey('fake', 'course', 'id')
def test_reset_student_attempts(self):
@@ -425,6 +428,7 @@ class TestSendBetaRoleEmail(TestCase):
"""
def setUp(self):
super(TestSendBetaRoleEmail, self).setUp()
self.user = UserFactory.create()
self.email_params = {'course': 'Robot Super Course'}
@@ -442,6 +446,8 @@ class TestGetEmailParams(ModuleStoreTestCase):
production-like conditions.
"""
def setUp(self):
super(TestGetEmailParams, self).setUp()
self.course = CourseFactory.create()
# Explicitly construct what we expect the course URLs to be
@@ -484,6 +490,7 @@ class TestRenderMessageToString(TestCase):
"""
def setUp(self):
super(TestRenderMessageToString, self).setUp()
self.subject_template = 'emails/enroll_email_allowedsubject.txt'
self.message_template = 'emails/enroll_email_allowedmessage.txt'
self.course = CourseFactory.create()

View File

@@ -23,6 +23,8 @@ class HintManagerTest(ModuleStoreTestCase):
Makes a course, which will be the same for all tests.
Set up mako middleware, which is necessary for template rendering to happen.
"""
super(HintManagerTest, self).setUp()
self.course = CourseFactory.create(org='Me', number='19.002', display_name='test_course')
self.url = '/courses/Me/19.002/test_course/hint_manager'
self.user = UserFactory.create(username='robot', email='robot@edx.org', password='test', is_staff=True)

View File

@@ -29,6 +29,7 @@ class TestInstructorEnrollsStudent(ModuleStoreTestCase, LoginEnrollmentTestCase)
"""
def setUp(self):
super(TestInstructorEnrollsStudent, self).setUp()
instructor = AdminFactory.create()
self.client.login(username=instructor.username, password='test')

View File

@@ -21,6 +21,8 @@ from instructor.views import legacy
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class TestXss(ModuleStoreTestCase):
def setUp(self):
super(TestXss, self).setUp()
self._request_factory = RequestFactory()
self._course = CourseFactory.create()
self._evil_student = UserFactory.create(

View File

@@ -26,6 +26,8 @@ class TestGradebook(ModuleStoreTestCase):
grading_policy = None
def setUp(self):
super(TestGradebook, self).setUp()
instructor = AdminFactory.create()
self.client.login(username=instructor.username, password='test')

View File

@@ -70,6 +70,7 @@ class TestRequireStudentIdentifier(unittest.TestCase):
"""
Fixtures
"""
super(TestRequireStudentIdentifier, self).setUp()
self.student = UserFactory.create()
def test_valid_student_id(self):
@@ -107,6 +108,8 @@ class TestFindUnit(ModuleStoreTestCase):
"""
Fixtures.
"""
super(TestFindUnit, self).setUp()
course = CourseFactory.create()
week1 = ItemFactory.create(parent=course)
homework = ItemFactory.create(parent=week1)
@@ -140,6 +143,8 @@ class TestGetUnitsWithDueDate(ModuleStoreTestCase):
"""
Fixtures.
"""
super(TestGetUnitsWithDueDate, self).setUp()
due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=utc)
course = CourseFactory.create()
week1 = ItemFactory.create(due=due, parent=course)
@@ -188,6 +193,8 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
"""
Fixtures.
"""
super(TestSetDueDateExtension, self).setUp()
due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=utc)
course = CourseFactory.create()
week1 = ItemFactory.create(due=due, parent=course)
@@ -263,6 +270,8 @@ class TestDataDumps(ModuleStoreTestCase):
"""
Fixtures.
"""
super(TestDataDumps, self).setUp()
due = datetime.datetime(2010, 5, 12, 2, 42, tzinfo=utc)
course = CourseFactory.create()
week1 = ItemFactory.create(due=due, parent=course)