def testGetNonExisting(self): portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ('Manager',)) doc = self._makeOne() from collective.btrees.interfaces import IOOBTreeContainer container = IOOBTreeContainer(doc) # Getting a non-existing item. self.assertEqual(container.get('foobar'), None) self.assertEqual(container.get('foobar', 'ni'), 'ni') self.assertEqual(container.pop('none'), None) self.assertEqual(container.pop('none', 'hi'), 'hi')
def testPopItem(self): portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ('Manager',)) doc = self._makeOne() from collective.btrees.interfaces import IOOBTreeContainer container = IOOBTreeContainer(doc) # Insert an item and pop it. key = object() value = object() container.insert(key, value) self.assertEqual(len(container.items()), 1) self.assertEqual(container.pop(key), value) self.assertEqual(len(container.items()), 0) self.assertEqual(container.pop(key), None)