bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
|
1563.2.21
by Robert Collins
Smoke test for RevisionStore factories creating revision stores. |
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 |
"""Revision store tests."""
|
|
18 |
||
19 |
||
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
20 |
import bzrlib.errors as errors |
21 |
from bzrlib.revision import Revision |
|
|
1563.2.21
by Robert Collins
Smoke test for RevisionStore factories creating revision stores. |
22 |
from bzrlib.store.revision import RevisionStore |
23 |
from bzrlib.tests import TestCaseWithTransport |
|
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
24 |
from bzrlib.transactions import PassThroughTransaction |
25 |
||
26 |
||
27 |
class TestFactory(TestCaseWithTransport): |
|
|
1563.2.21
by Robert Collins
Smoke test for RevisionStore factories creating revision stores. |
28 |
|
29 |
def test_factory_keeps_smoke_in(self): |
|
30 |
s = self.store_factory.create(self.get_url('.')) |
|
31 |
self.assertTrue(isinstance(s, RevisionStore)) |
|
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
32 |
|
33 |
||
34 |
class TestAll(TestCaseWithTransport): |
|
35 |
||
36 |
def setUp(self): |
|
37 |
super(TestAll, self).setUp() |
|
38 |
self.store = self.store_factory.create(self.get_url('.')) |
|
39 |
self.transaction = PassThroughTransaction() |
|
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
40 |
self.store.get_scope = self.get_transaction |
41 |
||
42 |
def get_transaction(self): |
|
43 |
return self.transaction |
|
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
44 |
|
|
1563.2.23
by Robert Collins
Add add_revision and get_revision methods to RevisionStore |
45 |
def test_add_has_get(self): |
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
46 |
rev = self.add_sample_rev() |
47 |
self.assertTrue(self.store.has_revision_id('A', self.transaction)) |
|
48 |
rev2 = self.store.get_revision('A', self.transaction) |
|
49 |
self.assertEqual(rev, rev2) |
|
50 |
||
51 |
def add_sample_rev(self): |
|
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
52 |
rev = Revision(timestamp=0, |
|
1913.1.6
by John Arbash Meinel
Found a test that expected timzone to be None |
53 |
timezone=0, |
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
54 |
committer="Foo Bar <foo@example.com>", |
55 |
message="Message", |
|
|
1563.2.23
by Robert Collins
Add add_revision and get_revision methods to RevisionStore |
56 |
inventory_sha1='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', |
57 |
revision_id='A') |
|
58 |
self.store.add_revision(rev, self.transaction) |
|
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
59 |
return rev |
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
60 |
|
61 |
def test_has_missing(self): |
|
62 |
# has of a non present id -> False
|
|
63 |
self.assertFalse(self.store.has_revision_id('missing', self.transaction)) |
|
64 |
||
|
2743.1.5
by Robert Collins
Tighten the revision store implementation tests surrounding the |
65 |
def test_has_null(self): |
66 |
# has of null -> True
|
|
|
2598.5.3
by Aaron Bentley
Push NULL_REVISION deeper |
67 |
self.assertTrue(self.store.has_revision_id('null:', self.transaction)) |
|
1563.2.23
by Robert Collins
Add add_revision and get_revision methods to RevisionStore |
68 |
|
|
2592.3.97
by Robert Collins
Merge more bzr.dev, addressing some bugs. [still broken] |
69 |
def test_get_revision_missing(self): |
70 |
# get_revision('B') -> raises NoSuchRevision
|
|
71 |
self.assertRaises(errors.NoSuchRevision, |
|
72 |
self.store.get_revision, |
|
73 |
'B', |
|
74 |
self.transaction) |
|
75 |
||
|
2743.1.5
by Robert Collins
Tighten the revision store implementation tests surrounding the |
76 |
def test_get_revision_null(self): |
77 |
# get_revision(null) -> raises ReservedId
|
|
78 |
self.assertRaises(errors.ReservedId, |
|
|
1563.2.23
by Robert Collins
Add add_revision and get_revision methods to RevisionStore |
79 |
self.store.get_revision, |
|
2743.1.5
by Robert Collins
Tighten the revision store implementation tests surrounding the |
80 |
'null:', |
|
1563.2.23
by Robert Collins
Add add_revision and get_revision methods to RevisionStore |
81 |
self.transaction) |
|
1563.2.27
by Robert Collins
Add signature text addition to the revisionstore api. |
82 |
|
83 |
def test_add_signature_text_missing(self): |
|
|
1563.2.30
by Robert Collins
Remove all but fetch references to revision_store, making the repository references that are weave specific use the RevisionTextStore.text_store attribute. |
84 |
# add of a text signature for a missing revision must work, to allow
|
85 |
# revisions to be added after the signature.
|
|
86 |
self.store.add_revision_signature_text('A', 'foo\nbar', self.transaction) |
|
87 |
# but must not be visible
|
|
|
1563.2.29
by Robert Collins
Remove all but fetch references to repository.revision_store. |
88 |
self.assertRaises(errors.NoSuchRevision, |
89 |
self.store.has_signature, |
|
|
1563.2.30
by Robert Collins
Remove all but fetch references to revision_store, making the repository references that are weave specific use the RevisionTextStore.text_store attribute. |
90 |
'A', |
91 |
self.transaction) |
|
92 |
# at all
|
|
93 |
self.assertRaises(errors.NoSuchRevision, |
|
94 |
self.store.get_signature_text, |
|
95 |
'A', |
|
96 |
self.transaction) |
|
97 |
# until the revision is added
|
|
98 |
self.add_sample_rev() |
|
99 |
self.assertTrue(self.store.has_signature('A', self.transaction)) |
|
100 |
self.assertEqual('foo\nbar', |
|
101 |
self.store.get_signature_text('A', self.transaction)) |
|
|
1563.2.29
by Robert Collins
Remove all but fetch references to repository.revision_store. |
102 |
|
103 |
def test_add_signature_text(self): |
|
104 |
# add a signature to a existing revision works.
|
|
105 |
self.add_sample_rev() |
|
106 |
self.assertFalse(self.store.has_signature('A', self.transaction)) |
|
|
1563.2.30
by Robert Collins
Remove all but fetch references to revision_store, making the repository references that are weave specific use the RevisionTextStore.text_store attribute. |
107 |
self.assertRaises(errors.NoSuchRevision, |
108 |
self.store.get_signature_text, |
|
109 |
'A', |
|
110 |
self.transaction) |
|
|
1563.2.29
by Robert Collins
Remove all but fetch references to repository.revision_store. |
111 |
self.store.add_revision_signature_text('A', 'foo\nbar', self.transaction) |
112 |
self.assertTrue(self.store.has_signature('A', self.transaction)) |
|
|
1563.2.30
by Robert Collins
Remove all but fetch references to revision_store, making the repository references that are weave specific use the RevisionTextStore.text_store attribute. |
113 |
self.assertEqual('foo\nbar', |
114 |
self.store.get_signature_text('A', self.transaction)) |
|
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
115 |
|
116 |
def test_total_size(self): |
|
117 |
# we get a revision count and a numeric size figure from total_size().
|
|
118 |
count, bytes = self.store.total_size(self.transaction) |
|
119 |
self.assertEqual(0, count) |
|
|
1666.1.6
by Robert Collins
Make knit the default format. |
120 |
# some stores use disk immediately that they are created so we just
|
121 |
# check that its an int.
|
|
122 |
self.assertIsInstance(bytes, (int, long)) |
|
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
123 |
self.add_sample_rev() |
124 |
count, bytes = self.store.total_size(self.transaction) |
|
125 |
self.assertEqual(1, count) |
|
126 |
self.assertNotEqual(0, bytes) |
|
127 |
||
|
1563.2.29
by Robert Collins
Remove all but fetch references to repository.revision_store. |
128 |
def test_all_revision_ids(self): |
129 |
self.assertEqual([], self.store.all_revision_ids(self.transaction)) |
|
130 |
self.add_sample_rev() |
|
131 |
self.assertEqual(['A'], self.store.all_revision_ids(self.transaction)) |