def test_baselineNoCopyReferences(self):
        # ensure that custom state is maintained with the no copy adapter

        # setup the named ref adapter
        from zope import component
        from Products.Archetypes.interfaces import IBaseObject
        from plone.app.iterate import relation, interfaces
        from plone.app.iterate.tests.utils import CustomReference

        component.provideAdapter(
            adapts=(IBaseObject,),
            provides=interfaces.ICheckinCheckoutReference,
            factory=relation.NoCopyReferenceAdapter,
            name="zebra")

        doc = self.portal.docs.doc1
        ref = doc.addReference(
            self.portal.docs, "zebra", referenceClass=CustomReference)
        ref.custom_state = "hello world"

        wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)

        self.assertEqual(len(wc.getReferences("zebra")), 0)

        doc = ICheckinCheckoutPolicy(wc).checkin("updated")

        self.assertEqual(len(doc.getReferences("zebra")), 1)

        ref = doc.getReferenceImpl("zebra")[0]

        self.assert_(hasattr(ref, "custom_state"))
        self.assertEqual(ref.custom_state, "hello world")
    def test_baselineNoCopyReferences(self):
        # ensure that custom state is maintained with the no copy adapter

        # setup the named ref adapter
        from zope import component
        from Products.Archetypes.interfaces import IBaseObject
        from plone.app.iterate import relation, interfaces
        from plone.app.iterate.tests.utils import CustomReference

        component.provideAdapter(adapts=(IBaseObject, ),
                                 provides=interfaces.ICheckinCheckoutReference,
                                 factory=relation.NoCopyReferenceAdapter,
                                 name="zebra")

        doc = self.portal.docs.doc1
        ref = doc.addReference(self.portal.docs,
                               "zebra",
                               referenceClass=CustomReference)
        ref.custom_state = "hello world"

        wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)

        self.assertEqual(len(wc.getReferences("zebra")), 0)

        doc = ICheckinCheckoutPolicy(wc).checkin("updated")

        self.assertEqual(len(doc.getReferences("zebra")), 1)

        ref = doc.getReferenceImpl("zebra")[0]

        self.assert_(hasattr(ref, "custom_state"))
        self.assertEqual(ref.custom_state, "hello world")
Exemple #3
0
 def test_wcNewForwardReferencesCopied( self ):
     # ensure that new wc references are copied back to the baseline on checkin
     doc = self.portal.docs.doc1
     doc.addReference( self.portal.docs )
     self.assertEqual( len(doc.getReferences("zebra")), 0)
     wc = ICheckinCheckoutPolicy( doc ).checkout( self.portal.workarea )
     wc.addReference( self.portal.docs.doc2, "zebra")
     doc = ICheckinCheckoutPolicy( wc ).checkin( "updated" )
     self.assertEqual( len(doc.getReferences("zebra")), 1 )
Exemple #4
0
    def test_baselineBrokenReferencesRemoved(self):
        # When the baseline has a reference to a deleted object, a
        # checkout should not fail with a ReferenceException.

        doc = self.portal.docs.doc1
        doc.addReference(self.portal.docs.doc2, 'pony')
        self.portal.docs._delOb('doc2')
        # _delOb is low level enough that the reference does not get cleaned
        # up.
        self.assertEqual(len(doc.getReferences()), 1)

        wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)
        # The working copy has one reference: its original.
        self.assertEqual(len(wc.getReferences()), 1)
        self.assertEqual(wc.getReferences()[0].id, 'doc1')

        doc = ICheckinCheckoutPolicy(wc).checkin('updated')
        # The checkin removes the broken reference.
        self.assertEqual(len(doc.getReferences()), 0)
Exemple #5
0
    def test_baselineBrokenReferencesRemoved(self):
        # When the baseline has a reference to a deleted object, a
        # checkout should not fail with a ReferenceException.

        doc = self.portal.docs.doc1
        doc.addReference(self.portal.docs.doc2, 'pony')
        self.portal.docs._delOb('doc2')
        # _delOb is low level enough that the reference does not get cleaned
        # up.
        self.assertEqual(len(doc.getReferences()), 1)

        wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)
        # The working copy has one reference: its original.
        self.assertEqual(len(wc.getReferences()), 1)
        self.assertEqual(wc.getReferences()[0].id, 'doc1')

        doc = ICheckinCheckoutPolicy(wc).checkin('updated')
        # The checkin removes the broken reference.
        self.assertEqual(len(doc.getReferences()), 0)
    def test_baselineReferencesMaintained(self):
        # ensure that baseline references are maintained when the object is
        # checked in copies forward, bkw are not copied, but are maintained.

        doc = self.portal.docs.doc1
        doc.addReference(self.portal.docs, "elephant")
        self.portal.docs.doc2.addReference(doc)

        wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)

        doc = ICheckinCheckoutPolicy(wc).checkin("updated")

        # TODO: This fails in Plone 4.1. The new optimized catalog lookups
        # in the reference catalog no longer filter out non-existing reference
        # objects. In both Plone 4.0 and 4.1 there's two references, one of
        # them is a stale catalog entry in the reference catalog. The real fix
        # is to figure out how the stale catalog entry gets in there
        self.assertEqual(len(doc.getReferences()), 1)
        self.assertEqual(len(doc.getBackReferences()), 1)
    def test_baselineReferencesMaintained(self):
        # ensure that baseline references are maintained when the object is
        # checked in copies forward, bkw are not copied, but are maintained.

        doc = self.portal.docs.doc1
        doc.addReference(self.portal.docs, "elephant")
        self.portal.docs.doc2.addReference(doc)

        wc = ICheckinCheckoutPolicy(doc).checkout(self.portal.workarea)

        doc = ICheckinCheckoutPolicy(wc).checkin("updated")

        # TODO: This fails in Plone 4.1. The new optimized catalog lookups
        # in the reference catalog no longer filter out non-existing reference
        # objects. In both Plone 4.0 and 4.1 there's two references, one of
        # them is a stale catalog entry in the reference catalog. The real fix
        # is to figure out how the stale catalog entry gets in there
        self.assertEqual(len(doc.getReferences()), 1)
        self.assertEqual(len(doc.getBackReferences()), 1)