def testExecuteWithError(self): e = CopyAction() 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 testExecute(self): e = CopyAction() e.target_folder = '/target' ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEquals(True, ex()) self.failUnless('d1' in self.folder.objectIds()) self.failUnless('d1' in self.portal.target.objectIds())
def testExecuteWithoutPermissionsOnTarget(self): self.setRoles(('Member', )) e = CopyAction() e.target_folder = '/target' ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEqual(True, ex()) self.assertTrue('d1' in self.folder.objectIds()) self.assertTrue('d1' in self.portal.target.objectIds())
def testExecuteWithNamingConflict(self): self.setRoles(('Manager', )) self.portal.target.invokeFactory('Document', 'd1') self.setRoles(('Member', )) e = CopyAction() e.target_folder = '/target' ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEqual(True, ex()) self.assertTrue('d1' in self.folder.objectIds()) self.assertTrue('d1' in self.portal.target.objectIds()) self.assertTrue('d1.1' in self.portal.target.objectIds())
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 = CopyAction() e.target_folder = '/Members/%s/target' % TEST_USER_ID ex = getMultiAdapter( (self.folder.target, e, DummyEvent(self.folder.d1)), IExecutable) self.assertEqual(True, ex()) self.assertTrue('d1' in self.folder.objectIds()) self.assertTrue('d1' in self.folder.target.objectIds()) self.assertTrue('d1.1' in self.folder.target.objectIds())
def testInvokeEditView(self): element = getUtility(IRuleAction, name='plone.actions.Copy') e = CopyAction() editview = getMultiAdapter((e, self.folder.REQUEST), name=element.editview) self.assertTrue(isinstance(editview, CopyEditFormView))