/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

  • Committer: Robert Collins
  • Date: 2010-05-06 07:48:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506074822-0bsgf2j4h8jx0xkk
Added ``bzrlib.tests.matchers`` as a place to put matchers, along with
our first in-tree matcher. See the module docstring for details.
(Robert Collins)

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
 
import os
20
 
 
21
 
from bzrlib.tests import (
22
 
    TestCase,
23
 
    TestCaseInTempDir,
24
 
    UnavailableFeature,
25
 
    )
26
 
 
27
 
from bzrlib.plugins.git.shamap import (
28
 
    DictGitShaMap,
29
 
    SqliteGitShaMap,
30
 
    TdbGitShaMap,
31
 
    )
32
 
 
33
 
class TestGitShaMap:
34
 
 
35
 
    def test_commit(self):
36
 
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
37
 
            "commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"))
38
 
        self.assertEquals(
39
 
            ("commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba")),
40
 
            self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
41
 
 
42
 
    def test_lookup_notfound(self):
43
 
        self.assertRaises(KeyError, 
44
 
            self.map.lookup_git_sha, "5686645d49063c73d35436192dfc9a160c672301")
45
 
        
46
 
    def test_blob(self):
47
 
        thesha = "5686645d49063c73d35436192dfc9a160c672301"
48
 
        self.map.add_entry(thesha, "blob", ("myfileid", "myrevid"))
49
 
        self.assertEquals(
50
 
            ("blob", ("myfileid", "myrevid")),
51
 
            self.map.lookup_git_sha(thesha))
52
 
        self.assertEquals(thesha, self.map.lookup_blob("myfileid", "myrevid"))
53
 
 
54
 
    def test_tree(self):
55
 
        thesha = "5686645d49063c73d35436192dfc9a160c672301"
56
 
        self.map.add_entry(thesha, 
57
 
            "tree", ("somepath", "myrevid"))
58
 
        self.assertEquals(
59
 
            ("tree", ("somepath", "myrevid")),
60
 
            self.map.lookup_git_sha(thesha))
61
 
        self.assertEquals(thesha, self.map.lookup_tree("somepath", "myrevid"))
62
 
 
63
 
    def test_revids(self):
64
 
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
65
 
            "commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba"))
66
 
        self.assertEquals(["myrevid"], list(self.map.revids()))
67
 
 
68
 
 
69
 
class DictGitShaMapTests(TestCase,TestGitShaMap):
70
 
 
71
 
    def setUp(self):
72
 
        TestCase.setUp(self)
73
 
        self.map = DictGitShaMap()
74
 
 
75
 
 
76
 
class SqliteGitShaMapTests(TestCase,TestGitShaMap):
77
 
 
78
 
    def setUp(self):
79
 
        TestCase.setUp(self)
80
 
        self.map = SqliteGitShaMap()
81
 
 
82
 
 
83
 
class TdbGitShaMapTests(TestCaseInTempDir,TestGitShaMap):
84
 
 
85
 
    def setUp(self):
86
 
        TestCaseInTempDir.setUp(self)
87
 
        try:
88
 
            self.map = TdbGitShaMap(os.path.join(self.test_dir, 'foo.tdb'))
89
 
        except ImportError:
90
 
            raise UnavailableFeature("Missing tdb")