def testActionSummary(self):
     e = GroupByDateAction()
     e.base_folder = "/target"
     e.container = "Folder"
     e.roles = set(["Reader"])
     summary = u"Move the item under ${base_folder} using ${structure} " u"structure"
     self.assertEqual(summary, e.summary)
    def testPlacefulWorflow(self):
        ''' validates if our folder structure is created with placeful workflow
            in it
        '''
        wt = self.portal.portal_workflow
        wPID = WorkflowPolicyConfig_id
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.structure = '%Y/%m/%d'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/2009/04/22' %
                                                          e.base_folder[1:])
        self.failUnless('d1' in target_folder.objectIds())

        # @ folder 22
        self.failUnless(wPID in target_folder.objectIds())
        # @ folder 04
        self.failUnless(wPID in target_folder.aq_parent.objectIds())
        # @ folder 2009
        self.failUnless(wPID in target_folder.aq_parent.aq_parent.objectIds())
        review_state = wt.getInfoFor(target_folder, 'review_state')
        self.failUnless(review_state == 'visible')
예제 #3
0
    def testExecuteWithNamingConflict(self):
        setRoles(self.portal, TEST_USER_ID, [
            'Manager',
        ])
        target_folder_path = '2009/04/22'.split('/')

        target_folder = self.portal.target
        for folder in target_folder_path:
            if not folder in target_folder.objectIds():
                target_folder.invokeFactory('Folder', folder)
            target_folder = target_folder[folder]
        target_folder.invokeFactory('Document', 'd1')

        setRoles(self.portal, TEST_USER_ID, [
            'Member',
        ])

        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        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 target_folder.objectIds())
        self.failUnless('d1.1' in target_folder.objectIds())
예제 #4
0
    def testFolderNotifyAddedEvent(self):
        from zope.component import adapter
        from zope.component import provideHandler
        from zope.lifecycleevent import ObjectAddedEvent

        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        class Handler(object):
            def __init__(self):
                self.invocations = []
                self.counter = 0

            @adapter(ObjectAddedEvent)
            def handler(self, event):
                obj = event.object
                self.counter += 1
                if not obj in self.invocations:
                    self.invocations.append(obj)

        self.handler = Handler()
        provideHandler(self.handler.handler)

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())
        invocations = self.handler.invocations
        self.assertEquals(len(invocations), 3)
        self.assertEquals(self.handler.counter, 3)
        self.assertEquals(invocations[0].getId(), '2009')
        self.assertEquals(invocations[1].getId(), '04')
        self.assertEquals(invocations[2].getId(), '22')
    def testFolderNotifyAddedEvent(self):
        from zope.component import adapter
        from zope.component import provideHandler
        from zope.lifecycleevent import ObjectAddedEvent

        e = GroupByDateAction()
        e.base_folder = "/target"
        e.container = "Folder"

        class Handler(object):
            def __init__(self):
                self.invocations = []
                self.counter = 0

            @adapter(ObjectAddedEvent)
            def handler(self, event):
                obj = event.object
                self.counter += 1
                if obj not in self.invocations:
                    self.invocations.append(obj)

        self.handler = Handler()
        provideHandler(self.handler.handler)

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable)
        self.assertTrue(ex())
        invocations = self.handler.invocations
        self.assertEqual(len(invocations), 3)
        self.assertEqual(self.handler.counter, 3)
        self.assertEqual(invocations[0].getId(), "2009")
        self.assertEqual(invocations[1].getId(), "04")
        self.assertEqual(invocations[2].getId(), "22")
예제 #6
0
 def testActionSummary(self):
     e = GroupByDateAction()
     e.base_folder = '/target'
     e.container = 'Folder'
     e.roles = set([
         'Reader',
     ])
     summary = (u"Move the item under ${base_folder} using ${structure} "
                u"structure")
     self.assertEquals(summary, e.summary)
    def testExecuteWithError(self):
        e = GroupByDateAction()
        e.base_folder = "/dummy"
        e.container = "Folder"

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable)
        self.assertFalse(ex())

        self.assertIn("d1", self.folder.objectIds())
        self.assertNotIn("d1", self.portal.target.objectIds())
    def testExecuteWithError(self):
        e = GroupByDateAction()
        e.base_folder = '/dummy'
        e.container = 'Folder'

        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())
