def testExecuteWithError(self): e = MoveAction() e.target_folder = '/dummy' ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEqual(False, ex()) self.assertTrue('d1' in self.folder.objectIds()) self.assertFalse('d1' in self.portal.target.objectIds())
def testExecuteWithError(self): e = MoveAction() e.target_folder = "/dummy" ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEquals(False, ex()) self.failUnless("d1" in self.folder.objectIds()) self.failIf("d1" in self.portal.target.objectIds())
def testExecute(self): e = MoveAction() e.target_folder = '/target' ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEquals(True, ex()) self.failIf('d1' in self.folder.objectIds()) self.failUnless('d1' in self.portal.target.objectIds())
def testExecuteWithoutPermissionsOnTarget(self): self.setRoles(('Member', )) e = MoveAction() e.target_folder = '/target' ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEqual(True, ex()) self.assertFalse('d1' in self.folder.objectIds()) self.assertTrue('d1' in self.portal.target.objectIds())
def testExecuteWithoutPermissionsOnTarget(self): self.setRoles(("Member",)) e = MoveAction() e.target_folder = "/target" ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEquals(True, ex()) self.failIf("d1" in self.folder.objectIds()) self.failUnless("d1" in self.portal.target.objectIds())
def testExecuteWithSameSourceAndTargetFolder(self): self.setRoles(("Manager",)) self.portal.target.invokeFactory("Document", "d1") self.setRoles(("Member",)) e = MoveAction() e.target_folder = "/target" ex = getMultiAdapter((self.portal.target, e, DummyEvent(self.portal.target.d1)), IExecutable) self.assertEquals(True, ex()) self.assertEquals(["d1"], list(self.portal.target.objectIds()))
def testExecuteWithSameSourceAndTargetFolder(self): self.setRoles(('Manager', )) self.portal.target.invokeFactory('Document', 'd1') self.setRoles(('Member', )) e = MoveAction() e.target_folder = '/target' ex = getMultiAdapter((self.portal.target, e, DummyEvent(self.portal.target.d1)), IExecutable) self.assertEqual(True, ex()) self.assertEqual(['d1'], list(self.portal.target.objectIds()))
def testExecute(self): e = MoveAction() e.target_folder = '/target' ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEqual(True, ex()) self.assertFalse('d1' in self.folder.objectIds()) self.assertTrue('d1' in self.portal.target.objectIds()) # test catalog is ok brains = self.portal.portal_catalog(id='d1') self.assertEqual(len(brains), 1) self.assertEqual(brains[0].getPath(), '/plone/target/d1')
def testExecuteWithNamingConflict(self): self.setRoles(('Manager', )) self.portal.target.invokeFactory('Document', 'd1') self.setRoles(('Member', )) e = MoveAction() e.target_folder = '/target' ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEqual(True, ex()) self.assertFalse('d1' in self.folder.objectIds()) self.assertTrue('d1' in self.portal.target.objectIds()) self.assertTrue('d1.1' in self.portal.target.objectIds())
def testExecuteWithNamingConflict(self): self.setRoles(("Manager",)) self.portal.target.invokeFactory("Document", "d1") self.setRoles(("Member",)) e = MoveAction() e.target_folder = "/target" ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEquals(True, ex()) self.failIf("d1" in self.folder.objectIds()) self.failUnless("d1" in self.portal.target.objectIds()) self.failUnless("d1.1" in self.portal.target.objectIds())
def testExecute(self): e = MoveAction() e.target_folder = "/target" ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEquals(True, ex()) self.failIf("d1" in self.folder.objectIds()) self.failUnless("d1" in self.portal.target.objectIds()) # test catalog is ok brains = self.portal.portal_catalog(id="d1") self.assertEquals(len(brains), 1) self.assertEquals(brains[0].getPath(), "/plone/target/d1")
def testExecuteWithNamingConflictDoesNotStupidlyAcquireHasKey(self): # self.folder is an ATBTreeFolder and so has a has_key. self.folder.target # does not. Let's make sure we don't accidentally acquire has_key and use # this for the check for unique id. self.folder.invokeFactory('Folder', 'target') self.folder.target.invokeFactory('Document', 'd1') e = MoveAction() e.target_folder = '/Members/%s/target' % default_user ex = getMultiAdapter((self.folder.target, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEqual(True, ex()) self.assertFalse('d1' in self.folder.objectIds()) self.assertTrue('d1' in self.folder.target.objectIds()) self.assertTrue('d1.1' in self.folder.target.objectIds())
def test_moved_content(self): """ content moved by content rules should remove the original catalog entry """ target = api.content.create(container=self.portal, type='Folder', id='target') source = api.content.create(container=self.portal, type='Folder', id='source') e = MoveAction() e.target_folder = '/target' obj = api.content.create(container=source, type='Document', id='doc') ex = getMultiAdapter((target, e, DummyEvent(obj)), IExecutable) self.assertEqual(True, ex()) catalog = api.portal.get_tool('portal_catalog') self.assertEqual( len(catalog(portal_type='Document', path='/plone/source')), 0) self.assertEqual( len(catalog(portal_type='Document', path='/plone/target')), 1)
def testInvokeEditView(self): element = getUtility(IRuleAction, name='plone.actions.Move') e = MoveAction() editview = getMultiAdapter((e, self.folder.REQUEST), name=element.editview) self.assertTrue(isinstance(editview, MoveEditForm))