~jelmer/bzr-git/index-based

« back to all changes in this revision

Viewing changes to tests/test_object_store.py

  • Committer: Jelmer Vernooij
  • Date: 2010-06-23 19:07:06 UTC
  • mfrom: (677.7.182 trunk)
  • Revision ID: jelmer@samba.org-20100623190706-t2mqoj2o304ni80f
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    Blob,
21
21
    )
22
22
 
 
23
from bzrlib.graph import (
 
24
    DictParentsProvider,
 
25
    )
23
26
from bzrlib.tests import (
24
27
    TestCase,
25
28
    )
26
29
 
27
30
from bzrlib.plugins.git.object_store import (
28
31
    _check_expected_sha,
 
32
    _find_missing_bzr_revids,
29
33
    )
30
34
 
31
35
 
48
52
        _check_expected_sha(self.obj.sha().digest(), self.obj)
49
53
        self.assertRaises(AssertionError, _check_expected_sha, 
50
54
            "x" * 20, self.obj)
 
55
 
 
56
 
 
57
class FindMissingBzrRevidsTests(TestCase):
 
58
 
 
59
    def _find_missing(self, ancestry, want, have):
 
60
        return _find_missing_bzr_revids(
 
61
            DictParentsProvider(ancestry).get_parent_map,
 
62
            set(want), set(have))
 
63
 
 
64
    def test_simple(self):
 
65
        self.assertEquals(set(), self._find_missing({}, [], []))
 
66
 
 
67
    def test_up_to_date(self):
 
68
        self.assertEquals(set(),
 
69
                self._find_missing({"a": ["b"]}, ["a"], ["a"]))
 
70
 
 
71
    def test_one_missing(self):
 
72
        self.assertEquals(set(["a"]),
 
73
                self._find_missing({"a": ["b"]}, ["a"], ["b"]))
 
74
 
 
75
    def test_two_missing(self):
 
76
        self.assertEquals(set(["a", "b"]),
 
77
                self._find_missing({"a": ["b"], "b": ["c"]}, ["a"], ["c"]))
 
78
 
 
79
    def test_two_missing_history(self):
 
80
        self.assertEquals(set(["a", "b"]),
 
81
                self._find_missing({"a": ["b"], "b": ["c"], "c": ["d"]},
 
82
                    ["a"], ["c"]))