|
@@ -396,36 +396,38 @@ class TreeLookupPathTests(TestCase):
|
|
|
class ObjectStoreGraphWalkerTests(TestCase):
|
|
|
|
|
|
def get_walker(self, heads, parent_map):
|
|
|
- return ObjectStoreGraphWalker(heads,
|
|
|
- parent_map.__getitem__)
|
|
|
+ new_parent_map = dict([
|
|
|
+ (k * 40, [(p * 40) for p in ps]) for (k, ps) in parent_map.items()])
|
|
|
+ return ObjectStoreGraphWalker([x * 40 for x in heads],
|
|
|
+ new_parent_map.__getitem__)
|
|
|
|
|
|
def test_empty(self):
|
|
|
gw = self.get_walker([], {})
|
|
|
self.assertIs(None, next(gw))
|
|
|
- gw.ack("aa" * 20)
|
|
|
+ gw.ack("a" * 40)
|
|
|
self.assertIs(None, next(gw))
|
|
|
|
|
|
def test_descends(self):
|
|
|
gw = self.get_walker(["a"], {"a": ["b"], "b": []})
|
|
|
- self.assertEqual("a", next(gw))
|
|
|
- self.assertEqual("b", next(gw))
|
|
|
+ self.assertEqual("a" * 40, next(gw))
|
|
|
+ self.assertEqual("b" * 40, next(gw))
|
|
|
|
|
|
def test_present(self):
|
|
|
gw = self.get_walker(["a"], {"a": ["b"], "b": []})
|
|
|
- gw.ack("a")
|
|
|
+ gw.ack("a" * 40)
|
|
|
self.assertIs(None, next(gw))
|
|
|
|
|
|
def test_parent_present(self):
|
|
|
gw = self.get_walker(["a"], {"a": ["b"], "b": []})
|
|
|
- self.assertEqual("a", next(gw))
|
|
|
- gw.ack("a")
|
|
|
+ self.assertEqual("a" * 40, next(gw))
|
|
|
+ gw.ack("a" * 40)
|
|
|
self.assertIs(None, next(gw))
|
|
|
|
|
|
def test_child_ack_later(self):
|
|
|
gw = self.get_walker(["a"], {"a": ["b"], "b": ["c"], "c": []})
|
|
|
- self.assertEqual("a", next(gw))
|
|
|
- self.assertEqual("b", next(gw))
|
|
|
- gw.ack("a")
|
|
|
+ self.assertEqual("a" * 40, next(gw))
|
|
|
+ self.assertEqual("b" * 40, next(gw))
|
|
|
+ gw.ack("a" * 40)
|
|
|
self.assertIs(None, next(gw))
|
|
|
|
|
|
def test_only_once(self):
|
|
@@ -447,18 +449,18 @@ class ObjectStoreGraphWalkerTests(TestCase):
|
|
|
walk.append(next(gw))
|
|
|
# A branch (a, c) or (b, d) may be done after 2 steps or 3 depending on
|
|
|
# the order walked: 3-step walks include (a, b, c) and (b, a, d), etc.
|
|
|
- if walk == ["a", "c"] or walk == ["b", "d"]:
|
|
|
+ if walk == ["a" * 40, "c" * 40] or walk == ["b" * 40, "d" * 40]:
|
|
|
gw.ack(walk[0])
|
|
|
acked = True
|
|
|
|
|
|
walk.append(next(gw))
|
|
|
- if not acked and walk[2] == "c":
|
|
|
- gw.ack("a")
|
|
|
- elif not acked and walk[2] == "d":
|
|
|
- gw.ack("b")
|
|
|
+ if not acked and walk[2] == "c" * 40:
|
|
|
+ gw.ack("a" * 40)
|
|
|
+ elif not acked and walk[2] == "d" * 40:
|
|
|
+ gw.ack("b" * 40)
|
|
|
walk.append(next(gw))
|
|
|
self.assertIs(None, next(gw))
|
|
|
|
|
|
- self.assertEqual(["a", "b", "c", "d"], sorted(walk))
|
|
|
- self.assertLess(walk.index("a"), walk.index("c"))
|
|
|
- self.assertLess(walk.index("b"), walk.index("d"))
|
|
|
+ self.assertEqual(["a" * 40, "b" * 40, "c" * 40, "d" * 40], sorted(walk))
|
|
|
+ self.assertLess(walk.index("a" * 40), walk.index("c" * 40))
|
|
|
+ self.assertLess(walk.index("b" * 40), walk.index("d" * 40))
|