bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
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 |
||
|
0.200.475
by Jelmer Vernooij
Add Tdb database backend. |
19 |
import os |
20 |
||
21 |
from bzrlib.tests import ( |
|
22 |
TestCase, |
|
23 |
TestCaseInTempDir, |
|
24 |
UnavailableFeature, |
|
25 |
)
|
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
26 |
|
27 |
from bzrlib.plugins.git.shamap import ( |
|
28 |
DictGitShaMap, |
|
29 |
SqliteGitShaMap, |
|
|
0.200.475
by Jelmer Vernooij
Add Tdb database backend. |
30 |
TdbGitShaMap, |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
31 |
)
|
32 |
||
33 |
class TestGitShaMap: |
|
34 |
||
35 |
def test_commit(self): |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
36 |
self.map.start_write_group() |
|
0.200.790
by Jelmer Vernooij
Fix regression in SQLite sha map backend. |
37 |
self.map.add_entries("myrevid", [], |
38 |
"5686645d49063c73d35436192dfc9a160c672301", |
|
39 |
"cc9462f7f8263ef5adfbeff2fb936bb36b504cba", []) |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
40 |
self.map.commit_write_group() |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
41 |
self.assertEquals( |
42 |
("commit", ("myrevid", "cc9462f7f8263ef5adfbeff2fb936bb36b504cba")), |
|
43 |
self.map.lookup_git_sha("5686645d49063c73d35436192dfc9a160c672301")) |
|
44 |
||
45 |
def test_lookup_notfound(self): |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
46 |
self.assertRaises(KeyError, |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
47 |
self.map.lookup_git_sha, "5686645d49063c73d35436192dfc9a160c672301") |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
48 |
|
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
49 |
def test_blob(self): |
|
0.200.790
by Jelmer Vernooij
Fix regression in SQLite sha map backend. |
50 |
thesha = "9686645d49063c73d35436192dfc9a160c672301" |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
51 |
self.map.start_write_group() |
|
0.200.790
by Jelmer Vernooij
Fix regression in SQLite sha map backend. |
52 |
self.map.add_entries("myrevid", [], |
53 |
"5686645d49063c73d35436192dfc9a160c672301", |
|
54 |
"cc9462f7f8263ef5adfbeff2fb936bb36b504cba", [ |
|
55 |
("myfileid", "blob", thesha, "myrevid") |
|
56 |
])
|
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
57 |
self.map.commit_write_group() |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
58 |
self.assertEquals( |
59 |
("blob", ("myfileid", "myrevid")), |
|
|
0.200.477
by Jelmer Vernooij
More tests for sha maps, fix cache misses in tdb. |
60 |
self.map.lookup_git_sha(thesha)) |
|
0.200.753
by Jelmer Vernooij
Move lookup_tree/lookup_blob to a separate object. |
61 |
invshamap = self.map.get_inventory_sha_map("myrevid") |
|
0.200.807
by Jelmer Vernooij
Fix test, remove unnecessary sort. |
62 |
self.assertEquals(thesha, invshamap.lookup_blob("myfileid", "myrevid")) |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
63 |
|
64 |
def test_tree(self): |
|
|
0.200.790
by Jelmer Vernooij
Fix regression in SQLite sha map backend. |
65 |
thesha = "8686645d49063c73d35436192dfc9a160c672301" |
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
66 |
self.map.start_write_group() |
|
0.200.790
by Jelmer Vernooij
Fix regression in SQLite sha map backend. |
67 |
self.map.add_entries("myrevid", [], |
68 |
"5686645d49063c73d35436192dfc9a160c672301", |
|
69 |
"cc9462f7f8263ef5adfbeff2fb936bb36b504cba", [ |
|
70 |
("somepath", "tree", thesha, "myrevid")]) |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
71 |
self.map.commit_write_group() |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
72 |
self.assertEquals( |
73 |
("tree", ("somepath", "myrevid")), |
|
|
0.200.477
by Jelmer Vernooij
More tests for sha maps, fix cache misses in tdb. |
74 |
self.map.lookup_git_sha(thesha)) |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
75 |
|
76 |
def test_revids(self): |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
77 |
self.map.start_write_group() |
|
0.200.790
by Jelmer Vernooij
Fix regression in SQLite sha map backend. |
78 |
self.map.add_entries("myrevid", [], |
79 |
"5686645d49063c73d35436192dfc9a160c672301", |
|
80 |
"cc9462f7f8263ef5adfbeff2fb936bb36b504cba", []) |
|
|
0.200.687
by Jelmer Vernooij
Use start_write_group() / commit_write_group() mechanism when creating git SHA maps. |
81 |
self.map.commit_write_group() |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
82 |
self.assertEquals(["myrevid"], list(self.map.revids())) |
83 |
||
|
0.200.747
by Jelmer Vernooij
Add test for ShaMap.missing_revisions(). |
84 |
def test_missing_revisions(self): |
85 |
self.map.start_write_group() |
|
|
0.200.790
by Jelmer Vernooij
Fix regression in SQLite sha map backend. |
86 |
self.map.add_entries("myrevid", [], |
87 |
"5686645d49063c73d35436192dfc9a160c672301", |
|
88 |
"cc9462f7f8263ef5adfbeff2fb936bb36b504cba", []) |
|
|
0.200.747
by Jelmer Vernooij
Add test for ShaMap.missing_revisions(). |
89 |
self.map.commit_write_group() |
90 |
self.assertEquals(set(["lala", "bla"]), |
|
91 |
set(self.map.missing_revisions(["myrevid", "lala", "bla"]))) |
|
92 |
||
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
93 |
|
94 |
class DictGitShaMapTests(TestCase,TestGitShaMap): |
|
95 |
||
96 |
def setUp(self): |
|
|
0.200.280
by Jelmer Vernooij
Support bzr.dev. |
97 |
TestCase.setUp(self) |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
98 |
self.map = DictGitShaMap() |
99 |
||
100 |
||
101 |
class SqliteGitShaMapTests(TestCase,TestGitShaMap): |
|
102 |
||
103 |
def setUp(self): |
|
|
0.200.280
by Jelmer Vernooij
Support bzr.dev. |
104 |
TestCase.setUp(self) |
|
0.200.262
by Jelmer Vernooij
Add tests for GitShaMap. |
105 |
self.map = SqliteGitShaMap() |
106 |
||
|
0.200.475
by Jelmer Vernooij
Add Tdb database backend. |
107 |
|
108 |
class TdbGitShaMapTests(TestCaseInTempDir,TestGitShaMap): |
|
109 |
||
110 |
def setUp(self): |
|
111 |
TestCaseInTempDir.setUp(self) |
|
112 |
try: |
|
113 |
self.map = TdbGitShaMap(os.path.join(self.test_dir, 'foo.tdb')) |
|
114 |
except ImportError: |
|
115 |
raise UnavailableFeature("Missing tdb") |