def test_retrieve_full_index(self): rt = radix_tree.RadixTree(2) rt.set((1, 2), 'a') rt.set((1, 2), 'b') self.assertItemsEqual({'a', 'b'}, rt.get_all((1, 2))) rt.set((2, 2), 'c') self.assertItemsEqual({'a', 'b'}, rt.get_all((1, 2)))
def __init__(self, index): self._index = index self._tree = radix_tree.RadixTree(len(index)) # We save ID->keys mapping for updating (object might have changed) # and deletion (object might contain just the ID) self._keys = collections.defaultdict(set)
def test_retrieve_partial_index2(self): rt = radix_tree.RadixTree(4) rt.set((1, 1, 1, 2), 'a') rt.set((1, 2, 3, 2), 'b') rt.set((1, 2, None, 2), 'c') rt.set((2, 2, None, 2), 'd') self.assertItemsEqual({'a', 'b', 'c'}, rt.get_all((1, ANY, ANY, 2)))
def test_delete(self): rt = radix_tree.RadixTree(2) rt.set((1, 2), 'a') rt.set((1, 2), 'b') rt.delete((1, 2), 'a') self.assertItemsEqual({'b'}, rt.get_all((1, 2)))
def test_retrieve_full_index_with_none(self): rt = radix_tree.RadixTree(2) rt.set((None, 2), 'a') rt.set((None, 1), 'b') self.assertItemsEqual({'a'}, rt.get_all((None, 2)))
def test_store(self): rt = radix_tree.RadixTree(2) rt.set((1, 2), object())
def test_create(self): for i in range(10): radix_tree.RadixTree(i)