From 54ee1607b8c73e9d48e65490511b1221853d9500 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 23 Jan 2013 11:22:37 -0500 Subject: [PATCH 1/2] add unit test to test DraftModuleStore.get_items() fix --- lms/djangoapps/courseware/tests/tests.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lms/djangoapps/courseware/tests/tests.py b/lms/djangoapps/courseware/tests/tests.py index bf8a65126d..fad8ac6fef 100644 --- a/lms/djangoapps/courseware/tests/tests.py +++ b/lms/djangoapps/courseware/tests/tests.py @@ -64,6 +64,21 @@ def mongo_store_config(data_dir): } } +def draft_mongo_store_config(data_dir): + return { + 'default': { + 'ENGINE': 'xmodule.modulestore.mongo.DraftMongoModuleStore', + 'OPTIONS': { + 'default_class': 'xmodule.raw_module.RawDescriptor', + 'host': 'localhost', + 'db': 'test_xmodule', + 'collection': 'modulestore', + 'fs_root': data_dir, + 'render_template': 'mitxmako.shortcuts.render_to_string', + } + } +} + def xml_store_config(data_dir): return { 'default': { @@ -78,6 +93,7 @@ def xml_store_config(data_dir): TEST_DATA_DIR = settings.COMMON_TEST_DATA_ROOT TEST_DATA_XML_MODULESTORE = xml_store_config(TEST_DATA_DIR) TEST_DATA_MONGO_MODULESTORE = mongo_store_config(TEST_DATA_DIR) +TEST_DATA_DRAFT_MONGO_MODULESTORE = draft_mongo_store_config(TEST_DATA_DIR) class ActivateLoginTestCase(TestCase): '''Check that we can activate and log in''' @@ -423,6 +439,14 @@ class TestNavigation(PageLoader): kwargs={'course_id': self.toy.id, 'chapter': 'secret:magic'})) +@override_settings(MODULESTORE=TEST_DATA_DRAFT_MONGO_MODULESTORE) +class TestDraftModuleStore(TestCase): + def test_get_items_with_course_items(self): + store = modulestore() + # fix was to allow get_items() to take the course_id parameter + store.get_items(Location(None, None, 'vertical', None, None), course_id='abc', depth=0) + + @override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE) class TestViewAuth(PageLoader): """Check that view authentication works properly""" From dbf15fc2ac5322660446b979a7f3e7b31087d7ec Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 30 Jan 2013 09:46:38 -0500 Subject: [PATCH 2/2] add comment on draft store test which explains test success is just for get_items() not to throw an exception when passed in a course_id --- lms/djangoapps/courseware/tests/tests.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lms/djangoapps/courseware/tests/tests.py b/lms/djangoapps/courseware/tests/tests.py index fad8ac6fef..6c41cbac14 100644 --- a/lms/djangoapps/courseware/tests/tests.py +++ b/lms/djangoapps/courseware/tests/tests.py @@ -445,6 +445,8 @@ class TestDraftModuleStore(TestCase): store = modulestore() # fix was to allow get_items() to take the course_id parameter store.get_items(Location(None, None, 'vertical', None, None), course_id='abc', depth=0) + # test success is just getting through the above statement. The bug was that 'course_id' argument was + # not allowed to be passed in (i.e. was throwing exception) @override_settings(MODULESTORE=TEST_DATA_XML_MODULESTORE)