예제 #9
0
    def testExecuteWithError(self):
        e = GroupByDateAction()
        e.base_folder = '/dummy'
        e.container = 'Folder'

        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 = GroupByDateAction()
        e.base_folder = "/target"
        e.container = "Folder"

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable)
        self.assertTrue(ex())

        self.assertNotIn("d1", self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse("%s/2009/04/22" % e.base_folder[1:])
        self.assertIn("d1", target_folder.objectIds())
    def testExecuteWithNonExistantRelativePath(self):
        """ Execute the action with a non existent relative path
        """
        e = GroupByDateAction()
        # An non existant folder
        e.base_folder = "../relativeTarget"
        e.container = "Folder"

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable)
        self.assertFalse(ex())

        self.assertIn("d1", self.folder.objectIds())
    def testExecute(self):
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/2009/04/22' %
                                                          e.base_folder[1:])
        self.failUnless('d1' in target_folder.objectIds())
    def testExecuteWithoutPermissionsOnTarget(self):
        setRoles(self.portal, TEST_USER_ID, ["Member"])

        e = GroupByDateAction()
        e.base_folder = "/target"
        e.container = "Folder"

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable)
        self.assertEqual(True, ex())

        self.assertNotIn("d1", self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse("%s/2009/04/22" % e.base_folder[1:])
        self.assertIn("d1", target_folder.objectIds())
    def testExecuteWithNonExistantRelativePath(self):
        ''' Execute the action with a non existent relative path
        '''
        e = GroupByDateAction()
        # An non existant folder
        e.base_folder = '../relativeTarget'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(False, ex())

        self.failUnless('d1' in self.folder.objectIds())
예제 #15
0
    def testExecuteWithNonExistantRelativePath(self):
        ''' Execute the action with a non existent relative path
        '''
        e = GroupByDateAction()
        # An non existant folder
        e.base_folder = '../relativeTarget'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(False, ex())

        self.failUnless('d1' in self.folder.objectIds())
예제 #16
0
    def testExecuteDifferentContainer(self):
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Topic'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/2009/04/22' %
                                                         e.base_folder[1:])
        self.assertTrue(isinstance(target_folder, ATTopic))
    def testExecuteWithoutBaseFolder(self):
        """ Execute the action without a path
        """
        e = GroupByDateAction()
        # A sibling folder named relativeTarget
        e.base_folder = ""
        e.container = "Folder"

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable)
        self.assertTrue(ex())

        self.assertNotIn("d1", self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse("2009/04/22")
        self.assertIn("d1", target_folder.objectIds())
    def testWrongStrftimeFmt(self):
        """ Execute the action using a typoed strftime formatting string
        """
        e = GroupByDateAction()
        e.base_folder = "/target"
        e.structure = "Y/%m"
        e.container = "Folder"

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable)
        self.assertTrue(ex())

        self.assertNotIn("d1", self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse("%s/Y/04" % e.base_folder[1:])
        self.assertIn("d1", target_folder.objectIds())
예제 #19
0
    def testExecuteWithoutBaseFolder(self):
        ''' Execute the action without a path
        '''
        e = GroupByDateAction()
        # A sibling folder named relativeTarget
        e.base_folder = ''
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('2009/04/22')
        self.failUnless('d1' in target_folder.objectIds())
    def testExecuteWithoutPermissionsOnTarget(self):
        setRoles(self.portal, TEST_USER_ID, ['Member', ])

        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/2009/04/22' %
                                                          e.base_folder[1:])
        self.failUnless('d1' in target_folder.objectIds())
    def testExecutionOnCMFContent(self):
        """ Tests if the rules works with CMF Content
        """
        e = GroupByDateAction()
        e.base_folder = "/target"
        e.container = "Folder"

        o = self.folder["cmf"]

        ex = getMultiAdapter((self.folder, e, DummyEvent(o)), IExecutable)
        self.assertTrue(ex())

        self.assertNotIn("cmf", self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse("%s/2009/04/22" % e.base_folder[1:])
        self.assertIn("cmf", target_folder.objectIds())
    def testExecuteFromPloneSite(self):
        """ Execute the action with a non existent relative path
        """
        e = GroupByDateAction()
        self.portal.invokeFactory("Document", "d2")
        self.portal.d2.setEffectiveDate(DateTime("2009/04/22"))
        # An non existant folder
        e.base_folder = ".."
        e.container = "Folder"

        ex = getMultiAdapter((self.portal, e, DummyEvent(self.portal.d2)), IExecutable)
        self.assertTrue(ex())

        target_folder = self.portal.unrestrictedTraverse("2009/04/22")
        self.assertIn("d2", target_folder.objectIds())
    def testExecuteWithRelativePath(self):
        ''' Execute the action with a valid relative path
        '''
        e = GroupByDateAction()
        # A sibling folder named relativeTarget
        e.base_folder = './relativeTarget'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        relativeTarget = self.folder.relativeTarget
        target_folder = relativeTarget.unrestrictedTraverse('2009/04/22')
        self.failUnless('d1' in target_folder.objectIds())
    def testWrongStrftimeFmt(self):
        ''' Execute the action using a typoed strftime formatting string
        '''
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.structure = 'Y/%m'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/Y/04' %
                                                          e.base_folder[1:])
        self.failUnless('d1' in target_folder.objectIds())
