From fcaa783e430b48ff2708c396f770eec92f690523 Mon Sep 17 00:00:00 2001 From: muhammad-ammar Date: Fri, 31 Oct 2014 09:54:44 +0000 Subject: [PATCH] Unit Test Improvements TE-489 --- .../commands/tests/test_cleanup_assets.py | 5 ++- .../contentstore/tests/test_contentstore.py | 42 ++++++++++--------- .../contentstore/tests/test_import.py | 18 ++++---- .../tests/test_import_draft_order.py | 5 ++- .../tests/test_import_pure_xblock.py | 5 ++- cms/djangoapps/contentstore/tests/utils.py | 5 ++- .../contentstore/views/tests/test_assets.py | 7 +++- common/djangoapps/contentserver/tests/test.py | 4 +- .../xmodule/modulestore/tests/django_utils.py | 3 +- .../test_cross_modulestore_import_export.py | 4 +- common/test/data/empty/.gitkeep | 0 .../course_wiki/tests/test_access.py | 8 +--- .../course_wiki/tests/test_middleware.py | 4 +- lms/djangoapps/course_wiki/tests/tests.py | 17 ++++---- .../commands/tests/test_dump_course.py | 3 +- lms/djangoapps/courseware/tests/__init__.py | 4 +- lms/djangoapps/courseware/tests/test_about.py | 16 ++++--- .../courseware/tests/test_access.py | 6 +-- .../dashboard/tests/test_sysadmin.py | 5 ++- .../django_comment_client/base/tests.py | 20 +++++---- .../django_comment_client/forum/tests.py | 36 +++++++++------- .../instructor/tests/test_access.py | 10 ++--- lms/djangoapps/instructor/tests/test_api.py | 28 ++++++------- lms/djangoapps/instructor/tests/test_email.py | 4 +- .../instructor/tests/test_enrollment.py | 6 +-- .../instructor/tests/test_hint_manager.py | 6 ++- .../instructor/tests/test_legacy_anon_csv.py | 11 +++-- .../tests/test_legacy_download_csv.py | 11 +++-- .../tests/test_legacy_enrollment.py | 4 +- .../tests/test_legacy_forum_admin.py | 13 ++---- .../instructor/tests/test_legacy_reset.py | 4 +- .../instructor/tests/test_legacy_xss.py | 6 ++- .../instructor/tests/test_spoc_gradebook.py | 4 +- lms/djangoapps/instructor/tests/test_tools.py | 10 ++--- .../instructor_task/tests/test_base.py | 6 +-- lms/djangoapps/licenses/tests.py | 4 +- lms/djangoapps/oauth2_handler/tests.py | 5 ++- lms/djangoapps/staticbook/tests.py | 4 +- 38 files changed, 194 insertions(+), 159 deletions(-) create mode 100644 common/test/data/empty/.gitkeep diff --git a/cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py b/cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py index 6c7dfc8628..7bda45df3b 100644 --- a/cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py +++ b/cms/djangoapps/contentstore/management/commands/tests/test_cleanup_assets.py @@ -11,6 +11,9 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.mongo.base import location_to_query from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.xml_importer import import_from_xml +from django.conf import settings + +TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT class ExportAllCourses(ModuleStoreTestCase): @@ -30,7 +33,7 @@ class ExportAllCourses(ModuleStoreTestCase): import_from_xml( self.module_store, '**replace_user**', - 'common/test/data/', + TEST_DATA_DIR, ['dot-underscore'], static_content_store=self.content_store, do_import_static=True, diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index fa22a9fbaa..cfae6f55a8 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -56,6 +56,8 @@ from xmodule.contentstore.content import StaticContent TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex +TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT + @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) class ContentStoreTestCase(CourseTestCase): @@ -69,7 +71,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): Tests which legitimately need to import a course """ def test_no_static_link_rewrites_on_import(self): - course_items = import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy']) + course_items = import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy']) course = course_items[0] handouts_usage_key = course.id.make_usage_key('course_info', 'handouts') @@ -81,7 +83,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): self.assertIn('/static/', handouts.data) def test_xlint_fails(self): - err_cnt = perform_xlint('common/test/data', ['toy']) + err_cnt = perform_xlint(TEST_DATA_DIR, ['toy']) self.assertGreater(err_cnt, 0) def test_about_overrides(self): @@ -90,7 +92,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): e.g. /about/Fall_2012/effort.html while there is a base definition in /about/effort.html ''' - course_items = import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy']) + course_items = import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy']) course_key = course_items[0].id effort = self.store.get_item(course_key.make_usage_key('about', 'effort')) self.assertEqual(effort.data, '6 hours') @@ -105,7 +107,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): ''' content_store = contentstore() - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy'], static_content_store=content_store, verbose=True) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], static_content_store=content_store, verbose=True) course = self.store.get_course(SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')) @@ -153,7 +155,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): Test that course info updates are imported and exported with all content fields ('data', 'items') """ content_store = contentstore() - data_dir = "common/test/data/" + data_dir = TEST_DATA_DIR courses = import_from_xml( self.store, self.user.id, data_dir, ['course_info_updates'], static_content_store=content_store, verbose=True, @@ -166,7 +168,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): self.assertIsNotNone(course_updates) # check that course which is imported has files 'updates.html' and 'updates.items.json' - filesystem = OSFS(data_dir + 'course_info_updates/info') + filesystem = OSFS(data_dir + '/course_info_updates/info') self.assertTrue(filesystem.exists('updates.html')) self.assertTrue(filesystem.exists('updates.items.json')) @@ -204,7 +206,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): def test_rewrite_nonportable_links_on_import(self): content_store = contentstore() - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy'], static_content_store=content_store) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], static_content_store=content_store) # first check a static asset link course_key = SlashSeparatedCourseKey('edX', 'toy', 'run') @@ -314,7 +316,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): def test_export_course_with_metadata_only_video(self): content_store = contentstore() - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy']) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy']) course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') # create a new video module and add it as a child to a vertical @@ -343,7 +345,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): """ content_store = contentstore() - import_from_xml(self.store, self.user.id, 'common/test/data/', ['word_cloud']) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['word_cloud']) course_id = SlashSeparatedCourseKey('HarvardX', 'ER22x', '2013_Spring') verticals = self.store.get_items(course_id, qualifiers={'category': 'vertical'}) @@ -370,7 +372,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): """ content_store = contentstore() - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy']) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy']) course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') verticals = self.store.get_items(course_id, qualifiers={'category': 'vertical'}) @@ -401,7 +403,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): """ content_store = contentstore() - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy']) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy']) course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') @@ -423,7 +425,7 @@ class ImportRequiredTestCases(ContentStoreTestCase): def test_export_course_without_content_store(self): # Create toy course - course_items = import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy']) + course_items = import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy']) course_id = course_items[0].id root_dir = path(mkdtemp_clean()) @@ -1212,7 +1214,7 @@ class ContentStoreTest(ContentStoreTestCase): ) self.assertEqual(resp.status_code, 200) - course_items = import_from_xml(self.store, self.user.id, 'common/test/data/', ['simple']) + course_items = import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['simple']) course_key = course_items[0].id resp = self._show_course_overview(course_key) @@ -1259,7 +1261,7 @@ class ContentStoreTest(ContentStoreTestCase): target_course_id = _get_course_id(self.course_data) _create_course(self, target_course_id, self.course_data) - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy'], target_course_id=target_course_id) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], target_course_id=target_course_id) modules = self.store.get_items(target_course_id) @@ -1294,7 +1296,7 @@ class ContentStoreTest(ContentStoreTestCase): course_module.save() # Import a course with wiki_slug == location.course - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy'], target_course_id=target_course_id) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], target_course_id=target_course_id) course_module = self.store.get_course(target_course_id) self.assertEquals(course_module.wiki_slug, 'toy') @@ -1309,17 +1311,17 @@ class ContentStoreTest(ContentStoreTestCase): _create_course(self, target_course_id, course_data) # Import a course with wiki_slug == location.course - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy'], target_course_id=target_course_id) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], target_course_id=target_course_id) course_module = self.store.get_course(target_course_id) self.assertEquals(course_module.wiki_slug, 'MITx.111.2013_Spring') # Now try importing a course with wiki_slug == '{0}.{1}.{2}'.format(location.org, location.course, location.run) - import_from_xml(self.store, self.user.id, 'common/test/data/', ['two_toys'], target_course_id=target_course_id) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['two_toys'], target_course_id=target_course_id) course_module = self.store.get_course(target_course_id) self.assertEquals(course_module.wiki_slug, 'MITx.111.2013_Spring') def test_import_metadata_with_attempts_empty_string(self): - import_from_xml(self.store, self.user.id, 'common/test/data/', ['simple']) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['simple']) did_load_item = False try: course_key = SlashSeparatedCourseKey('edX', 'simple', 'problem') @@ -1341,7 +1343,7 @@ class ContentStoreTest(ContentStoreTestCase): self.assertNotEquals(new_discussion_item.discussion_id, '$$GUID$$') def test_metadata_inheritance(self): - course_items = import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy']) + course_items = import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy']) course = course_items[0] verticals = self.store.get_items(course.id, qualifiers={'category': 'vertical'}) @@ -1410,7 +1412,7 @@ class ContentStoreTest(ContentStoreTestCase): courses = import_from_xml( self.store, self.user.id, - 'common/test/data/', + TEST_DATA_DIR, ['conditional_and_poll'], static_content_store=content_store ) diff --git a/cms/djangoapps/contentstore/tests/test_import.py b/cms/djangoapps/contentstore/tests/test_import.py index d8f4dfe95c..fe81ce05ea 100644 --- a/cms/djangoapps/contentstore/tests/test_import.py +++ b/cms/djangoapps/contentstore/tests/test_import.py @@ -24,6 +24,8 @@ from uuid import uuid4 TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex +TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT + @ddt.ddt @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) @@ -48,7 +50,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): import_from_xml( module_store, self.user.id, - 'common/test/data/', + TEST_DATA_DIR, ['test_import_course'], static_content_store=content_store, do_import_static=False, @@ -70,7 +72,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): course_items = import_from_xml( module_store, self.user.id, - 'common/test/data', + TEST_DATA_DIR, ['test_import_course_2'], target_course_id=course.id, verbose=True, @@ -86,7 +88,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): import_from_xml( module_store, self.user.id, - 'common/test/data/', + TEST_DATA_DIR, ['2014_Uni'], target_course_id=course_id ) @@ -131,7 +133,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): content_store = contentstore() module_store = modulestore() - import_from_xml(module_store, self.user.id, 'common/test/data/', ['toy'], static_content_store=content_store, do_import_static=False, verbose=True) + import_from_xml(module_store, self.user.id, TEST_DATA_DIR, ['toy'], static_content_store=content_store, do_import_static=False, verbose=True) course = module_store.get_course(SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')) @@ -142,7 +144,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): def test_no_static_link_rewrites_on_import(self): module_store = modulestore() - courses = import_from_xml(module_store, self.user.id, 'common/test/data/', ['toy'], do_import_static=False, verbose=True) + courses = import_from_xml(module_store, self.user.id, TEST_DATA_DIR, ['toy'], do_import_static=False, verbose=True) course_key = courses[0].id handouts = module_store.get_item(course_key.make_usage_key('course_info', 'handouts')) @@ -183,7 +185,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): import_from_xml( module_store, self.user.id, - 'common/test/data/', + TEST_DATA_DIR, ['conditional'], target_course_id=target_course_id ) @@ -213,7 +215,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): import_from_xml( module_store, self.user.id, - 'common/test/data/', + TEST_DATA_DIR, ['open_ended'], target_course_id=target_course_id ) @@ -254,7 +256,7 @@ class ContentStoreImportTest(ModuleStoreTestCase): import_from_xml( module_store, self.user.id, - 'common/test/data/', + TEST_DATA_DIR, [source_course_name], target_course_id=target_course_id ) diff --git a/cms/djangoapps/contentstore/tests/test_import_draft_order.py b/cms/djangoapps/contentstore/tests/test_import_draft_order.py index 13c47ea53a..4f3e2c1d3a 100644 --- a/cms/djangoapps/contentstore/tests/test_import_draft_order.py +++ b/cms/djangoapps/contentstore/tests/test_import_draft_order.py @@ -2,6 +2,9 @@ from xmodule.modulestore.xml_importer import import_from_xml from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.django import modulestore +from django.conf import settings + +TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT # This test is in the CMS module because the test configuration to use a draft @@ -10,7 +13,7 @@ class DraftReorderTestCase(ModuleStoreTestCase): def test_order(self): store = modulestore() - course_items = import_from_xml(store, self.user.id, 'common/test/data/', ['import_draft_order']) + course_items = import_from_xml(store, self.user.id, TEST_DATA_DIR, ['import_draft_order']) course_key = course_items[0].id sequential = store.get_item(course_key.make_usage_key('sequential', '0f4f7649b10141b0bdc9922dcf94515a')) verticals = sequential.children diff --git a/cms/djangoapps/contentstore/tests/test_import_pure_xblock.py b/cms/djangoapps/contentstore/tests/test_import_pure_xblock.py index 681c1b1d44..7f8c7554fd 100644 --- a/cms/djangoapps/contentstore/tests/test_import_pure_xblock.py +++ b/cms/djangoapps/contentstore/tests/test_import_pure_xblock.py @@ -9,6 +9,9 @@ from xmodule.modulestore.xml_importer import import_from_xml from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.django import modulestore from xmodule.modulestore.mongo.draft import as_draft +from django.conf import settings + +TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT class StubXBlock(XBlock): @@ -59,7 +62,7 @@ class XBlockImportTest(ModuleStoreTestCase): """ courses = import_from_xml( - self.store, self.user.id, 'common/test/data', [course_dir] + self.store, self.user.id, TEST_DATA_DIR, [course_dir] ) xblock_location = courses[0].id.make_usage_key('stubxblock', 'xblock_test') diff --git a/cms/djangoapps/contentstore/tests/utils.py b/cms/djangoapps/contentstore/tests/utils.py index cc1b4b4717..4b546108bb 100644 --- a/cms/djangoapps/contentstore/tests/utils.py +++ b/cms/djangoapps/contentstore/tests/utils.py @@ -18,6 +18,9 @@ from student.models import Registration from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation from contentstore.utils import reverse_url from xmodule.modulestore.split_mongo.split import SplitMongoModuleStore +from django.conf import settings + +TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT def parse_json(response): @@ -135,7 +138,7 @@ class CourseTestCase(ModuleStoreTestCase): Imports the test toy course and populates it with additional test data """ content_store = contentstore() - import_from_xml(self.store, self.user.id, 'common/test/data/', ['toy'], static_content_store=content_store) + import_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], static_content_store=content_store) course_id = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') # create an Orphan diff --git a/cms/djangoapps/contentstore/views/tests/test_assets.py b/cms/djangoapps/contentstore/views/tests/test_assets.py index a0c33f22f3..d0a5f7928d 100644 --- a/cms/djangoapps/contentstore/views/tests/test_assets.py +++ b/cms/djangoapps/contentstore/views/tests/test_assets.py @@ -21,6 +21,9 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.xml_importer import import_from_xml from django.test.utils import override_settings from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation +from django.conf import settings + +TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT class AssetsTestCase(CourseTestCase): @@ -54,7 +57,7 @@ class BasicAssetsTestCase(AssetsTestCase): course_items = import_from_xml( module_store, self.user.id, - 'common/test/data/', + TEST_DATA_DIR, ['toy'], static_content_store=contentstore(), verbose=True @@ -247,7 +250,7 @@ class LockAssetTestCase(AssetsTestCase): course_items = import_from_xml( module_store, self.user.id, - 'common/test/data/', + TEST_DATA_DIR, ['toy'], static_content_store=contentstore(), verbose=True diff --git a/common/djangoapps/contentserver/tests/test.py b/common/djangoapps/contentserver/tests/test.py index 8ecb14cc13..872dea3af8 100644 --- a/common/djangoapps/contentserver/tests/test.py +++ b/common/djangoapps/contentserver/tests/test.py @@ -25,6 +25,8 @@ log = logging.getLogger(__name__) TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex +TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT + @ddt.ddt @override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE) @@ -47,7 +49,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): self.course_key = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall') import_from_xml( - modulestore(), self.user.id, 'common/test/data/', ['toy'], + modulestore(), self.user.id, TEST_DATA_DIR, ['toy'], static_content_store=self.contentstore, verbose=True ) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py index 8208ef588c..bac06d756e 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py @@ -116,7 +116,7 @@ def split_mongo_store_config(data_dir): return store -def xml_store_config(data_dir): +def xml_store_config(data_dir, course_dirs=None): """ Defines default module store using XMLModuleStore. """ @@ -127,6 +127,7 @@ def xml_store_config(data_dir): 'OPTIONS': { 'data_dir': data_dir, 'default_class': 'xmodule.hidden_module.HiddenDescriptor', + 'course_dirs': course_dirs, } } } diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py b/common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py index d08bb518fa..9cdaba7a9d 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py @@ -31,6 +31,8 @@ from xmodule.modulestore.tests.mongo_connection import MONGO_PORT_NUM, MONGO_HOS from xmodule.modulestore.inheritance import InheritanceMixin from xmodule.x_module import XModuleMixin +TEST_DATA_DIR = 'common/test/data/' + COMMON_DOCSTORE_CONFIG = { 'host': MONGO_HOST, @@ -289,7 +291,7 @@ class CrossStoreXMLRoundtrip(CourseComparisonTest): import_from_xml( source_store, 'test_user', - 'common/test/data', + TEST_DATA_DIR, course_dirs=[course_data_name], static_content_store=source_content, target_course_id=source_course_key, diff --git a/common/test/data/empty/.gitkeep b/common/test/data/empty/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lms/djangoapps/course_wiki/tests/test_access.py b/lms/djangoapps/course_wiki/tests/test_access.py index bc501fa0ee..c4bf9e5091 100644 --- a/lms/djangoapps/course_wiki/tests/test_access.py +++ b/lms/djangoapps/course_wiki/tests/test_access.py @@ -9,7 +9,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from django.test.utils import override_settings from courseware.tests.factories import InstructorFactory, StaffFactory -from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE +from courseware.tests.modulestore_config import TEST_DATA_MONGO_MODULESTORE from wiki.models import URLPath from course_wiki.views import get_or_create_root @@ -17,7 +17,7 @@ from course_wiki.utils import user_is_article_course_staff, course_wiki_slug from course_wiki import settings -@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) +@override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) class TestWikiAccessBase(ModuleStoreTestCase): """Base class for testing wiki access.""" def setUp(self): @@ -53,7 +53,6 @@ class TestWikiAccessBase(ModuleStoreTestCase): ] -@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class TestWikiAccess(TestWikiAccessBase): """Test wiki access for course staff.""" def setUp(self): @@ -114,7 +113,6 @@ class TestWikiAccess(TestWikiAccessBase): self.assertFalse(user_is_article_course_staff(course_staff, self.wiki_310b.article)) -@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class TestWikiAccessForStudent(TestWikiAccessBase): """Test access for students.""" def setUp(self): @@ -130,7 +128,6 @@ class TestWikiAccessForStudent(TestWikiAccessBase): self.assertFalse(user_is_article_course_staff(self.student, page.article)) -@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class TestWikiAccessForNumericalCourseNumber(TestWikiAccessBase): """Test staff has access if course number is numerical and wiki slug has an underscore appended.""" def setUp(self): @@ -150,7 +147,6 @@ class TestWikiAccessForNumericalCourseNumber(TestWikiAccessBase): self.assertTrue(user_is_article_course_staff(course_staff, page.article)) -@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class TestWikiAccessForOldFormatCourseStaffGroups(TestWikiAccessBase): """Test staff has access if course group has old format.""" def setUp(self): diff --git a/lms/djangoapps/course_wiki/tests/test_middleware.py b/lms/djangoapps/course_wiki/tests/test_middleware.py index d8373407ea..28e548996e 100644 --- a/lms/djangoapps/course_wiki/tests/test_middleware.py +++ b/lms/djangoapps/course_wiki/tests/test_middleware.py @@ -10,11 +10,11 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory from courseware.tests.factories import InstructorFactory -from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE +from courseware.tests.modulestore_config import TEST_DATA_MONGO_MODULESTORE from course_wiki.views import get_or_create_root -@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) +@override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) class TestWikiAccessMiddleware(ModuleStoreTestCase): """Tests for WikiAccessMiddleware.""" diff --git a/lms/djangoapps/course_wiki/tests/tests.py b/lms/djangoapps/course_wiki/tests/tests.py index d12bdda138..30e57774b1 100644 --- a/lms/djangoapps/course_wiki/tests/tests.py +++ b/lms/djangoapps/course_wiki/tests/tests.py @@ -2,21 +2,24 @@ from django.core.urlresolvers import reverse from django.test.utils import override_settings from courseware.tests.tests import LoginEnrollmentTestCase -from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE -from xmodule.modulestore.django import modulestore -from opaque_keys.edx.locations import SlashSeparatedCourseKey +from courseware.tests.modulestore_config import TEST_DATA_MONGO_MODULESTORE +from xmodule.modulestore.tests.factories import CourseFactory from mock import patch -@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) +@override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) 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): - # Load the toy course - self.toy = modulestore().get_course(SlashSeparatedCourseKey('edX', 'toy', '2012_Fall')) - # Create two accounts self.student = 'view@test.com' self.instructor = 'view2@test.com' diff --git a/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py b/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py index 286ab1bada..433a494c84 100644 --- a/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py +++ b/lms/djangoapps/courseware/management/commands/tests/test_dump_course.py @@ -24,8 +24,9 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.xml_importer import import_from_xml from opaque_keys.edx.locations import SlashSeparatedCourseKey +from django.conf import settings -DATA_DIR = 'common/test/data/' +DATA_DIR = settings.COMMON_TEST_DATA_ROOT TEST_COURSE_ID = 'edX/simple/2012_Fall' diff --git a/lms/djangoapps/courseware/tests/__init__.py b/lms/djangoapps/courseware/tests/__init__.py index e0a0d0ee6a..29f07391d5 100644 --- a/lms/djangoapps/courseware/tests/__init__.py +++ b/lms/djangoapps/courseware/tests/__init__.py @@ -13,7 +13,7 @@ from django.test.client import Client from edxmako.shortcuts import render_to_string from student.tests.factories import UserFactory, CourseEnrollmentFactory -from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE +from courseware.tests.modulestore_config import TEST_DATA_MONGO_MODULESTORE from xblock.field_data import DictFieldData from xmodule.tests import get_test_system, get_test_descriptor_system from opaque_keys.edx.locations import Location @@ -24,7 +24,7 @@ from lms.lib.xblock.field_data import LmsFieldData from lms.lib.xblock.runtime import quote_slashes -@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) +@override_settings(MODULESTORE=TEST_DATA_MONGO_MODULESTORE) class BaseTestXmodule(ModuleStoreTestCase): """Base class for testing Xmodules with mongo store. diff --git a/lms/djangoapps/courseware/tests/test_about.py b/lms/djangoapps/courseware/tests/test_about.py index c02ae50c08..49c95fc422 100644 --- a/lms/djangoapps/courseware/tests/test_about.py +++ b/lms/djangoapps/courseware/tests/test_about.py @@ -11,7 +11,7 @@ from django.conf import settings from .helpers import LoginEnrollmentTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase -from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE +from courseware.tests.modulestore_config import TEST_DATA_MONGO_MODULESTORE, TEST_DATA_MIXED_MODULESTORE from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from opaque_keys.edx.locations import SlashSeparatedCourseKey from student.tests.factories import UserFactory, CourseEnrollmentAllowedFactory @@ -21,8 +21,12 @@ REG_STR = "