/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.799 by Jelmer Vernooij
Add trivial object store tests.
1
# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Tests for bzr-git's object store."""
18
19
from dulwich.objects import (
20
    Blob,
21
    )
22
0.200.899 by Jelmer Vernooij
Add tests for find_missing_bzr_revids.
23
from bzrlib.graph import (
24
    DictParentsProvider,
25
    )
0.200.799 by Jelmer Vernooij
Add trivial object store tests.
26
from bzrlib.tests import (
27
    TestCase,
28
    )
29
30
from bzrlib.plugins.git.object_store import (
31
    _check_expected_sha,
0.200.899 by Jelmer Vernooij
Add tests for find_missing_bzr_revids.
32
    _find_missing_bzr_revids,
0.200.799 by Jelmer Vernooij
Add trivial object store tests.
33
    )
34
35
36
class ExpectedShaTests(TestCase):
37
38
    def setUp(self):
39
        super(ExpectedShaTests, self).setUp()
40
        self.obj = Blob()
41
        self.obj.data = "foo"
42
43
    def test_none(self):
44
        _check_expected_sha(None, self.obj)
45
46
    def test_hex(self):
47
        _check_expected_sha(self.obj.sha().hexdigest(), self.obj)
48
        self.assertRaises(AssertionError, _check_expected_sha, 
49
            "0" * 40, self.obj)
50
51
    def test_binary(self):
52
        _check_expected_sha(self.obj.sha().digest(), self.obj)
53
        self.assertRaises(AssertionError, _check_expected_sha, 
54
            "x" * 20, self.obj)
0.200.899 by Jelmer Vernooij
Add tests for find_missing_bzr_revids.
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"]))
0.200.905 by Jelmer Vernooij
More find missing revision tests.
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"]))