def testIOBTree(self): portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ('Manager',)) doc = self._makeOne() from collective.btrees.interfaces import IIOBTreeContainer container = IIOBTreeContainer(doc) self.assertEqual(len(container.keys()), 0) key = 1 value = object() self.assertEqual(container.get(key), None) container.insert(key, value) self.assertEqual(container.get(key), value) self.assertEqual(list(container.items()), [(key, value)]) container.clear() self.assertEqual(list(container.keys()), [])
def testMinimumMaximum(self): portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ('Manager',)) from collective.btrees.interfaces import IIOBTreeContainer doc = self._makeOne() container = IIOBTreeContainer(doc) self.assertEqual(len(container.keys()), 0) container.insert(1, 'one') container.insert(2, 'two') container.insert(3, 'three') container.insert(4, 'four') container.insert(5, 'five') self.assertEqual(container.get(1), 'one') self.assertEqual(len(container.items()), 5) self.assertEqual(len(container.keys()), 5) self.assertEqual(len(container.values()), 5) self.assertEqual(list(container.keys(min=4)), [4, 5]) self.assertEqual(list(container.keys(max=2)), [1, 2]) self.assertEqual(list(container.keys(min=2, max=4)), [2, 3, 4])