def test_moved_event2(self): # move from one folder to another manage_addNoVerifyPasteFolder(self.folder, 'folder1', 'Folder1') folder1 = self.folder.folder1 manage_addNoVerifyPasteFolder(self.folder, 'folder2', 'Folder2') folder2 = self.folder.folder2 manage_addSimpleContent(folder1, 'foo', 'Foo') foo = folder1.foo # need to trigger subtransaction before copy/paste can work get_transaction().commit(1) cb = folder1.manage_cutObjects(['foo']) folder2.manage_pasteObjects(cb) newfoo = folder2.foo events = objectMovedEventCatcher.getEvents() self.assertEquals(3, len(events)) self.assertEquals(1, len(objectAddedEventCatcher.getEvents())) # removed event self.assertEquals(folder1.getPhysicalPath(), events[1].oldParent.getPhysicalPath()) self.assertEquals(None, events[1].newParent) # moved event self.assertEquals(newfoo.getPhysicalPath(), events[2].object.getPhysicalPath()) self.assertEquals(folder1.getPhysicalPath(), events[2].oldParent.getPhysicalPath()) self.assertEquals(folder2.getPhysicalPath(), events[2].newParent.getPhysicalPath()) self.assertEquals('foo', events[2].oldName) self.assertEquals('foo', events[2].newName)
def test_moved_event2(self): # move from one folder to another manage_addNoVerifyPasteFolder(self.folder, 'folder1', 'Folder1') folder1 = self.folder.folder1 manage_addNoVerifyPasteFolder(self.folder, 'folder2', 'Folder2') folder2 = self.folder.folder2 manage_addSimpleContent(folder1, 'foo', 'Foo') foo = folder1.foo # need to trigger subtransaction before copy/paste can work transaction.savepoint() cb = folder1.manage_cutObjects(['foo']) folder2.manage_pasteObjects(cb) newfoo = folder2.foo events = objectMovedEventCatcher.getEvents() self.assertEquals(3, len(events)) self.assertEquals(1, len(objectAddedEventCatcher.getEvents())) # removed event self.assertEquals(folder1.getPhysicalPath(), events[1].oldParent.getPhysicalPath()) self.assertEquals(None, events[1].newParent) # moved event self.assertEquals(newfoo.getPhysicalPath(), events[2].object.getPhysicalPath()) self.assertEquals(folder1.getPhysicalPath(), events[2].oldParent.getPhysicalPath()) self.assertEquals(folder2.getPhysicalPath(), events[2].newParent.getPhysicalPath()) self.assertEquals('foo', events[2].oldName) self.assertEquals('foo', events[2].newName)
def test_added_event(self): manage_addSimpleContent(self.folder, 'foo', 'Foo') foo = self.folder.foo events = objectEventCatcher.getEvents() self.assertEquals(1, len(events)) self.assertEquals(foo.getPhysicalPath(), events[0].object.getPhysicalPath()) events = objectAddedEventCatcher.getEvents() self.assertEquals(1, len(events)) self.assertEquals(foo.getPhysicalPath(), events[0].object.getPhysicalPath()) self.assertEquals(foo.aq_parent.getPhysicalPath(), events[0].newParent.getPhysicalPath())
def test_added_event(self): manage_addSimpleContent(self.folder, 'foo', 'Foo') foo = self.folder.foo events = objectEventCatcher.getEvents() self.assertEquals(1, len(events)) self.assertEquals(foo.getPhysicalPath(), events[0].object.getPhysicalPath()) events = objectAddedEventCatcher.getEvents() self.assertEquals(1, len(events)) self.assertEquals(foo.getPhysicalPath(), events[0].object.getPhysicalPath()) self.assertEquals(foo.aq_parent.getPhysicalPath(), events[0].newParent.getPhysicalPath())
def test_copied_event(self): manage_addSimpleContent(self.folder, 'foo', 'Foo') manage_addNoVerifyPasteFolder(self.folder, 'folder1') folder1 = self.folder.folder1 # need to trigger subtransaction before copy/paste can work get_transaction().commit(1) cb = self.folder.manage_copyObjects(['foo']) folder1.manage_pasteObjects(cb) foo_copy = folder1.foo events = objectCopiedEventCatcher.getEvents() self.assertEquals(1, len(events)) self.assertEquals(foo_copy.getPhysicalPath(), events[0].object.getPhysicalPath()) events = objectAddedEventCatcher.getEvents() self.assertEquals(2, len(events)) self.assertEquals(foo_copy.getPhysicalPath(), events[1].object.getPhysicalPath())
def test_copied_event(self): manage_addSimpleContent(self.folder, 'foo', 'Foo') manage_addNoVerifyPasteFolder(self.folder, 'folder1') folder1 = self.folder.folder1 # need to trigger subtransaction before copy/paste can work transaction.savepoint() cb = self.folder.manage_copyObjects(['foo']) folder1.manage_pasteObjects(cb) foo_copy = folder1.foo events = objectCopiedEventCatcher.getEvents() self.assertEquals(1, len(events)) self.assertEquals(foo_copy.getPhysicalPath(), events[0].object.getPhysicalPath()) events = objectAddedEventCatcher.getEvents() self.assertEquals(2, len(events)) self.assertEquals(foo_copy.getPhysicalPath(), events[1].object.getPhysicalPath())