示例#1
0
    def test_dict_round_trip(self):
        leaf = obnamlib.CowLeaf()
        leaf.insert('foo', 'bar')
        some_dict = leaf.as_dict()

        leaf2 = obnamlib.CowLeaf()
        leaf2.from_dict(some_dict)
        some_dict2 = leaf2.as_dict()

        self.assertNotEqual(id(some_dict), id(some_dict2))
        self.assertEqual(some_dict, some_dict2)
示例#2
0
 def test_inserting_adds_key(self):
     leaf = obnamlib.CowLeaf()
     leaf.insert('foo', 'bar')
     self.assertEqual(leaf.keys(), ['foo'])
示例#3
0
 def test_lookup_returns_inserted_value(self):
     key = 'fookey'
     value = 'barvalue'
     leaf = obnamlib.CowLeaf()
     leaf.insert(key, value)
     self.assertEqual(leaf.lookup(key), value)
示例#4
0
 def test_inserting_increases_length(self):
     leaf = obnamlib.CowLeaf()
     leaf.insert('foo', 'bar')
     self.assertEqual(len(leaf), 1)
示例#5
0
 def test_has_no_keys_initially(self):
     leaf = obnamlib.CowLeaf()
     self.assertEqual(leaf.keys(), [])
示例#6
0
 def test_lookup_returns_None_if_key_is_missing(self):
     leaf = obnamlib.CowLeaf()
     self.assertEqual(leaf.lookup(42), None)
示例#7
0
 def test_has_zero_length_initially(self):
     leaf = obnamlib.CowLeaf()
     self.assertEqual(len(leaf), 0)
示例#8
0
 def get_leaf(self, leaf_id):
     leaf = obnamlib.CowLeaf()
     leaf.from_dict(self._blob_store.get_blob(leaf_id))
     return leaf
示例#9
0
文件: cowtree.py 项目: nom3ad/obnam
 def commit(self):
     fake_leaf = obnamlib.CowLeaf()
     fake_leaf.insert('leaf_list', self._leaf_list.as_dict())
     list_id = self._store.put_leaf(fake_leaf)
     self._store.flush()
     return list_id
示例#10
0
文件: cowtree.py 项目: nom3ad/obnam
 def _make_split_leaf(self, leaf, sorted_keys):
     new = obnamlib.CowLeaf()
     for key in sorted_keys:
         new.insert(key, leaf.lookup(key))
     new_id = self._store.put_leaf(new)
     self._leaf_list.insert_leaf(sorted_keys[0], sorted_keys[-1], new_id)
示例#11
0
文件: cowtree.py 项目: nom3ad/obnam
 def _add_new_leaf(self, key, value):
     leaf = obnamlib.CowLeaf()
     leaf.insert(key, value)
     leaf_id = self._store.put_leaf(leaf)
     self._leaf_list.insert_leaf(key, key, leaf_id)