Commit 4d8eb533 by Ned Batchelder

Merge pull request #335 from edx/ned/fix-course-factory

Fix broken tests by simplifying the CourseFactory
parents 14ed02c1 31a72093
......@@ -51,17 +51,13 @@ class XModuleCourseFactory(Factory):
]
)
data = kwargs.pop('data', None)
if data is not None:
store.update_item(new_course.location, data)
# The rest of kwargs become attributes on the course:
for k, v in kwargs.iteritems():
setattr(new_course, k, v)
# Update the data in the mongo datastore
store.update_metadata(new_course.location.url(), own_metadata(new_course))
store.update_item(new_course.location.url(), new_course._model_data._kvs._data)
store.update_metadata(new_course.location, own_metadata(new_course))
store.update_item(new_course.location, new_course._model_data._kvs._data)
# update_item updates the the course as it exists in the modulestore, but doesn't
# update the instance we are working with, so have to refetch the course after updating it.
......
......@@ -32,13 +32,11 @@ class BaseTestXmodule(ModuleStoreTestCase):
1. TEMPLATE_NAME
2. DATA
3. MODEL_DATA
4. COURSE_DATA and USER_COUNT if needed
This class should not contain any tests, because TEMPLATE_NAME
should be defined in child class.
"""
USER_COUNT = 2
COURSE_DATA = {}
# Data from YAML common/lib/xmodule/xmodule/templates/NAME/default.yaml
TEMPLATE_NAME = ""
......@@ -47,7 +45,7 @@ class BaseTestXmodule(ModuleStoreTestCase):
def setUp(self):
self.course = CourseFactory.create(data=self.COURSE_DATA)
self.course = CourseFactory.create()
# Turn off cache.
modulestore().request_cache = None
......
......@@ -27,11 +27,11 @@ class TestGradebook(ModuleStoreTestCase):
modulestore().request_cache = modulestore().metadata_inheritance_cache_subsystem = None
course_data = {}
kwargs = {}
if self.grading_policy is not None:
course_data['grading_policy'] = self.grading_policy
kwargs['grading_policy'] = self.grading_policy
self.course = CourseFactory.create(data=course_data)
self.course = CourseFactory.create(**kwargs)
chapter = ItemFactory.create(
parent_location=self.course.location,
template="i4x://edx/templates/sequential/Empty",
......
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