예제 #25
0
    def testWrongStrftimeFmt(self):
        ''' Execute the action using a typoed strftime formatting string
        '''
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.structure = 'Y/%m'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/Y/04' %
                                                         e.base_folder[1:])
        self.failUnless('d1' in target_folder.objectIds())
예제 #26
0
    def testExecutionOnCMFContent(self):
        ''' Tests if the rules works with CMF Content
        '''
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        o = self.folder['cmf']

        ex = getMultiAdapter((self.folder, e, DummyEvent(o)), IExecutable)
        self.assertEquals(True, ex())

        self.failIf('cmf' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/2009/04/22' %
                                                         e.base_folder[1:])
        self.failUnless('cmf' in target_folder.objectIds())
예제 #27
0
 def testInvokeEditView(self):
     element = getUtility(IRuleAction,
                          name='sc.contentrules.actions.groupbydate')
     e = GroupByDateAction()
     editview = getMultiAdapter((e, self.folder.REQUEST),
                                name=element.editview)
     self.failUnless(isinstance(editview, GroupByDateEditForm))
예제 #28
0
    def testExecuteFromPloneSite(self):
        ''' Execute the action with a non existent relative path
        '''
        e = GroupByDateAction()
        self.portal.invokeFactory('Document', 'd2')
        self.portal.d2.setEffectiveDate(DateTime('2009/04/22'))
        # An non existant folder
        e.base_folder = '..'
        e.container = 'Folder'

        ex = getMultiAdapter((self.portal, e, DummyEvent(self.portal.d2)),
                             IExecutable)
        self.assertEquals(True, ex())

        target_folder = self.portal.unrestrictedTraverse('2009/04/22')
        self.failUnless('d2' in target_folder.objectIds())
