예제 #1
0
    def test_folderContents(self):
        """When an folder is checked out, and item is added, and then
        the folder is checked back in, the added item is in the new
        version of the folder.  UIDs of contained content are also
        preserved."""
        container = self.portal.docs
        folder = container[container.invokeFactory(type_name='Folder',
                                                   id='foo-folder')]
        existing_doc = folder[folder.invokeFactory(type_name='Document',
                                                   id='existing-folder-item')]
        existing_doc_uid = existing_doc.UID()

        self.repo.save(folder)
        wc = ICheckinCheckoutPolicy(folder).checkout(container)
        new_doc = wc[wc.invokeFactory(type_name='Document',
                                      id='new-folder-item',
                                      text='new folder item text')]
        new_doc_uid = new_doc.UID()
        new_folder = ICheckinCheckoutPolicy(wc).checkin("updated")

        catalog = getToolByName(self.portal, 'portal_catalog')

        self.assertTrue('existing-folder-item' in new_folder)
        self.assertEqual(new_folder['existing-folder-item'].UID(),
                         existing_doc_uid)
        self.assertTrue('new-folder-item' in new_folder)
        self.assertEqual(new_folder['new-folder-item'].UID(), new_doc_uid)
        brains = catalog(
            path='/'.join(new_folder['new-folder-item'].getPhysicalPath()))
        self.assertTrue(brains)
        self.assertTrue(
            'new folder item text' in new_folder['new-folder-item'].getText())
예제 #2
0
    def test_folderContents(self):
        """When an folder is checked out, and item is added, and then
        the folder is checked back in, the added item is in the new
        version of the folder.  UIDs of contained content are also
        preserved."""
        container = self.portal.docs
        folder = container[container.invokeFactory(
            type_name='Folder', id='foo-folder')]
        existing_doc = folder[folder.invokeFactory(
            type_name='Document', id='existing-folder-item')]
        existing_doc_uid = existing_doc.UID()

        self.repo.save(folder)
        wc = ICheckinCheckoutPolicy(folder).checkout(container)
        new_doc = wc[wc.invokeFactory(type_name='Document',
                                      id='new-folder-item',
                                      text='new folder item text')]
        new_doc_uid = new_doc.UID()
        new_folder = ICheckinCheckoutPolicy(wc).checkin("updated")

        catalog = getToolByName(self.portal, 'portal_catalog')

        self.assertTrue('existing-folder-item' in new_folder)
        self.assertEqual(
            new_folder['existing-folder-item'].UID(), existing_doc_uid)
        self.assertTrue('new-folder-item' in new_folder)
        self.assertEqual(new_folder['new-folder-item'].UID(), new_doc_uid)
        brains = catalog(path='/'.join(
            new_folder['new-folder-item'].getPhysicalPath()))
        self.assertTrue(brains)
        self.assertTrue('new folder item text' in
                        new_folder['new-folder-item'].getText())
예제 #3
0
 def test_add_name_to_wc(self):
     self.setRoles(('Contributor', ))
     p1 = self.places['1']
     self.failUnless('foo' in p1, p1.keys())
     wc = ICheckinCheckoutPolicy(p1).checkout(self.places)
     nid = wc.invokeFactory('Name', 'bar', nameTransliterated=u"Bar")
     self.failUnless('bar' in wc, wc.keys())
     p1 = ICheckinCheckoutPolicy(wc).checkin("updated")
     self.failUnless('foo' in p1, p1.keys())
     self.failUnless('bar' in p1, p1.keys())
     # A child's history acquires its parent's history
     history = self.repo.getHistory(p1['foo'])
     self.failUnlessEqual(len(history), 2)
     history = self.repo.getHistory(p1['bar'])
     self.failUnlessEqual(len(history), 1)
예제 #4
0
 def test_add_name_to_wc(self):
     self.setRoles(('Contributor',))
     p1 = self.places['1']
     self.failUnless('foo' in p1, p1.keys())
     wc = ICheckinCheckoutPolicy(p1).checkout(self.places)
     nid = wc.invokeFactory('Name', 'bar', nameTransliterated=u"Bar")
     self.failUnless('bar' in wc, wc.keys())
     p1 = ICheckinCheckoutPolicy(wc).checkin("updated")
     self.failUnless('foo' in p1, p1.keys())
     self.failUnless('bar' in p1, p1.keys())
     # A child's history acquires its parent's history
     history = self.repo.getHistory(p1['foo'])
     self.failUnlessEqual(len(history), 2)
     history = self.repo.getHistory(p1['bar'])
     self.failUnlessEqual(len(history), 1)