コード例 #1
0
    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())
コード例 #2
0
    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())
コード例 #3
0
    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())
コード例 #4
0
    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())
コード例 #5
0
    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())
コード例 #6
0
    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())
コード例 #7
0
    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())
コード例 #8
0
    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()))
コード例 #9
0
    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()))
コード例 #10
0
    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')
コード例 #11
0
    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())
コード例 #12
0
    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())
コード例 #13
0
    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')
コード例 #14
0
    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")
コード例 #15
0
    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())
コード例 #16
0
    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())
コード例 #17
0
    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())
コード例 #18
0
    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)
コード例 #19
0
 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))