예제 #29
0
    def testExecuteWithLongRelativePath(self):
        ''' Execute the action with a valid relative path
        '''
        folder = self.folder['relativeTarget']
        folder.invokeFactory('Document', 'd2')
        folder.d2.setEffectiveDate(DateTime('2009/04/22'))
        e = GroupByDateAction()
        # A sibling folder named relativeTarget
        e.base_folder = '../../'
        e.container = 'Folder'

        ex = getMultiAdapter((folder, e, DummyEvent(folder.d2)), IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d2' in folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('2009/04/22')
        self.failUnless('d2' in target_folder.objectIds())
예제 #30
0
    def testExecuteWithoutPermissionsOnTarget(self):
        setRoles(self.portal, TEST_USER_ID, [
            'Member',
        ])

        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/2009/04/22' %
                                                         e.base_folder[1:])
        self.failUnless('d1' in target_folder.objectIds())
    def testExecuteWithLongRelativePath(self):
        """ Execute the action with a valid relative path
        """
        folder = self.folder["relativeTarget"]
        folder.invokeFactory("Document", "d2")
        folder.d2.setEffectiveDate(DateTime("2009/04/22"))
        e = GroupByDateAction()
        # A sibling folder named relativeTarget
        e.base_folder = "../../"
        e.container = "Folder"

        ex = getMultiAdapter((folder, e, DummyEvent(folder.d2)), IExecutable)
        self.assertTrue(ex())

        self.assertNotIn("d2", folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse("2009/04/22")
        self.assertIn("d2", target_folder.objectIds())
예제 #32
0
    def testExecuteWithoutEffectiveDate(self):
        ''' Execute the action without an effective date
        '''
        folder = self.folder['relativeTarget']
        folder.invokeFactory('Document', 'd2')
        e = GroupByDateAction()
        # A sibling folder named relativeTarget
        e.base_folder = '../'
        e.container = 'Folder'

        ex = getMultiAdapter((folder, e, DummyEvent(folder.d2)), IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d2' in folder.objectIds())
        path = DateTime().strftime('%Y/%m/%d')
        target_folder = self.folder.unrestrictedTraverse(path)
        self.failUnless('d2' in target_folder.objectIds())
    def testExecutionOnCMFContent(self):
        ''' Tests if the rules works with CMF Content
        '''
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        o = self.folder['cmf']

        ex = getMultiAdapter((self.folder, e, DummyEvent(o)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('cmf' in self.folder.objectIds())
        target_folder = self.portal.unrestrictedTraverse('%s/2009/04/22' %
                                                          e.base_folder[1:])
        self.failUnless('cmf' in target_folder.objectIds())
    def testExecuteWithoutEffectiveDate(self):
        """ Execute the action without an effective date
        """
        folder = self.folder["relativeTarget"]
        folder.invokeFactory("Document", "d2")
        e = GroupByDateAction()
        # A sibling folder named relativeTarget
        e.base_folder = "../"
        e.container = "Folder"

        ex = getMultiAdapter((folder, e, DummyEvent(folder.d2)), IExecutable)
        self.assertTrue(ex())

        self.assertNotIn("d2", folder.objectIds())
        path = DateTime().strftime("%Y/%m/%d")
        target_folder = self.folder.unrestrictedTraverse(path)
        self.assertIn("d2", target_folder.objectIds())
    def testExecuteWithSameSourceAndTargetFolder(self):
        setRoles(self.portal, TEST_USER_ID, ["Manager"])
        target_folder_path = "2009/04/22".split("/")

        target_folder = self.portal.target
        for folder in target_folder_path:
            if folder not in target_folder.objectIds():
                target_folder.invokeFactory("Folder", folder)
            target_folder = target_folder[folder]

        target_folder.invokeFactory("Document", "d1")
        target_folder.d1.setEffectiveDate(DateTime("2009/04/22"))

        e = GroupByDateAction()
        e.base_folder = "/target"
        e.container = "Folder"

        ex = getMultiAdapter((target_folder, e, DummyEvent(target_folder.d1)), IExecutable)
        self.assertTrue(ex())

        self.assertEqual(["d1"], list(target_folder.objectIds()))
    def testExecuteWithSameSourceAndTargetFolder(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager', ])
        target_folder_path = '2009/04/22'.split('/')

        target_folder = self.portal.target
        for folder in target_folder_path:
            if not folder in target_folder.objectIds():
                target_folder.invokeFactory('Folder', folder)
            target_folder = target_folder[folder]

        target_folder.invokeFactory('Document', 'd1')
        target_folder.d1.setEffectiveDate(DateTime('2009/04/22'))

        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        ex = getMultiAdapter((target_folder, e, DummyEvent(target_folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.assertEquals(['d1'], list(target_folder.objectIds()))
    def testPlacefulWorflowPermissions(self):
        ''' validates permissions on folders created by our rule
        '''
        portal = self.portal
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.structure = '%Y/%m/%d'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.failIf('d1' in self.folder.objectIds())
        base_folder = portal.unrestrictedTraverse('%s' % e.base_folder[1:])

        # Permissions
        view_perm = 'View'
        access_perm = 'Access contents information'

        # year folder
        folder = base_folder['2009']
        self.assertEquals(folder.acquiredRolesAreUsedBy(view_perm),
                          'CHECKED')
        self.assertEquals(folder.acquiredRolesAreUsedBy(access_perm),
                          'CHECKED')
        # month folder
        folder = base_folder['2009']['04']
        self.assertEquals(folder.acquiredRolesAreUsedBy(view_perm),
                          'CHECKED')
        self.assertEquals(folder.acquiredRolesAreUsedBy(access_perm),
                          'CHECKED')
        # month folder
        folder = base_folder['2009']['04']['22']
        self.assertEquals(folder.acquiredRolesAreUsedBy(view_perm),
                          'CHECKED')
        self.assertEquals(folder.acquiredRolesAreUsedBy(access_perm),
                          'CHECKED')
    def testExcludeFolderFromNav(self):
        ''' Execute the action specifying some folders that should be
            excluded from navigation
        '''
        e = GroupByDateAction()
        e.base_folder = '/target'
        e.structure = '%Yee/%m/%dee'
        e.container = 'Folder'

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        foldera = self.portal.unrestrictedTraverse('%s/2009' %
                                                         e.base_folder[1:])
        folderb = self.portal.unrestrictedTraverse('%s/2009/04' %
                                                         e.base_folder[1:])
        folderc = self.portal.unrestrictedTraverse('%s/2009/04/22' %
                                                         e.base_folder[1:])

        self.assertTrue(foldera.exclude_from_nav())
        self.assertFalse(folderb.exclude_from_nav())
        self.assertTrue(folderc.exclude_from_nav())
    def testExecuteWithNamingConflict(self):
        setRoles(self.portal, TEST_USER_ID, ["Manager"])
        target_folder_path = "2009/04/22".split("/")

        target_folder = self.portal.target
        for folder in target_folder_path:
            if folder not in target_folder.objectIds():
                target_folder.invokeFactory("Folder", folder)
            target_folder = target_folder[folder]
        target_folder.invokeFactory("Document", "d1")

        setRoles(self.portal, TEST_USER_ID, ["Member"])

        e = GroupByDateAction()
        e.base_folder = "/target"
        e.container = "Folder"

        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)), IExecutable)
        self.assertTrue(ex())

        self.assertNotIn("d1", self.folder.objectIds())
        self.assertIn("d1", target_folder.objectIds())
        self.assertIn("d1.1", target_folder.objectIds())
예제 #40
0
    def testExecuteWithSameSourceAndTargetFolder(self):
        setRoles(self.portal, TEST_USER_ID, [
            'Manager',
        ])
        target_folder_path = '2009/04/22'.split('/')

        target_folder = self.portal.target
        for folder in target_folder_path:
            if not folder in target_folder.objectIds():
                target_folder.invokeFactory('Folder', folder)
            target_folder = target_folder[folder]

        target_folder.invokeFactory('Document', 'd1')
        target_folder.d1.setEffectiveDate(DateTime('2009/04/22'))

        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        ex = getMultiAdapter((target_folder, e, DummyEvent(target_folder.d1)),
                             IExecutable)
        self.assertEquals(True, ex())

        self.assertEquals(['d1'], list(target_folder.objectIds()))
    def testExecuteWithNamingConflict(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager', ])
        target_folder_path = '2009/04/22'.split('/')

        target_folder = self.portal.target
        for folder in target_folder_path:
            if not folder in target_folder.objectIds():
                target_folder.invokeFactory('Folder', folder)
            target_folder = target_folder[folder]
        target_folder.invokeFactory('Document', 'd1')

        setRoles(self.portal, TEST_USER_ID, ['Member', ])

        e = GroupByDateAction()
        e.base_folder = '/target'
        e.container = 'Folder'

        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 target_folder.objectIds())
        self.failUnless('d1.1' in target_folder.objectIds())