From 4106528e1a2207257e83be23803e2cbbe58b6087 Mon Sep 17 00:00:00 2001 From: John Eskew Date: Tue, 22 Dec 2015 15:26:06 -0500 Subject: [PATCH] Fix toy course textbook test - use Mongo-backed test course. --- common/lib/xmodule/xmodule/course_module.py | 2 +- .../xmodule/xmodule/modulestore/tests/factories.py | 3 ++- lms/djangoapps/courseware/tests/tests.py | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 85188e7ddb..36fd65d294 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -175,7 +175,7 @@ class CourseFields(object): scope=Scope.settings ) textbooks = TextbookList( - help=_("List of pairs of (title, url) for textbooks used in this course"), + help=_("List of Textbook objects with (title, url) for textbooks used in this course"), default=[], scope=Scope.content ) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/factories.py b/common/lib/xmodule/xmodule/modulestore/tests/factories.py index b33ed1d65e..66e4ea081d 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/factories.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/factories.py @@ -25,6 +25,7 @@ from xmodule.modulestore import prefer_xmodules, ModuleStoreEnum from xmodule.modulestore.tests.sample_courses import default_block_info_tree, TOY_BLOCK_INFO_TREE from xmodule.tabs import CourseTab from xmodule.x_module import DEPRECATION_VSCOMPAT_EVENT +from xmodule.course_module import Textbook class Dummy(object): @@ -190,7 +191,7 @@ class ToyCourseFactory(SampleCourseFactory): fields = { 'block_info_tree': TOY_BLOCK_INFO_TREE, - 'textbooks': [["Textbook", "path/to/a/text_book"]], + 'textbooks': [Textbook("Textbook", "path/to/a/text_book")], 'wiki_slug': "toy", 'graded': True, 'discussion_topics': {"General": {"id": "i4x-edX-toy-course-2012_Fall"}}, diff --git a/lms/djangoapps/courseware/tests/tests.py b/lms/djangoapps/courseware/tests/tests.py index 32e658d9aa..5189f143c7 100644 --- a/lms/djangoapps/courseware/tests/tests.py +++ b/lms/djangoapps/courseware/tests/tests.py @@ -10,11 +10,13 @@ from nose.plugins.attrib import attr from opaque_keys.edx.locations import SlashSeparatedCourseKey from courseware.tests.helpers import LoginEnrollmentTestCase -from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_TOY_MODULESTORE as TOY_MODULESTORE from lms.djangoapps.lms_xblock.field_data import LmsFieldData from xmodule.error_module import ErrorDescriptor from xmodule.modulestore.django import modulestore -from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase +from xmodule.modulestore.tests.django_utils import ( + ModuleStoreTestCase, TEST_DATA_MIXED_TOY_MODULESTORE +) +from xmodule.modulestore.tests.factories import ToyCourseFactory @attr('shard_1') @@ -126,11 +128,12 @@ class TestMongoCoursesLoad(ModuleStoreTestCase, PageLoaderTestCase): """ Check that all pages in test courses load properly from Mongo. """ - MODULESTORE = TOY_MODULESTORE + MODULESTORE = TEST_DATA_MIXED_TOY_MODULESTORE def setUp(self): super(TestMongoCoursesLoad, self).setUp() self.setup_user() + self.toy_course_key = ToyCourseFactory.create().id @mock.patch('xmodule.course_module.requests.get') def test_toy_textbooks_loads(self, mock_get): @@ -139,8 +142,7 @@ class TestMongoCoursesLoad(ModuleStoreTestCase, PageLoaderTestCase): """).strip() - - location = SlashSeparatedCourseKey('edX', 'toy', '2012_Fall').make_usage_key('course', '2012_Fall') + location = self.toy_course_key.make_usage_key('course', '2012_Fall') course = self.store.get_item(location) self.assertGreater(len(course.textbooks), 0)