/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

Reduce number of round trips when fetching from Git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for GitShaMap."""
18
18
 
19
 
import os
20
 
 
21
 
from bzrlib.tests import (
22
 
    TestCase,
23
 
    TestCaseInTempDir,
24
 
    UnavailableFeature,
25
 
    )
 
19
from bzrlib.tests import TestCase
26
20
 
27
21
from bzrlib.plugins.git.shamap import (
28
22
    DictGitShaMap,
29
23
    SqliteGitShaMap,
30
 
    TdbGitShaMap,
31
24
    )
32
25
 
33
26
class TestGitShaMap:
44
37
            self.map.lookup_git_sha, "5686645d49063c73d35436192dfc9a160c672301")
45
38
        
46
39
    def test_blob(self):
47
 
        thesha = "5686645d49063c73d35436192dfc9a160c672301"
48
 
        self.map.add_entry(thesha, "blob", ("myfileid", "myrevid"))
 
40
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
 
41
            "blob", ("myfileid", "myrevid"))
49
42
        self.assertEquals(
50
43
            ("blob", ("myfileid", "myrevid")),
51
 
            self.map.lookup_git_sha(thesha))
52
 
        self.assertEquals(thesha, self.map.lookup_blob("myfileid", "myrevid"))
 
44
            self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
53
45
 
54
46
    def test_tree(self):
55
 
        thesha = "5686645d49063c73d35436192dfc9a160c672301"
56
 
        self.map.add_entry(thesha, 
 
47
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
57
48
            "tree", ("somepath", "myrevid"))
58
49
        self.assertEquals(
59
50
            ("tree", ("somepath", "myrevid")),
60
 
            self.map.lookup_git_sha(thesha))
61
 
        self.assertEquals(thesha, self.map.lookup_tree("somepath", "myrevid"))
 
51
            self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301"))
62
52
 
63
53
    def test_revids(self):
64
54
        self.map.add_entry("5686645d49063c73d35436192dfc9a160c672301", 
79
69
        TestCase.setUp(self)
80
70
        self.map = SqliteGitShaMap()
81
71
 
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")