From 92391a22fc58d61c18b52888cdb532fdd4627fae Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 11 Jul 2013 08:42:24 -0400 Subject: [PATCH] Don't force field inheritance of default values --- .../xmodule/xmodule/modulestore/mongo/base.py | 4 ---- common/lib/xmodule/xmodule/tests/test_import.py | 17 +++-------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index 0b1c601a2f..ab63243aaf 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -630,10 +630,6 @@ class MongoModuleStore(ModuleStoreBase): definition_data = {} dbmodel = self._create_new_model_data(location.category, location, definition_data, metadata) xmodule = xblock_class(system, dbmodel) - # force inherited fields w/ defaults to take the defaults so the children can inherit - for attr in INHERITABLE_METADATA: - if hasattr(xmodule, attr): - xmodule._model_data[attr] = getattr(xmodule, attr) return xmodule def save_xmodule(self, xmodule): diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 30c8939b5b..2fe9d70627 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -156,11 +156,7 @@ class ImportTestCase(BaseCourseTestCase): child = descriptor.get_children()[0] self.assertEqual(child.lms.due, ImportTestCase.date.from_json(v)) self.assertEqual(child._inheritable_metadata, child._inherited_metadata) - self.assertEqual(2, len(child._inherited_metadata)) - self.assertLessEqual( - ImportTestCase.date.from_json(child._inherited_metadata['start']), - datetime.datetime.now(UTC()) - ) + self.assertEqual(1, len(child._inherited_metadata)) self.assertEqual(v, child._inherited_metadata['due']) # Now export and check things @@ -218,10 +214,8 @@ class ImportTestCase(BaseCourseTestCase): self.assertEqual(child.lms.due, None) # pylint: disable=W0212 self.assertEqual(child._inheritable_metadata, child._inherited_metadata) - self.assertEqual(1, len(child._inherited_metadata)) - # why do these tests look in the internal structure v just calling child.start? self.assertLessEqual( - ImportTestCase.date.from_json(child._inherited_metadata['start']), + child.lms.start, datetime.datetime.now(UTC()) ) @@ -249,12 +243,7 @@ class ImportTestCase(BaseCourseTestCase): self.assertEqual(descriptor.lms.due, ImportTestCase.date.from_json(course_due)) self.assertEqual(child.lms.due, ImportTestCase.date.from_json(child_due)) # Test inherited metadata. Due does not appear here (because explicitly set on child). - self.assertEqual(1, len(child._inherited_metadata)) - self.assertLessEqual( - ImportTestCase.date.from_json(child._inherited_metadata['start']), - datetime.datetime.now(UTC())) - # Test inheritable metadata. This has the course inheritable value for due. - self.assertEqual(2, len(child._inheritable_metadata)) + self.assertEqual(1, len(child._inheritable_metadata)) self.assertEqual(course_due, child._inheritable_metadata['due']) def test_is_pointer_tag(self):