/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_shamap.py

Make remote repository access a bit lazier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009 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 GitShaMap."""
 
18
 
 
19
from bzrlib.tests import TestCase
 
20
 
 
21
from bzrlib.plugins.git.shamap import (
 
22
    DictGitShaMap,
 
23
    SqliteGitShaMap,
 
24
    )
 
25
 
 
26
class TestGitShaMap:
 
27
 
 
28
    def test_commit(self):
 
29
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
 
30
            "commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"))
 
31
        self.assertEquals(
 
32
            ("commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba")),
 
33
            self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
 
34
 
 
35
    def test_lookup_notfound(self):
 
36
        self.assertRaises(KeyError, 
 
37
            self.map.lookup_git_sha, "5686645d49063c73d35436192dfc9a160c672301")
 
38
        
 
39
    def test_blob(self):
 
40
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
 
41
            "blob", ("myfileid", "myrevid"))
 
42
        self.assertEquals(
 
43
            ("blob", ("myfileid", "myrevid")),
 
44
            self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
 
45
 
 
46
    def test_tree(self):
 
47
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
 
48
            "tree", ("somepath", "myrevid"))
 
49
        self.assertEquals(
 
50
            ("tree", ("somepath", "myrevid")),
 
51
            self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
 
52
 
 
53
    def test_revids(self):
 
54
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
 
55
            "commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"))
 
56
        self.assertEquals(["myrevid"], list(self.map.revids()))
 
57
 
 
58
 
 
59
class DictGitShaMapTests(TestCase,TestGitShaMap):
 
60
 
 
61
    def setUp(self):
 
62
        TestCase.setUp(self)
 
63
        self.map = DictGitShaMap()
 
64
 
 
65
 
 
66
class SqliteGitShaMapTests(TestCase,TestGitShaMap):
 
67
 
 
68
    def setUp(self):
 
69
        TestCase.setUp(self)
 
70
        self.map = SqliteGitShaMap()
 
71