def test_simulateNestedFolderCloneRemovingUid1(self): self.root.site._setObject( 'foo', SimpleFolder(id='foo') ) self.root.site._setObject( 'foo2', SimpleFolder(id='foo2') ) foo = self.root.site.foo foo._setObject( 'sub1', SimpleFolder(id='sub1') ) foo.sub1._setObject( 'sub2', SimpleFolder(id='sub2') ) foo.sub1.sub2._setObject( 'baz', DummyContent(id='baz', catalog=1) ) baz = foo.sub1.sub2.baz annotation = self.root.portal_uidannotation(baz, UID_ATTRNAME) self.assertEqual( getattr(baz, UID_ATTRNAME), annotation ) transaction.savepoint(optimistic=True) cookie = self.root.site.manage_copyObjects(ids='foo') self.root.site.foo2.manage_pasteObjects(cookie) self.assertRaises(AttributeError, getattr, self.root.site.foo2.foo.sub1.sub2.baz, UID_ATTRNAME)
def setUp(self): SecurityTest.setUp(self) self.root._setObject('portal_uidannotation', self._getTargetClass()()) self.root._setObject('portal_uidhandler', DummyUniqueIdHandlerTool()) sm = getSiteManager() sm.registerUtility(self.root.portal_uidannotation, IUniqueIdAnnotationManagement) self.root._setObject('dummy', DummyContent(id='dummy')) self.root._setObject('site', SimpleFolder('site')) transaction.savepoint(optimistic=True)
def test_simulateItemCloneRemovingUid1(self): # an object is set in place, annotated and then copied self._initPolicyAndUser() # allow copy/paste operations dummy = TheClass('dummy') site = self.root.site site._setObject('dummy', dummy) annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME) self.root._setObject('folder1', SimpleFolder('folder1')) transaction.savepoint(optimistic=True) cookie = site.manage_copyObjects(ids=['dummy']) self.root.folder1.manage_pasteObjects( cookie ) self.assertRaises(AttributeError, getattr, self.root.folder1.dummy, UID_ATTRNAME)
def test_simulateItemCloneAssignsNewUid(self): # an object is set in place, annotated, and then copied self._initPolicyAndUser() # allow copy/paste operations dummy = TheClass('dummy') site = self.root.site site._setObject('dummy', dummy) annotation = self.root.portal_uidannotation(dummy, UID_ATTRNAME) self.root.portal_uidannotation.assign_on_clone = True self.root._setObject('folder1', SimpleFolder('folder1')) transaction.savepoint(optimistic=True) cookie = site.manage_copyObjects(ids=['dummy']) self.root.folder1.manage_pasteObjects( cookie ) new_annotation = getattr(self.root.folder1.dummy, UID_ATTRNAME) self.failIf( annotation() == new_annotation() )