37
37
self.addCleanup(repo.abort_write_group)
38
38
return repo.chk_bytes
40
def _get_map(self, a_dict, maximum_size=0, chk_bytes=None):
40
def _get_map(self, a_dict, maximum_size=0, chk_bytes=None, key_width=1):
41
41
if chk_bytes is None:
42
42
chk_bytes = self.get_chk_bytes()
43
root_key = CHKMap.from_dict(chk_bytes, a_dict, maximum_size=maximum_size)
43
root_key = CHKMap.from_dict(chk_bytes, a_dict,
44
maximum_size=maximum_size, key_width=key_width)
44
45
chkmap = CHKMap(chk_bytes, root_key)
251
252
self.assertEqual({("a",): "content here"},
252
253
self.to_dict(chkmap, [("a",)]))
255
def test_iteritems_keys_prefixed_by_2_width_nodes(self):
256
chkmap = self._get_map(
257
{("a","a"):"content here", ("a", "b",):"more content",
258
("b", ""): 'boring content'},
259
maximum_size=10, key_width=2)
261
{("a", "a"): "content here", ("a", "b"): 'more content'},
262
self.to_dict(chkmap, [("a",)]))
264
def test_iteritems_keys_prefixed_by_2_width_one_leaf(self):
265
chkmap = self._get_map(
266
{("a","a"):"content here", ("a", "b",):"more content",
267
("b", ""): 'boring content'}, key_width=2)
269
{("a", "a"): "content here", ("a", "b"): 'more content'},
270
self.to_dict(chkmap, [("a",)]))
254
272
def test___len__empty(self):
255
273
chkmap = self._get_map({})
256
274
self.assertEqual(0, len(chkmap))