def test_meta_type_change_class(self): fti = DexterityFTI( 'testtype', klass='plone.dexterity.tests.test_fti.TestClass' ) fti._updateProperty( 'klass', 'plone.dexterity.tests.test_fti.TestClass2' ) self.assertEqual(TestClass2.meta_type, fti.Metatype())
def test_meta_type_change_class(self): fti = DexterityFTI( u"testtype", klass="plone.dexterity.tests.test_fti.TestClass" ) fti._updateProperty( 'klass', "plone.dexterity.tests.test_fti.TestClass2" ) self.assertEqual(TestClass2.meta_type, fti.Metatype())
def setUp(self): self.app = self.layer['app'] self.portal = self.layer['portal'] self.portal_url = self.portal.absolute_url() fti = DexterityFTI('ImageDocument') fti._updateProperty( 'schema', 'plone.restapi.tests.test_adapter_image.' 'IImageDocument' ) types_tool = getToolByName(self.portal, "portal_types") types_tool._setObject('ImageDocument', fti)
def test_fires_modified_event_on_update_property_if_changed(self): fti = DexterityFTI(u"testtype") fti.title = u"Old title" fti.global_allow = False notify_mock = self.mocker.replace('zope.event.notify') self.expect(notify_mock(mocker.MATCH(lambda x: IObjectModifiedEvent.providedBy(x) \ and len(x.descriptions) == 1 \ and x.descriptions[0].attribute == 'title' \ and x.descriptions[0].oldValue == "Old title"))) self.replay() fti._updateProperty('title', "New title") # fires event caught above fti._updateProperty('allow_discussion', False) # does not fire
def test_fires_modified_event_on_update_property_if_changed(self): fti = DexterityFTI(u"testtype") fti.title = u"Old title" fti.global_allow = False from zope.event import notify notify_mock = self.patch_global(notify) fti._updateProperty('title', "New title") # fires event caught above fti._updateProperty('allow_discussion', False) # does not fire event = notify_mock.call_args[0][0] self.assertTrue(IObjectModifiedEvent.providedBy(event)) self.assertEqual(len(event.descriptions), 1) self.assertEqual(event.descriptions[0].attribute, 'title') self.assertEqual(event.descriptions[0].oldValue, 'Old title')
def test_meta_type_change_class(self): fti = DexterityFTI('testtype', klass='plone.dexterity.tests.test_fti.TestClass') fti._updateProperty('klass', 'plone.dexterity.tests.test_fti.TestClass2') self.assertEqual(TestClass2.meta_type, fti.Metatype())