Commit 03a05fd9 by Calen Pennington

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

parent b1dfac56
......@@ -22,6 +22,8 @@ class ExportAllCourses(ModuleStoreTestCase):
"""
def setUp(self):
""" Common setup. """
super(ExportAllCourses, self).setUp()
self.content_store = contentstore()
self.module_store = modulestore()
......
......@@ -16,6 +16,8 @@ class TestArgParsing(unittest.TestCase):
Tests for parsing arguments for the `create_course` management command
"""
def setUp(self):
super(TestArgParsing, self).setUp()
self.command = Command()
def test_no_args(self):
......
......@@ -18,6 +18,7 @@ class ExportAllCourses(ModuleStoreTestCase):
"""
def setUp(self):
""" Common setup. """
super(ExportAllCourses, self).setUp()
self.store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)
self.temp_dir = mkdtemp()
self.first_course = CourseFactory.create(org="test", course="course1", display_name="run1")
......
......@@ -16,6 +16,8 @@ class ConvertExportFormat(TestCase):
"""
def setUp(self):
""" Common setup. """
super(ConvertExportFormat, self).setUp()
self.temp_dir = mkdtemp()
self.data_dir = path(__file__).realpath().parent / 'data'
self.version0 = self.data_dir / "Version0_drafts.tar.gz"
......
......@@ -1747,6 +1747,7 @@ class EntryPageTestCase(TestCase):
Tests entry pages that aren't specific to a course.
"""
def setUp(self):
super(EntryPageTestCase, self).setUp()
self.client = AjaxEnabledTestClient()
def _test_page(self, page, status_code=200):
......
......@@ -20,6 +20,7 @@ class TemplateTests(unittest.TestCase):
"""
def setUp(self):
super(TemplateTests, self).setUp()
clear_existing_modulestores() # redundant w/ cleanup but someone was getting errors
self.addCleanup(self._drop_mongo_collections)
self.addCleanup(clear_existing_modulestores)
......
......@@ -19,6 +19,8 @@ class InternationalizationTest(ModuleStoreTestCase):
will be cleared out before each test case execution and deleted
afterwards.
"""
super(InternationalizationTest, self).setUp(create_user=False)
self.uname = 'testuser'
self.email = 'test+courses@edx.org'
self.password = 'foo'
......
......@@ -28,6 +28,8 @@ TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().
class TestGenerateSubs(unittest.TestCase):
"""Tests for `generate_subs` function."""
def setUp(self):
super(TestGenerateSubs, self).setUp()
self.source_subs = {
'start': [100, 200, 240, 390, 1000],
'end': [200, 240, 380, 1000, 1500],
......@@ -93,6 +95,7 @@ class TestSaveSubsToStore(ModuleStoreTestCase):
def setUp(self):
super(TestSaveSubsToStore, self).setUp()
self.course = CourseFactory.create(
org=self.org, number=self.number, display_name=self.display_name)
......@@ -183,6 +186,7 @@ class TestDownloadYoutubeSubs(ModuleStoreTestCase):
self.clear_sub_content(subs_id)
def setUp(self):
super(TestDownloadYoutubeSubs, self).setUp()
self.course = CourseFactory.create(
org=self.org, number=self.number, display_name=self.display_name)
......@@ -477,6 +481,7 @@ class TestTranscript(unittest.TestCase):
Tests for Transcript class e.g. different transcript conversions.
"""
def setUp(self):
super(TestTranscript, self).setUp()
self.srt_transcript = textwrap.dedent("""\
0
......
......@@ -196,6 +196,8 @@ class XBlockVisibilityTestCase(TestCase):
"""Tests for xblock visibility for students."""
def setUp(self):
super(XBlockVisibilityTestCase, self).setUp()
self.dummy_user = ModuleStoreEnum.UserID.test
self.past = datetime(1970, 1, 1)
self.future = datetime.now(UTC) + timedelta(days=1)
......
......@@ -88,6 +88,8 @@ class AuthTestCase(ContentStoreTestCase):
"""Check that various permissions-related things work"""
def setUp(self):
super(AuthTestCase, self).setUp(create_user=False)
self.email = 'a@b.com'
self.pw = 'xyz'
self.username = 'testuser'
......
......@@ -17,6 +17,8 @@ class RolesTest(TestCase):
"""
def setUp(self):
""" Test case setup """
super(RolesTest, self).setUp()
self.global_admin = AdminFactory()
self.instructor = User.objects.create_user('testinstructor', 'testinstructor+courses@edx.org', 'foo')
self.staff = User.objects.create_user('teststaff', 'teststaff+courses@edx.org', 'foo')
......
......@@ -1188,6 +1188,8 @@ class TestEditSplitModule(ItemTest):
@ddt.ddt
class TestComponentHandler(TestCase):
def setUp(self):
super(TestComponentHandler, self).setUp()
self.request_factory = RequestFactory()
patcher = patch('contentstore.views.component.modulestore')
......
......@@ -292,6 +292,8 @@ class TextbookValidationTestCase(TestCase):
def setUp(self):
"Set some useful content for tests"
super(TextbookValidationTestCase, self).setUp()
self.tb1 = {
"tab_title": "Hi, mom!",
"url": "/mom.pdf"
......
......@@ -21,6 +21,7 @@ class EmbargoCourseFormTest(ModuleStoreTestCase):
"""Test the course form properly validates course IDs"""
def setUp(self):
super(EmbargoCourseFormTest, self).setUp()
self.course = CourseFactory.create()
self.true_form_data = {'course_id': self.course.id.to_deprecated_string(), 'embargoed': True}
self.false_form_data = {'course_id': self.course.id.to_deprecated_string(), 'embargoed': False}
......
......@@ -37,6 +37,8 @@ class EmbargoMiddlewareTests(ModuleStoreTestCase):
Tests of EmbargoMiddleware
"""
def setUp(self):
super(EmbargoMiddlewareTests, self).setUp()
self.user = UserFactory(username='fred', password='secret')
self.client.login(username='fred', password='secret')
self.embargo_course = CourseFactory.create()
......
......@@ -20,6 +20,7 @@ class CountryMiddlewareTests(TestCase):
Tests of CountryMiddleware.
"""
def setUp(self):
super(CountryMiddlewareTests, self).setUp()
self.country_middleware = CountryMiddleware()
self.session_middleware = SessionMiddleware()
self.authenticated_user = UserFactory.create()
......
......@@ -27,6 +27,8 @@ class TestTransferStudents(ModuleStoreTestCase):
def setUp(self, **kwargs):
"""Connect a stub receiver, and analytics event tracking."""
super(TestTransferStudents, self).setUp()
UNENROLL_DONE.connect(self.assert_unenroll_signal)
patcher = patch('student.models.tracker')
self.mock_tracker = patcher.start()
......
......@@ -31,6 +31,8 @@ class TestStudentDashboardEmailView(ModuleStoreTestCase):
Check for email view displayed with flag
"""
def setUp(self):
super(TestStudentDashboardEmailView, self).setUp()
self.course = CourseFactory.create()
# Create student account
......
......@@ -50,6 +50,7 @@ class LoginFormTest(UrlResetMixin, ModuleStoreTestCase):
@patch.dict(settings.FEATURES, {"ENABLE_COMBINED_LOGIN_REGISTRATION": False})
def setUp(self):
super(LoginFormTest, self).setUp('lms.urls')
self.url = reverse("signin_user")
self.course = CourseFactory.create()
self.course_id = unicode(self.course.id)
......@@ -162,6 +163,7 @@ class RegisterFormTest(UrlResetMixin, ModuleStoreTestCase):
@patch.dict(settings.FEATURES, {"ENABLE_COMBINED_LOGIN_REGISTRATION": False})
def setUp(self):
super(RegisterFormTest, self).setUp('lms.urls')
self.url = reverse("register_user")
self.course = CourseFactory.create()
self.course_id = unicode(self.course.id)
......
......@@ -18,6 +18,7 @@ class KeywordSubTest(ModuleStoreTestCase):
""" Tests for the keyword substitution feature """
def setUp(self):
super(KeywordSubTest, self).setUp(create_user=False)
self.user = UserFactory.create(
email="testuser@edx.org",
username="testuser",
......
......@@ -13,6 +13,7 @@ class CorrectMapTest(unittest.TestCase):
"""
def setUp(self):
super(CorrectMapTest, self).setUp()
self.cmap = CorrectMap()
def test_set_input_properties(self):
......
......@@ -34,6 +34,7 @@ class TemplateTestCase(unittest.TestCase):
"""
Load the template under test.
"""
super(TemplateTestCase, self).setUp()
capa_path = capa.__path__[0]
self.template_path = os.path.join(capa_path,
'templates',
......
......@@ -393,6 +393,7 @@ class MatlabTest(unittest.TestCase):
Test Matlab input types
'''
def setUp(self):
super(MatlabTest, self).setUp()
self.rows = '10'
self.cols = '80'
self.tabsize = '4'
......@@ -1003,6 +1004,7 @@ class ChemicalEquationTest(unittest.TestCase):
Check that chemical equation inputs work.
'''
def setUp(self):
super(ChemicalEquationTest, self).setUp()
self.size = "42"
xml_str = """<chemicalequationinput id="prob_1_2" size="{size}"/>""".format(size=self.size)
......@@ -1089,6 +1091,7 @@ class FormulaEquationTest(unittest.TestCase):
Check that formula equation inputs work.
"""
def setUp(self):
super(FormulaEquationTest, self).setUp()
self.size = "42"
xml_str = """<formulaequationinput id="prob_1_2" size="{size}"/>""".format(size=self.size)
......
......@@ -37,6 +37,7 @@ class ResponseTest(unittest.TestCase):
maxDiff = None
def setUp(self):
super(ResponseTest, self).setUp()
if self.xml_factory_class:
self.xml_factory = self.xml_factory_class()
......
......@@ -19,6 +19,7 @@ class FormulaTest(unittest.TestCase):
mathml_end = '</mstyle></math>'
def setUp(self):
super(FormulaTest, self).setUp()
self.formulaInstance = formula.formula('')
def test_replace_mathvariants(self):
......
......@@ -62,6 +62,7 @@ class TestSortedAssetList(unittest.TestCase):
Tests the SortedAssetList class.
"""
def setUp(self):
super(TestSortedAssetList, self).setUp()
asset_list = [dict(zip(AssetStoreTestData.asset_fields, asset)) for asset in AssetStoreTestData.all_asset_data]
self.sorted_asset_list_by_filename = SortedAssetList(iterable=asset_list)
self.sorted_asset_list_by_last_edit = SortedAssetList(iterable=asset_list, key=lambda x: x['edited_on'])
......
......@@ -153,13 +153,9 @@ class TestMongoModuleStoreBase(unittest.TestCase):
# Destroy the test db.
connection.drop_database(DB)
@classmethod
def setUp(cls):
cls.dummy_user = ModuleStoreEnum.UserID.test
@classmethod
def tearDown(cls):
pass
def setUp(self):
super(TestMongoModuleStoreBase, self).setUp()
self.dummy_user = ModuleStoreEnum.UserID.test
class TestMongoModuleStore(TestMongoModuleStoreBase):
......@@ -742,12 +738,13 @@ class TestMongoModuleStoreWithNoAssetCollection(TestMongoModuleStore):
self.assertRaises(ItemNotFoundError, lambda: self.draft_store.get_all_asset_metadata(course_key, 'asset')[:1])
class TestMongoKeyValueStore(object):
class TestMongoKeyValueStore(unittest.TestCase):
"""
Tests for MongoKeyValueStore.
"""
def setUp(self):
super(TestMongoKeyValueStore, self).setUp()
self.data = {'foo': 'foo_value'}
self.course_id = SlashSeparatedCourseKey('org', 'course', 'run')
self.parent = self.course_id.make_usage_key('parent', 'p')
......
......@@ -519,6 +519,7 @@ class SplitModuleTest(unittest.TestCase):
split_store.copy("test@edx.org", source_course, destination, [to_publish], None)
def setUp(self):
super(SplitModuleTest, self).setUp()
self.user_id = random.getrandbits(32)
def tearDown(self):
......@@ -1707,7 +1708,7 @@ class TestPublish(SplitModuleTest):
Test the publishing api
"""
def setUp(self):
SplitModuleTest.setUp(self)
super(TestPublish, self).setUp()
def tearDown(self):
SplitModuleTest.tearDown(self)
......
......@@ -114,6 +114,7 @@ class PartitionTestCase(TestCase):
TEST_SCHEME_NAME = "mock"
def setUp(self):
super(PartitionTestCase, self).setUp()
# Set up two user partition schemes: mock and random
self.non_random_scheme = MockUserPartitionScheme(self.TEST_SCHEME_NAME)
self.random_scheme = MockUserPartitionScheme("random")
......
......@@ -172,9 +172,6 @@ def mock_render_template(*args, **kwargs):
class ModelsTest(unittest.TestCase):
def setUp(self):
pass
def test_load_class(self):
vc = XModuleDescriptor.load_class('video')
vc_str = "<class 'xmodule.video_module.video_module.VideoDescriptor'>"
......@@ -187,6 +184,7 @@ class LogicTest(unittest.TestCase):
raw_field_data = {}
def setUp(self):
super(LogicTest, self).setUp()
self.system = get_test_system()
self.descriptor = Mock(name="descriptor", url_name='', category='test')
......
......@@ -32,6 +32,7 @@ class AnnotatableModuleTestCase(unittest.TestCase):
'''
def setUp(self):
super(AnnotatableModuleTestCase, self).setUp()
self.annotatable = AnnotatableModule(
Mock(),
get_test_system(),
......
......@@ -187,6 +187,8 @@ if submission[0] == '':
class CapaModuleTest(unittest.TestCase):
def setUp(self):
super(CapaModuleTest, self).setUp()
now = datetime.datetime.now(UTC)
day_delta = datetime.timedelta(days=1)
self.yesterday_str = str(now - day_delta)
......@@ -1736,6 +1738,7 @@ class TestProblemCheckTracking(unittest.TestCase):
"""
def setUp(self):
super(TestProblemCheckTracking, self).setUp()
self.maxDiff = None
def test_choice_answer_text(self):
......
......@@ -85,6 +85,7 @@ class OpenEndedChildTest(unittest.TestCase):
descriptor = Mock()
def setUp(self):
super(OpenEndedChildTest, self).setUp()
self.test_system = get_test_system()
self.test_system.open_ended_grading_interface = None
self.openendedchild = OpenEndedChild(self.test_system, self.location,
......@@ -249,6 +250,7 @@ class OpenEndedModuleTest(unittest.TestCase):
}
def setUp(self):
super(OpenEndedModuleTest, self).setUp()
self.test_system = get_test_system()
self.test_system.open_ended_grading_interface = None
self.test_system.location = self.location
......@@ -529,6 +531,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
)
def setUp(self):
super(CombinedOpenEndedModuleTest, self).setUp()
self.combinedoe = CombinedOpenEndedV1Module(self.test_system,
self.location,
self.definition,
......@@ -885,6 +888,7 @@ class CombinedOpenEndedModuleConsistencyTest(unittest.TestCase):
)
def setUp(self):
super(CombinedOpenEndedModuleConsistencyTest, self).setUp()
self.combinedoe = CombinedOpenEndedV1Module(self.test_system,
self.location,
self.definition,
......@@ -987,6 +991,7 @@ class OpenEndedModuleXmlTest(unittest.TestCase, DummyModulestore):
return test_system
def setUp(self):
super(OpenEndedModuleXmlTest, self).setUp()
self.setup_modulestore(COURSE)
def _handle_ajax(self, dispatch, content):
......@@ -1229,6 +1234,7 @@ class OpenEndedModuleXmlAttemptTest(unittest.TestCase, DummyModulestore):
return test_system
def setUp(self):
super(OpenEndedModuleXmlAttemptTest, self).setUp()
self.setup_modulestore(COURSE)
def _handle_ajax(self, dispatch, content):
......@@ -1304,6 +1310,7 @@ class OpenEndedModuleXmlImageUploadTest(unittest.TestCase, DummyModulestore):
return test_system
def setUp(self):
super(OpenEndedModuleXmlImageUploadTest, self).setUp()
self.setup_modulestore(COURSE)
def test_file_upload_fail(self):
......
......@@ -116,6 +116,7 @@ class ConditionalModuleBasicTest(unittest.TestCase):
"""
def setUp(self):
super(ConditionalModuleBasicTest, self).setUp()
self.test_system = get_test_system()
def test_icon_class(self):
......@@ -178,6 +179,7 @@ class ConditionalModuleXmlTest(unittest.TestCase):
return DummySystem(load_error_modules)
def setUp(self):
super(ConditionalModuleXmlTest, self).setUp()
self.test_system = get_test_system()
def get_course(self, name):
......
......@@ -91,6 +91,8 @@ class HasEndedMayCertifyTestCase(unittest.TestCase):
"""Double check the semantics around when to finalize courses."""
def setUp(self):
super(HasEndedMayCertifyTestCase, self).setUp()
system = DummySystem(load_error_modules=True)
#sample_xml = """
# <course org="{org}" course="{course}" display_organization="{org}_display" display_coursenumber="{course}_display"
......@@ -139,6 +141,8 @@ class IsNewCourseTestCase(unittest.TestCase):
"""Make sure the property is_new works on courses"""
def setUp(self):
super(IsNewCourseTestCase, self).setUp()
# Needed for test_is_newish
datetime_patcher = patch.object(
xmodule.course_module, 'datetime',
......
......@@ -14,8 +14,10 @@ from xblock.fields import ScopeIds
from xblock.test.tools import unabc
class SetupTestErrorModules():
class SetupTestErrorModules(unittest.TestCase):
"""Common setUp for use in ErrorModule tests."""
def setUp(self):
super(SetupTestErrorModules, self).setUp()
self.system = get_test_system()
self.course_id = SlashSeparatedCourseKey('org', 'course', 'run')
self.location = self.course_id.make_usage_key('foo', 'bar')
......@@ -23,13 +25,10 @@ class SetupTestErrorModules():
self.error_msg = "Error"
class TestErrorModule(unittest.TestCase, SetupTestErrorModules):
class TestErrorModule(SetupTestErrorModules):
"""
Tests for ErrorModule and ErrorDescriptor
"""
def setUp(self):
SetupTestErrorModules.setUp(self)
def test_error_module_xml_rendering(self):
descriptor = ErrorDescriptor.from_xml(
self.valid_xml,
......@@ -58,13 +57,10 @@ class TestErrorModule(unittest.TestCase, SetupTestErrorModules):
self.assertIn(repr(descriptor), context_repr)
class TestNonStaffErrorModule(unittest.TestCase, SetupTestErrorModules):
class TestNonStaffErrorModule(SetupTestErrorModules):
"""
Tests for NonStaffErrorModule and NonStaffErrorDescriptor
"""
def setUp(self):
SetupTestErrorModules.setUp(self)
def test_non_staff_error_module_create(self):
descriptor = NonStaffErrorDescriptor.from_xml(
self.valid_xml,
......@@ -125,6 +121,7 @@ class TestErrorModuleConstruction(unittest.TestCase):
"""
def setUp(self):
super(TestErrorModuleConstruction, self).setUp()
field_data = Mock(spec=FieldData)
self.descriptor = BrokenDescriptor(
TestRuntime(Mock(spec=IdReader), field_data),
......
......@@ -70,6 +70,7 @@ class RoundTripTestCase(unittest.TestCase):
"""
def setUp(self):
super(RoundTripTestCase, self).setUp()
self.maxDiff = None
self.temp_dir = mkdtemp()
self.addCleanup(shutil.rmtree, self.temp_dir)
......@@ -158,6 +159,8 @@ class TestEdxJsonEncoder(unittest.TestCase):
Tests for xml_exporter.EdxJSONEncoder
"""
def setUp(self):
super(TestEdxJsonEncoder, self).setUp()
self.encoder = EdxJSONEncoder()
class OffsetTZ(tzinfo):
......@@ -220,6 +223,7 @@ class ConvertExportFormat(unittest.TestCase):
"""
def setUp(self):
""" Common setup. """
super(ConvertExportFormat, self).setUp()
# Directory for expanding all the test archives
self.temp_dir = mkdtemp()
......
......@@ -46,6 +46,8 @@ class ImageAnnotationModuleTestCase(unittest.TestCase):
"""
Makes sure that the Module is declared and mocked with the sample xml above.
"""
super(ImageAnnotationModuleTestCase, self).setUp()
# return anything except None to test LMS
def test_real_user(useless):
useless_user = Mock(email='fake@fake.com', id=useless)
......
......@@ -48,6 +48,7 @@ class PeerGradingModuleTest(unittest.TestCase, DummyModulestore):
Create a peer grading module from a test system
@return:
"""
super(PeerGradingModuleTest, self).setUp()
self.setup_modulestore(self.course_id.course)
self.peer_grading = self.get_module_from_location(self.problem_location)
self.coe = self.get_module_from_location(self.coe_location)
......@@ -264,6 +265,7 @@ class PeerGradingModuleScoredTest(unittest.TestCase, DummyModulestore):
Create a peer grading module from a test system
@return:
"""
super(PeerGradingModuleScoredTest, self).setUp()
self.setup_modulestore(self.course_id.course)
def test_metadata_load(self):
......@@ -305,6 +307,7 @@ class PeerGradingModuleLinkedTest(unittest.TestCase, DummyModulestore):
"""
Create a peer grading module from a test system.
"""
super(PeerGradingModuleLinkedTest, self).setUp()
self.setup_modulestore(self.course_id.course)
@property
......
......@@ -35,6 +35,8 @@ class SelfAssessmentTest(unittest.TestCase):
descriptor = Mock()
def setUp(self):
super(SelfAssessmentTest, self).setUp()
self.static_data = {
'max_attempts': 10,
'rubric': etree.XML(self.rubric),
......
......@@ -8,6 +8,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
class TabTestCase(unittest.TestCase):
"""Base class for Tab-related test cases."""
def setUp(self):
super(TabTestCase, self).setUp()
self.course = MagicMock()
self.course.id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
......@@ -450,6 +451,7 @@ class KeyCheckerTestCase(unittest.TestCase):
"""Test cases for KeyChecker class"""
def setUp(self):
super(KeyCheckerTestCase, self).setUp()
self.valid_keys = ['a', 'b']
self.invalid_keys = ['a', 'v', 'g']
......@@ -467,6 +469,7 @@ class NeedNameTestCase(unittest.TestCase):
"""Test cases for NeedName validator"""
def setUp(self):
super(NeedNameTestCase, self).setUp()
self.valid_dict1 = {'a': 1, 'name': 2}
self.valid_dict2 = {'name': 1}
......
......@@ -31,6 +31,8 @@ class TextAnnotationModuleTestCase(unittest.TestCase):
"""
Makes sure that the Module is declared and mocked with the sample xml above.
"""
super(TextAnnotationModuleTestCase, self).setUp()
# return anything except None to test LMS
def test_real_user(useless):
useless_user = Mock(email='fake@fake.com', id=useless)
......
......@@ -14,6 +14,7 @@ class BaseVerticalModuleTest(XModuleXmlImportTest):
test_html_2 = 'Test HTML 2'
def setUp(self):
super(BaseVerticalModuleTest, self).setUp()
# construct module
course = xml.CourseFactory.build()
sequence = xml.SequenceFactory.build(parent=course)
......
......@@ -185,6 +185,7 @@ class VideoDescriptorTestBase(unittest.TestCase):
"""
def setUp(self):
super(VideoDescriptorTestBase, self).setUp()
self.descriptor = instantiate_descriptor()
......
......@@ -27,6 +27,8 @@ class VideoAnnotationModuleTestCase(unittest.TestCase):
"""
Makes sure that the Video Annotation Module is created.
"""
super(VideoAnnotationModuleTestCase, self).setUp()
# return anything except None to test LMS
def test_real_user(useless):
useless_user = Mock(email='fake@fake.com', id=useless)
......
......@@ -362,6 +362,7 @@ class TestXModuleHandler(TestCase):
"""
def setUp(self):
super(TestXModuleHandler, self).setUp()
self.module = XModule(descriptor=Mock(), field_data=Mock(), runtime=Mock(), scope_ids=Mock())
self.module.handle_ajax = Mock(return_value='{}')
self.request = webob.Request({})
......
......@@ -64,6 +64,7 @@ class InheritingFieldDataTest(unittest.TestCase):
not_inherited = String(scope=Scope.settings, default="nothing")
def setUp(self):
super(InheritingFieldDataTest, self).setUp()
self.system = get_test_descriptor_system()
self.all_blocks = {}
self.system.get_block = self.all_blocks.get
......
......@@ -123,6 +123,8 @@ class PreRequisiteCourseCatalog(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
@patch.dict(settings.FEATURES, {'ENABLE_PREREQUISITE_COURSES': True, 'MILESTONES_APP': True})
def setUp(self):
super(PreRequisiteCourseCatalog, self).setUp()
seed_milestone_relationship_types()
@patch.dict(settings.FEATURES, {'ENABLE_PREREQUISITE_COURSES': True, 'MILESTONES_APP': True})
......
......@@ -27,6 +27,7 @@ class TestOptoutCourseEmails(ModuleStoreTestCase):
"""
def setUp(self):
super(TestOptoutCourseEmails, self).setUp()
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(display_name=course_title)
self.instructor = AdminFactory.create()
......
......@@ -51,6 +51,7 @@ class EmailSendFromDashboardTestCase(ModuleStoreTestCase):
@patch.dict(settings.FEATURES, {'ENABLE_INSTRUCTOR_EMAIL': True, 'REQUIRE_COURSE_EMAIL_AUTH': False})
def setUp(self):
super(EmailSendFromDashboardTestCase, self).setUp()
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(display_name=course_title)
......
......@@ -46,6 +46,7 @@ class TestEmailErrors(ModuleStoreTestCase):
"""
def setUp(self):
super(TestEmailErrors, self).setUp()
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(display_name=course_title)
self.instructor = AdminFactory.create()
......
......@@ -23,6 +23,7 @@ class CourseAuthorizationFormTest(ModuleStoreTestCase):
"""Test the CourseAuthorizationAdminForm form for Mongo-backed courses."""
def setUp(self):
super(CourseAuthorizationFormTest, self).setUp()
course_title = u"ẗëṡẗ title イ乇丂イ ᄊ乇丂丂ムg乇 キo尺 ムレレ тэѕт мэѕѕаБэ"
self.course = CourseFactory.create(display_name=course_title)
......
......@@ -69,6 +69,8 @@ class CourseEmailTemplateTest(TestCase):
"""Test the CourseEmailTemplate model."""
def setUp(self):
super(CourseEmailTemplateTest, self).setUp()
# load initial content (since we don't run migrations as part of tests):
call_command("loaddata", "course_email_template.json")
......
......@@ -34,6 +34,7 @@ class TestGetProblemGradeDistribution(ModuleStoreTestCase):
"""
def setUp(self):
super(TestGetProblemGradeDistribution, self).setUp()
self.request_factory = RequestFactory()
self.instructor = AdminFactory.create()
......
......@@ -21,6 +21,7 @@ class TestViews(ModuleStoreTestCase):
"""
def setUp(self):
super(TestViews, self).setUp()
self.request_factory = RequestFactory()
self.request = self.request_factory.get('')
......
......@@ -21,6 +21,7 @@ from course_wiki import settings
class TestWikiAccessBase(ModuleStoreTestCase):
"""Base class for testing wiki access."""
def setUp(self):
super(TestWikiAccessBase, self).setUp()
self.wiki = get_or_create_root()
......
......@@ -20,6 +20,8 @@ class TestWikiAccessMiddleware(ModuleStoreTestCase):
def setUp(self):
"""Test setup."""
super(TestWikiAccessMiddleware, self).setUp()
self.wiki = get_or_create_root()
self.course_math101 = CourseFactory.create(org='edx', number='math101', display_name='2014', metadata={'use_unique_wiki_id': 'false'})
......
......@@ -14,11 +14,9 @@ class WikiRedirectTestCase(LoginEnrollmentTestCase):
Tests for wiki course redirection.
"""
@classmethod
def setUpClass(cls):
cls.toy = CourseFactory.create(org='edX', course='toy', display_name='2012_Fall')
def setUp(self):
super(WikiRedirectTestCase, self).setUp()
self.toy = CourseFactory.create(org='edX', course='toy', display_name='2012_Fall')
# Create two accounts
self.student = 'view@test.com'
......
......@@ -46,6 +46,7 @@ class CommandsTestBase(TestCase):
"""
def setUp(self):
super(CommandsTestBase, self).setUp()
self.loaded_courses = self.load_courses()
def load_courses(self):
......
......@@ -39,6 +39,7 @@ class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
Tests about xblock.
"""
def setUp(self):
super(AboutTestCase, self).setUp()
self.course = CourseFactory.create()
self.about = ItemFactory.create(
category="about", parent_location=self.course.location,
......@@ -220,6 +221,7 @@ class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, ModuleStoreTes
"""
Set up the tests
"""
super(AboutWithCappedEnrollmentsTestCase, self).setUp()
self.course = CourseFactory.create(metadata={"max_student_enrollments_allowed": 1})
self.about = ItemFactory.create(
......@@ -267,6 +269,7 @@ class AboutWithInvitationOnly(ModuleStoreTestCase):
This test case will check the About page when a course is invitation only.
"""
def setUp(self):
super(AboutWithInvitationOnly, self).setUp()
self.course = CourseFactory.create(metadata={"invitation_only": True})
......@@ -314,6 +317,7 @@ class AboutTestCaseShibCourse(LoginEnrollmentTestCase, ModuleStoreTestCase):
Test cases covering about page behavior for courses that use shib enrollment domain ("shib courses")
"""
def setUp(self):
super(AboutTestCaseShibCourse, self).setUp()
self.course = CourseFactory.create(enrollment_domain="shib:https://idp.stanford.edu/")
self.about = ItemFactory.create(
......
......@@ -32,6 +32,7 @@ class AccessTestCase(LoginEnrollmentTestCase):
Tests for the various access controls on the student dashboard
"""
def setUp(self):
super(AccessTestCase, self).setUp()
course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
self.course = course_key.make_usage_key('course', course_key.run)
self.anonymous_user = AnonymousUserFactory()
......@@ -329,6 +330,7 @@ class UserRoleTestCase(TestCase):
Tests for user roles.
"""
def setUp(self):
super(UserRoleTestCase, self).setUp()
self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
self.anonymous_user = AnonymousUserFactory()
self.student = UserFactory()
......
......@@ -21,6 +21,7 @@ class CourseInfoTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
Tests for the Course Info page
"""
def setUp(self):
super(CourseInfoTestCase, self).setUp()
self.course = CourseFactory.create()
self.page = ItemFactory.create(
category="course_info", parent_location=self.course.location,
......
......@@ -39,6 +39,8 @@ class TestGradeIteration(ModuleStoreTestCase):
"""
Create a course and a handful of users to assign grades
"""
super(TestGradeIteration, self).setUp()
self.course = CourseFactory.create(
display_name=self.COURSE_NAME,
number=self.COURSE_NUM
......
......@@ -72,6 +72,7 @@ class GroupAccessTestCase(ModuleStoreTestCase):
modulestore().update_item(block, 1)
def setUp(self):
super(GroupAccessTestCase, self).setUp()
UserPartition.scheme_extensions = ExtensionManager.make_test_instance(
[
......
......@@ -135,6 +135,7 @@ class TestLTIModuleListing(ModuleStoreTestCase):
def setUp(self):
"""Create course, 2 chapters, 2 sections"""
super(TestLTIModuleListing, self).setUp()
self.course = CourseFactory.create(display_name=self.COURSE_NAME, number=self.COURSE_SLUG)
self.chapter1 = ItemFactory.create(
parent_location=self.course.location,
......
......@@ -26,6 +26,8 @@ class MasqueradeTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
Base class for masquerade tests that sets up a test course and enrolls a user in the course.
"""
def setUp(self):
super(MasqueradeTestCase, self).setUp()
# By default, tests run with DISABLE_START_DATES=True. To test that masquerading as a student is
# working properly, we must use start dates and set a start date in the past (otherwise the access
# checks exist prematurely).
......
......@@ -23,6 +23,8 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
STUDENT_INFO = [('view@test.com', 'foo'), ('view2@test.com', 'foo')]
def setUp(self):
super(TestMicrosites, self).setUp()
# use a different hostname to test Microsites since they are
# triggered on subdomain mappings
#
......
......@@ -20,6 +20,8 @@ class CoursewareMiddlewareTestCase(ModuleStoreTestCase):
"""Tests that courseware middleware is correctly redirected"""
def setUp(self):
super(CoursewareMiddlewareTestCase, self).setUp()
self.course = CourseFactory.create()
def check_user_not_enrolled_redirect(self):
......
......@@ -54,6 +54,7 @@ class StudentModuleFactory(cmfStudentModuleFactory):
class TestInvalidScopes(TestCase):
def setUp(self):
super(TestInvalidScopes, self).setUp()
self.user = UserFactory.create(username='user')
self.field_data_cache = FieldDataCache([mock_descriptor([mock_field(Scope.user_state, 'a_field')])], course_id, self.user)
self.kvs = DjangoKeyValueStore(self.field_data_cache)
......@@ -101,6 +102,7 @@ class TestStudentModuleStorage(OtherUserFailureTestMixin, TestCase):
existing_field_name = "a_field"
def setUp(self):
super(TestStudentModuleStorage, self).setUp()
student_module = StudentModuleFactory(state=json.dumps({'a_field': 'a_value', 'b_field': 'b_value'}))
self.user = student_module.student
self.assertEqual(self.user.id, 1) # check our assumption hard-coded in the key functions above.
......@@ -179,6 +181,8 @@ class TestStudentModuleStorage(OtherUserFailureTestMixin, TestCase):
class TestMissingStudentModule(TestCase):
def setUp(self):
super(TestMissingStudentModule, self).setUp()
self.user = UserFactory.create(username='user')
self.assertEqual(self.user.id, 1) # check our assumption hard-coded in the key functions above.
self.field_data_cache = FieldDataCache([mock_descriptor()], course_id, self.user)
......
......@@ -506,6 +506,7 @@ class TestHtmlModifiers(ModuleStoreTestCase):
student_view are taking place
"""
def setUp(self):
super(TestHtmlModifiers, self).setUp()
self.user = UserFactory.create()
self.request = RequestFactory().get('/')
self.request.user = self.user
......@@ -637,6 +638,7 @@ class ViewInStudioTest(ModuleStoreTestCase):
def setUp(self):
""" Set up the user and request that will be used. """
super(ViewInStudioTest, self).setUp()
self.staff_user = GlobalStaffFactory.create()
self.request = RequestFactory().get('/')
self.request.user = self.staff_user
......@@ -697,9 +699,6 @@ class ViewInStudioTest(ModuleStoreTestCase):
class MongoViewInStudioTest(ViewInStudioTest):
"""Test the 'View in Studio' link visibility in a mongo backed course."""
def setUp(self):
super(MongoViewInStudioTest, self).setUp()
def test_view_in_studio_link_studio_course(self):
"""Regular Studio courses should see 'View in Studio' links."""
self.setup_mongo_course()
......@@ -772,6 +771,7 @@ class TestStaffDebugInfo(ModuleStoreTestCase):
"""Tests to verify that Staff Debug Info panel and histograms are displayed to staff."""
def setUp(self):
super(TestStaffDebugInfo, self).setUp()
self.user = UserFactory.create()
self.request = RequestFactory().get('/')
self.request.user = self.user
......@@ -893,6 +893,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
def setUp(self):
super(TestAnonymousStudentId, self).setUp(create_user=False)
self.user = UserFactory()
@patch('courseware.module_render.has_access', Mock(return_value=True))
......@@ -961,6 +962,8 @@ class TestModuleTrackingContext(ModuleStoreTestCase):
"""
def setUp(self):
super(TestModuleTrackingContext, self).setUp()
self.user = UserFactory.create()
self.request = RequestFactory().get('/')
self.request.user = self.user
......
......@@ -35,6 +35,8 @@ class TestRecommender(ModuleStoreTestCase, LoginEnrollmentTestCase):
XBLOCK_NAMES = ['recommender', 'recommender_second']
def setUp(self):
super(TestRecommender, self).setUp()
self.course = CourseFactory.create(
display_name='Recommender_Test_Course'
)
......
......@@ -29,6 +29,7 @@ class SplitTestBase(ModuleStoreTestCase):
VISIBLE_CONTENT = None
def setUp(self):
super(SplitTestBase, self).setUp()
self.partition = UserPartition(
0,
'first_partition',
......@@ -276,6 +277,8 @@ class SplitTestPosition(ModuleStoreTestCase):
Check that we can change positions in a course with partitions defined
"""
def setUp(self):
super(SplitTestPosition, self).setUp()
self.partition = UserPartition(
0,
'first_partition',
......
......@@ -31,6 +31,7 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
"""Test cases for Static Tab Dates."""
def setUp(self):
super(StaticTabDateTestCase, self).setUp()
self.course = CourseFactory.create()
self.page = ItemFactory.create(
category="static_tab", parent_location=self.course.location,
......@@ -117,6 +118,8 @@ class EntranceExamsTabsTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
"""
Test case scaffolding
"""
super(EntranceExamsTabsTestCase, self).setUp()
self.course = CourseFactory.create()
self.instructor_tab = ItemFactory.create(
category="instructor", parent_location=self.course.location,
......
......@@ -150,6 +150,7 @@ class TestGetHtmlMethod(BaseTestXmodule):
METADATA = {}
def setUp(self):
super(TestGetHtmlMethod, self).setUp()
self.setup_course()
def test_get_html_track(self):
......@@ -766,6 +767,7 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
METADATA = {}
def setUp(self):
super(TestVideoDescriptorInitialization, self).setUp()
self.setup_course()
def test_source_not_in_html5sources(self):
......
......@@ -395,6 +395,7 @@ class TestBetatesterAccess(ModuleStoreTestCase):
Tests for the beta tester feature
"""
def setUp(self):
super(TestBetatesterAccess, self).setUp()
now = datetime.datetime.now(pytz.UTC)
tomorrow = now + datetime.timedelta(days=1)
......
......@@ -36,12 +36,13 @@ from util.views import ensure_valid_course_key
@override_settings(MODULESTORE=TEST_DATA_MIXED_TOY_MODULESTORE)
class TestJumpTo(TestCase):
class TestJumpTo(ModuleStoreTestCase):
"""
Check the jumpto link for a course.
"""
def setUp(self):
super(TestJumpTo, self).setUp()
# Use toy course from XML
self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')
......@@ -82,6 +83,7 @@ class ViewsTestCase(TestCase):
Tests for views.py methods.
"""
def setUp(self):
super(ViewsTestCase, self).setUp()
self.course = CourseFactory.create()
self.chapter = ItemFactory.create(category='chapter', parent_location=self.course.location) # pylint: disable=no-member
self.section = ItemFactory.create(category='sequential', parent_location=self.chapter.location, due=datetime(2013, 9, 18, 11, 30, 00))
......@@ -493,6 +495,7 @@ class BaseDueDateTests(ModuleStoreTestCase):
return course
def setUp(self):
super(BaseDueDateTests, self).setUp()
self.request_factory = RequestFactory()
self.user = UserFactory.create()
self.request = self.request_factory.get("foo")
......@@ -588,6 +591,7 @@ class StartDateTests(ModuleStoreTestCase):
"""
def setUp(self):
super(StartDateTests, self).setUp()
self.request_factory = RequestFactory()
self.user = UserFactory.create()
self.request = self.request_factory.get("foo")
......@@ -642,6 +646,7 @@ class ProgressPageTests(ModuleStoreTestCase):
"""
def setUp(self):
super(ProgressPageTests, self).setUp()
self.request_factory = RequestFactory()
self.user = UserFactory.create()
self.request = self.request_factory.get("foo")
......@@ -676,6 +681,8 @@ class VerifyCourseKeyDecoratorTests(TestCase):
"""
def setUp(self):
super(VerifyCourseKeyDecoratorTests, self).setUp()
self.request = RequestFactory().get("foo")
self.valid_course_id = "edX/test/1"
self.invalid_course_id = "edX/"
......
......@@ -23,6 +23,7 @@ class ActivateLoginTest(LoginEnrollmentTestCase):
Test logging in and logging out.
"""
def setUp(self):
super(ActivateLoginTest, self).setUp()
self.setup_user()
def test_activate_login(self):
......
......@@ -22,6 +22,8 @@ class RefundTests(ModuleStoreTestCase):
Tests for the manual refund page
"""
def setUp(self):
super(RefundTests, self).setUp()
self.course = CourseFactory.create(
org='testorg', number='run1', display_name='refundable course'
)
......
......@@ -847,6 +847,8 @@ class ViewPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSet
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class CreateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRequestSetupMixin):
def setUp(self):
super(CreateThreadUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
seed_permissions_roles(self.course.id)
self.student = UserFactory.create()
......@@ -869,6 +871,8 @@ class CreateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRequestSetupMixin):
def setUp(self):
super(UpdateThreadUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
seed_permissions_roles(self.course.id)
self.student = UserFactory.create()
......@@ -897,6 +901,8 @@ class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class CreateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRequestSetupMixin):
def setUp(self):
super(CreateCommentUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
seed_permissions_roles(self.course.id)
self.student = UserFactory.create()
......@@ -920,6 +926,8 @@ class CreateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRe
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class UpdateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRequestSetupMixin):
def setUp(self):
super(UpdateCommentUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
seed_permissions_roles(self.course.id)
self.student = UserFactory.create()
......@@ -944,6 +952,8 @@ class UpdateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRe
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRequestSetupMixin):
def setUp(self):
super(CreateSubCommentUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
seed_permissions_roles(self.course.id)
self.student = UserFactory.create()
......@@ -978,6 +988,8 @@ class UsersEndpointTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
})
def setUp(self):
super(UsersEndpointTestCase, self).setUp()
self.course = CourseFactory.create()
seed_permissions_roles(self.course.id)
self.student = UserFactory.create()
......
......@@ -186,6 +186,8 @@ class PartialDictMatcher(object):
@patch('requests.request')
class SingleThreadTestCase(ModuleStoreTestCase):
def setUp(self):
super(SingleThreadTestCase, self).setUp(create_user=False)
self.course = CourseFactory.create()
self.student = UserFactory.create()
CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id)
......@@ -835,6 +837,8 @@ class FollowedThreadsDiscussionGroupIdTestCase(CohortedContentTestCase, Cohorted
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class InlineDiscussionTestCase(ModuleStoreTestCase):
def setUp(self):
super(InlineDiscussionTestCase, self).setUp()
self.course = CourseFactory.create(org="TestX", number="101", display_name="Test Course")
self.student = UserFactory.create()
CourseEnrollmentFactory(user=self.student, course_id=self.course.id)
......@@ -870,6 +874,8 @@ class UserProfileTestCase(ModuleStoreTestCase):
TEST_THREAD_ID = 'userprofile-test-thread-id'
def setUp(self):
super(UserProfileTestCase, self).setUp()
self.course = CourseFactory.create()
self.student = UserFactory.create()
self.profiled_user = UserFactory.create()
......@@ -979,6 +985,8 @@ class UserProfileTestCase(ModuleStoreTestCase):
class CommentsServiceRequestHeadersTestCase(UrlResetMixin, ModuleStoreTestCase):
@patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
def setUp(self):
super(CommentsServiceRequestHeadersTestCase, self).setUp()
username = "foo"
password = "bar"
......@@ -1038,6 +1046,8 @@ class CommentsServiceRequestHeadersTestCase(UrlResetMixin, ModuleStoreTestCase):
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class InlineDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
def setUp(self):
super(InlineDiscussionUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
self.student = UserFactory.create()
CourseEnrollmentFactory(user=self.student, course_id=self.course.id)
......@@ -1058,6 +1068,8 @@ class InlineDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class ForumFormDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
def setUp(self):
super(ForumFormDiscussionUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
self.student = UserFactory.create()
CourseEnrollmentFactory(user=self.student, course_id=self.course.id)
......@@ -1079,6 +1091,8 @@ class ForumFormDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class ForumDiscussionSearchUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
def setUp(self):
super(ForumDiscussionSearchUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
self.student = UserFactory.create()
CourseEnrollmentFactory(user=self.student, course_id=self.course.id)
......@@ -1104,6 +1118,8 @@ class ForumDiscussionSearchUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class SingleThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
def setUp(self):
super(SingleThreadUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
self.student = UserFactory.create()
CourseEnrollmentFactory(user=self.student, course_id=self.course.id)
......@@ -1126,6 +1142,8 @@ class SingleThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class UserProfileUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
def setUp(self):
super(UserProfileUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
self.student = UserFactory.create()
CourseEnrollmentFactory(user=self.student, course_id=self.course.id)
......@@ -1147,6 +1165,8 @@ class UserProfileUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
class FollowedThreadsUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
def setUp(self):
super(FollowedThreadsUnicodeTestCase, self).setUp()
self.course = CourseFactory.create()
self.student = UserFactory.create()
CourseEnrollmentFactory(user=self.student, course_id=self.course.id)
......
......@@ -17,6 +17,7 @@ class PermissionsTestCase(TestCase):
return ''.join(random.choice(chars) for x in range(length))
def setUp(self):
super(PermissionsTestCase, self).setUp()
self.course_id = "edX/toy/2012_Fall"
......
......@@ -13,6 +13,8 @@ class MockCommentServiceServerTest(unittest.TestCase):
'''
def setUp(self):
super(MockCommentServiceServerTest, self).setUp()
# This is a test of the test setup,
# so it does not need to run as part of the unit test suite
# You can re-enable it by commenting out the line below
......
......@@ -8,6 +8,7 @@ import django_comment_client.middleware as middleware
class AjaxExceptionTestCase(TestCase):
def setUp(self):
super(AjaxExceptionTestCase, self).setUp()
self.a = middleware.AjaxExceptionMiddleware()
self.request1 = django.http.HttpRequest()
self.request0 = django.http.HttpRequest()
......
......@@ -16,6 +16,8 @@ class RoleClassTestCase(ModuleStoreTestCase):
Tests for roles of the comment client service integration
"""
def setUp(self):
super(RoleClassTestCase, self).setUp()
# For course ID, syntax edx/classname/classdate is important
# because xmodel.course_module.id_to_location looks for a string to split
......@@ -57,6 +59,7 @@ class PermissionClassTestCase(TestCase):
Tests for permissions of the comment client service integration
"""
def setUp(self):
super(PermissionClassTestCase, self).setUp()
self.permission = models.Permission.objects.get_or_create(name="test")[0]
def test_unicode(self):
......
......@@ -4,6 +4,7 @@ import django_comment_client.mustache_helpers as mustache_helpers
class PluralizeTest(TestCase):
def setUp(self):
super(PluralizeTest, self).setUp()
self.text1 = '0 goat'
self.text2 = '1 goat'
self.text3 = '7 goat'
......@@ -17,6 +18,7 @@ class PluralizeTest(TestCase):
class CloseThreadTextTest(TestCase):
def setUp(self):
super(CloseThreadTextTest, self).setUp()
self.contentClosed = {'closed': True}
self.contentOpen = {'closed': False}
......
......@@ -49,6 +49,8 @@ class AccessUtilsTestCase(ModuleStoreTestCase):
comment client service integration
"""
def setUp(self):
super(AccessUtilsTestCase, self).setUp(create_user=False)
self.course = CourseFactory.create()
self.course_id = self.course.id
self.student_role = RoleFactory(name='Student', course_id=self.course_id)
......@@ -90,6 +92,8 @@ class CoursewareContextTestCase(ModuleStoreTestCase):
comment client service integration
"""
def setUp(self):
super(CoursewareContextTestCase, self).setUp()
self.course = CourseFactory.create(org="TestX", number="101", display_name="Test Course")
self.discussion1 = ItemFactory.create(
parent_location=self.course.location,
......@@ -151,6 +155,8 @@ class CategoryMapTestCase(ModuleStoreTestCase):
comment client service integration
"""
def setUp(self):
super(CategoryMapTestCase, self).setUp()
self.course = CourseFactory.create(
org="TestX", number="101", display_name="Test Course",
# This test needs to use a course that has already started --
......
......@@ -62,6 +62,8 @@ class EdxNotesDecoratorTest(TestCase):
"""
def setUp(self):
super(EdxNotesDecoratorTest, self).setUp()
ClientFactory(name="edx-notes")
self.course = CourseFactory.create(edxnotes=True)
self.user = UserFactory.create(username="Bob", email="bob@example.com", password="edx")
......
......@@ -22,6 +22,8 @@ log = logging.getLogger(__name__)
class FolditTestCase(TestCase):
"""Tests for various responses of the FoldIt module"""
def setUp(self):
super(FolditTestCase, self).setUp()
self.factory = RequestFactory()
self.url = reverse('foldit_ops')
......
......@@ -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
......
......@@ -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(
......
......@@ -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)
......
......@@ -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.
......
......@@ -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
......
......@@ -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
......
......@@ -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()
......
......@@ -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)
......
......@@ -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')
......
......@@ -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(
......
......@@ -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')
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment