def test_remap_namespace_native_xblock_default_values(self): # Set the XBlock's location self.xblock.location = Location("i4x://import/org/run/stubxblock") # Do NOT set any values, so the fields should use the defaults self.xblock.save() # Remap the namespace target_location_namespace = Location("i4x://course/org/run/stubxblock") remap_namespace(self.xblock, target_location_namespace) # Check the values of the fields. # The content and settings fields should be the default values self.assertEqual(self.xblock.test_content_field, 'default value') self.assertEqual(self.xblock.test_settings_field, 'default value') # The fields should NOT appear in the explicitly set fields self.assertNotIn( 'test_content_field', self.xblock.get_explicitly_set_fields_by_scope( scope=Scope.content)) self.assertNotIn( 'test_settings_field', self.xblock.get_explicitly_set_fields_by_scope( scope=Scope.settings))
def test_remap_namespace_native_xblock(self): # Set the XBlock's location self.xblock.location = Location("i4x://import/org/run/stubxblock") # Explicitly set the content and settings fields self.xblock.test_content_field = "Explicitly set" self.xblock.test_settings_field = "Explicitly set" self.xblock.save() # Remap the namespace target_location_namespace = Location("i4x://course/org/run/stubxblock") remap_namespace(self.xblock, target_location_namespace) # Check the XBlock's location self.assertEqual(self.xblock.location, target_location_namespace) # Check the values of the fields. # The content and settings fields should be preserved self.assertEqual(self.xblock.test_content_field, 'Explicitly set') self.assertEqual(self.xblock.test_settings_field, 'Explicitly set') # Expect that these fields are marked explicitly set self.assertIn( 'test_content_field', self.xblock.get_explicitly_set_fields_by_scope( scope=Scope.content)) self.assertIn( 'test_settings_field', self.xblock.get_explicitly_set_fields_by_scope( scope=Scope.settings))
def test_remap_namespace_native_xblock(self): # Set the XBlock's location self.xblock.location = Location("i4x://import/org/run/stubxblock") # Explicitly set the content and settings fields self.xblock.test_content_field = "Explicitly set" self.xblock.test_settings_field = "Explicitly set" self.xblock.save() # Remap the namespace target_location_namespace = Location("i4x://course/org/run/stubxblock") remap_namespace(self.xblock, target_location_namespace) # Check the XBlock's location self.assertEqual(self.xblock.location, target_location_namespace) # Check the values of the fields. # The content and settings fields should be preserved self.assertEqual(self.xblock.test_content_field, "Explicitly set") self.assertEqual(self.xblock.test_settings_field, "Explicitly set") # Expect that these fields are marked explicitly set self.assertIn("test_content_field", self.xblock.get_explicitly_set_fields_by_scope(scope=Scope.content)) self.assertIn("test_settings_field", self.xblock.get_explicitly_set_fields_by_scope(scope=Scope.settings))
def test_remap_namespace_native_xblock_inherited_values(self): # Set the XBlock's location self.xblock.location = Location("i4x://import/org/run/stubxblock") self.xblock.save() # Remap the namespace target_location_namespace = Location("i4x://course/org/run/stubxblock") remap_namespace(self.xblock, target_location_namespace) # Inherited fields should NOT be explicitly set self.assertNotIn("start", self.xblock.get_explicitly_set_fields_by_scope(scope=Scope.settings)) self.assertNotIn("graded", self.xblock.get_explicitly_set_fields_by_scope(scope=Scope.settings))
def test_remap_namespace_native_xblock_inherited_values(self): # Set the XBlock's location self.xblock.location = Location("i4x://import/org/run/stubxblock") self.xblock.save() # Remap the namespace target_location_namespace = Location("i4x://course/org/run/stubxblock") remap_namespace(self.xblock, target_location_namespace) # Inherited fields should NOT be explicitly set self.assertNotIn( 'start', self.xblock.get_explicitly_set_fields_by_scope( scope=Scope.settings)) self.assertNotIn( 'graded', self.xblock.get_explicitly_set_fields_by_scope( scope=Scope.settings))
def test_remap_namespace_native_xblock_default_values(self): # Set the XBlock's location self.xblock.location = Location("i4x://import/org/run/stubxblock") # Do NOT set any values, so the fields should use the defaults self.xblock.save() # Remap the namespace target_location_namespace = Location("i4x://course/org/run/stubxblock") remap_namespace(self.xblock, target_location_namespace) # Check the values of the fields. # The content and settings fields should be the default values self.assertEqual(self.xblock.test_content_field, "default value") self.assertEqual(self.xblock.test_settings_field, "default value") # The fields should NOT appear in the explicitly set fields self.assertNotIn("test_content_field", self.xblock.get_explicitly_set_fields_by_scope(scope=Scope.content)) self.assertNotIn("test_settings_field", self.xblock.get_explicitly_set_fields_by_scope(scope=Scope.settings))