Esempio n. 1
0
 def test_getitem(self):
     ordering = IOrdering(self.create())
     self.assertEquals(ordering[1], 'o2')
     self.assertEquals(ordering[-1], 'o4')
     self.assertEquals(ordering[1:2], ['o2'])
     self.assertEquals(ordering[1:-1], ['o2', 'o3'])
     self.assertEquals(ordering[1:], ['o2', 'o3', 'o4'])
Esempio n. 2
0
 def fix_folderish_types(self):
     log = self.mklog()
     catalog = api.portal.get_tool("portal_catalog")
     ordering_nb = btree_nb = 0
     for brain in catalog():
         obj = brain.getObject()
         is_container = isinstance(obj, BTreeFolder2Base)
         if not is_container:
             continue
         if not IOrdering.providedBy(obj):
             alsoProvides(obj, IOrdering)
             obj.reindexObject(["object_provides"])
             ordering_nb += 1
         if obj._tree is None:
             BTreeFolder2Base._initBTrees(obj)
             btree_nb += 1
     log("{0} objects IOrdering interface have been fixed.".format(
         ordering_nb))
     log("{0} objects tree have been fixed.".format(btree_nb))
Esempio n. 3
0
 def testMigrationViewWithSubobjects(self):
     # set up an (unmigrated) folder with subobjects
     folder = create('Folder', self.portal, 'test', title='Foo')
     create('Document', folder, 'doc1')
     create('Event', folder, 'event1')
     reverseMigrate(folder)
     folder = self.portal.test  # get the object again...
     self.failIf(isSaneBTreeFolder(folder))
     # now test its migration...
     view, headers, output, request = getView(self.portal, 'migrate-btrees')
     view()  # call the view, triggering the migration
     num = self.getNumber(output)
     self.assertEqual(num, 1)
     folder = self.portal.test  # get the object again...
     self.failUnless(isSaneBTreeFolder(folder))
     self.assertEqual(folder.getId(), 'test')
     self.assertEqual(folder.Title(), 'Foo')
     self.assertEqual(len(folder.objectValues()), 2)
     self.assertEqual(set(folder.objectIds()), set(['doc1', 'event1']))
     self.assertEqual(IOrdering(folder).idsInOrder(), ['doc1', 'event1'])