Exemple #1
0
    def available(self):
        """If ICheckedOut is provided by context then return empty list. 
        If ICheckedIn is provided and context is not the latest version 
        return empty list, else default."""
        if ICheckedOut.providedBy(self.context):
            return []

        if ICheckedIn.providedBy(self.context):
            vc = getToolByName(self.context, 'upfront_versioning_catalog')
            ob = vc.getLatestVersionOf(self.context)
            if ob != self.context:
                return []

        return BaseWorkflowSubMenuItem.available(self)
    def test_unversioned(self):
        """Item is not yet versioned. Make it so."""
        utility = getUtility(IVersioner)
        workspace = self.getWorkspace()

        version2 = utility.start_new_version(
            workspace['a-document-unversioned'])

        # Was version1 created?
        self.failUnless(
            '00000001' in version2.aq_parent.objectIds('ATDocument'))

        version1 = version2.aq_parent['00000001']

        # Version1 tests

        # Is there a VersionFolder with id a-document-unversioned in workspace?
        self.failUnless(
            'a-document-unversioned' in workspace.objectIds('VersionFolder'))

        # Is it a child of the VersionFolder?
        self.assertEquals(workspace['a-document-unversioned']['00000001'],
                          version1)

        # Is interface provided?
        self.failUnless(ICheckedIn.providedBy(version1))

        # Is interface not provided?
        self.failIf(ICheckedOut.providedBy(version1))

        # Check metadata
        adapted = IVersionMetadata(version1)
        self.assertEquals(adapted.token, version1.UID())
        self.assertEquals(adapted.state, 'checked_in')
        self.assertEquals(adapted.version, 1)

        # Is it in versioning catalog?
        vc = self.portal.upfront_versioning_catalog
        brains = vc(path='/'.join(version1.getPhysicalPath()),
                    token=version1.UID(),
                    state='checked_in')
        self.failUnless(brains)

        # Is it in portal catalog?
        pc = self.portal.portal_catalog
        brains = pc(path='/'.join(version1.getPhysicalPath()), )
        self.failUnless(brains)

        # Is it published?
        wf = self.portal.portal_workflow
        self.assertEquals(wf.getInfoFor(version1, 'review_state'), 'published')

        # Version2 tests

        # Is interface provided?
        self.failUnless(ICheckedOut.providedBy(version2))

        # Is interface not provided?
        self.failIf(ICheckedIn.providedBy(version2))

        # Check metadata
        adapted = IVersionMetadata(version2)
        self.assertEquals(adapted.token, version1.UID())
        self.assertEquals(adapted.state, 'checked_out')
        self.assertEquals(adapted.version, 2)

        # Is it in version catalog?
        vc = self.portal.upfront_versioning_catalog
        brains = vc(path='/'.join(version2.getPhysicalPath()),
                    token=version1.UID(),
                    state='checked_out')
        self.failUnless(brains)

        # Is it published?
        wf = self.portal.portal_workflow
        self.assertEquals(wf.getInfoFor(version2, 'review_state'), 'published')
    def test_unversioned(self):
        """Item is not yet versioned. Make it so."""
        utility = getUtility(IVersioner)
        workspace = self.getWorkspace()

        version2 = utility.start_new_version(workspace['a-document-unversioned'])

        # Was version1 created?
        self.failUnless('00000001' in version2.aq_parent.objectIds('ATDocument'))

        version1 = version2.aq_parent['00000001']

        # Version1 tests

        # Is there a VersionFolder with id a-document-unversioned in workspace?
        self.failUnless('a-document-unversioned' in workspace.objectIds('VersionFolder'))

        # Is it a child of the VersionFolder?
        self.assertEquals(workspace['a-document-unversioned']['00000001'], version1)

        # Is interface provided?
        self.failUnless(ICheckedIn.providedBy(version1))

        # Is interface not provided?
        self.failIf(ICheckedOut.providedBy(version1))
       
        # Check metadata
        adapted = IVersionMetadata(version1)
        self.assertEquals(adapted.token, version1.UID())
        self.assertEquals(adapted.state, 'checked_in')
        self.assertEquals(adapted.version, 1)

        # Is it in versioning catalog?
        vc = self.portal.upfront_versioning_catalog
        brains = vc(
            path='/'.join(version1.getPhysicalPath()), 
            token=version1.UID(),
            state='checked_in'
        )
        self.failUnless(brains)      

        # Is it in portal catalog?
        pc = self.portal.portal_catalog
        brains = pc(
            path='/'.join(version1.getPhysicalPath()), 
        )
        self.failUnless(brains)      

        # Is it published?
        wf = self.portal.portal_workflow
        self.assertEquals(wf.getInfoFor(version1, 'review_state'), 'published')

        # Version2 tests

        # Is interface provided?
        self.failUnless(ICheckedOut.providedBy(version2))

        # Is interface not provided?
        self.failIf(ICheckedIn.providedBy(version2))
       
        # Check metadata
        adapted = IVersionMetadata(version2)
        self.assertEquals(adapted.token, version1.UID())
        self.assertEquals(adapted.state, 'checked_out')
        self.assertEquals(adapted.version, 2)

        # Is it in version catalog?
        vc = self.portal.upfront_versioning_catalog
        brains = vc(
            path='/'.join(version2.getPhysicalPath()), 
            token=version1.UID(),
            state='checked_out'
        )
        self.failUnless(brains)      

        # Is it published?
        wf = self.portal.portal_workflow
        self.assertEquals(wf.getInfoFor(version2, 'review_state'), 'published')