def testOOBTree(self):
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Manager',))
     doc = self._makeOne()
     from collective.btrees.interfaces import IOOBTreeContainer
     container = IOOBTreeContainer(doc)
     self.assertEqual(len(container.keys()), 0)
     key = object()
     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 testClear(self):
     portal = self.layer['portal']
     setRoles(portal, TEST_USER_ID, ('Manager',))
     doc = self._makeOne()
     from collective.btrees.interfaces import IOOBTreeContainer
     container = IOOBTreeContainer(doc)
     container.insert(object(), object())
     container.insert(object(), object())
     container.insert(object(), object())
     self.assertEqual(len(container.items()), 3)
     # Remove all.
     container.clear()
     self.assertEqual(len(container.items()), 0)
     self.assertEqual(len(container.keys()), 0)
     self.assertEqual(len(container.values()), 0)
     self.assertRaises(StopIteration, container.iteritems().next)
     self.assertRaises(StopIteration, container.iterkeys().next)
     self.assertRaises(StopIteration, container.itervalues().next)
     # Clearing an empty container should work too of course.
     container.clear()