bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005-2011, 2016 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
974.1.44
by aaron.bentley at utoronto
Added test of double-add in ImmutableStore |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
974.1.44
by aaron.bentley at utoronto
Added test of double-add in ImmutableStore |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
974.1.44
by aaron.bentley at utoronto
Added test of double-add in ImmutableStore |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
974.1.44
by aaron.bentley at utoronto
Added test of double-add in ImmutableStore |
16 |
|
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
17 |
"""Test Store implementations."""
|
18 |
||
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
19 |
from io import BytesIO |
1185.1.46
by Robert Collins
Aarons branch --basis patch |
20 |
import os |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
21 |
import gzip |
1185.1.41
by Robert Collins
massive patch from Alexander Belchenko - many PEP8 fixes, removes unused function uuid |
22 |
|
6686.2.1
by Jelmer Vernooij
Move breezy.store to breezy.plugins.weave_fmt, its only user. |
23 |
from ... import errors as errors |
24 |
from ...errors import BzrError |
|
25 |
from .store import TransportStore |
|
26 |
from .store.text import TextStore |
|
27 |
from .store.versioned import VersionedFileStore |
|
28 |
from ...tests import TestCase, TestCaseInTempDir, TestCaseWithTransport |
|
29 |
from ... import transactions |
|
30 |
from ... import transport |
|
31 |
from ...transport.memory import MemoryTransport |
|
6670.4.18
by Jelmer Vernooij
Merge move-store. |
32 |
from ...bzr.weave import WeaveFile |
974.1.44
by aaron.bentley at utoronto
Added test of double-add in ImmutableStore |
33 |
|
1185.1.41
by Robert Collins
massive patch from Alexander Belchenko - many PEP8 fixes, removes unused function uuid |
34 |
|
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
35 |
class TestStores(object): |
1185.16.146
by Martin Pool
Fix up assert with sideeffects in CompressedTextStore._copy_one |
36 |
"""Mixin template class that provides some common tests for stores""" |
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
37 |
|
38 |
def check_content(self, store, fileid, value): |
|
1442.1.35
by Robert Collins
convert all users of __getitem__ into TransportStores to use .get instead |
39 |
f = store.get(fileid) |
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
40 |
self.assertEqual(f.read(), value) |
41 |
||
42 |
def fill_store(self, store): |
|
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
43 |
store.add(BytesIO(b'hello'), b'a') |
44 |
store.add(BytesIO(b'other'), b'b') |
|
45 |
store.add(BytesIO(b'something'), b'c') |
|
46 |
store.add(BytesIO(b'goodbye'), b'123123') |
|
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
47 |
|
48 |
def test_get(self): |
|
49 |
store = self.get_store() |
|
50 |
self.fill_store(store) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
51 |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
52 |
self.check_content(store, b'a', b'hello') |
53 |
self.check_content(store, b'b', b'other') |
|
54 |
self.check_content(store, b'c', b'something') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
55 |
|
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
56 |
# Make sure that requesting a non-existing file fails
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
57 |
self.assertRaises(KeyError, self.check_content, store, b'd', None) |
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
58 |
|
974.1.44
by aaron.bentley at utoronto
Added test of double-add in ImmutableStore |
59 |
def test_multiple_add(self): |
60 |
"""Multiple add with same ID should raise a BzrError""" |
|
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
61 |
store = self.get_store() |
62 |
self.fill_store(store) |
|
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
63 |
self.assertRaises(BzrError, store.add, BytesIO(b'goodbye'), b'123123') |
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
64 |
|
65 |
||
66 |
class TestCompressedTextStore(TestCaseInTempDir, TestStores): |
|
67 |
||
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
68 |
def get_store(self, path=u'.'): |
6083.1.1
by Jelmer Vernooij
Use get_transport_from_{url,path} in more places. |
69 |
t = transport.get_transport_from_path(path) |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
70 |
return TextStore(t, compressed=True) |
1185.11.1
by John Arbash Meinel
(broken) Transport work is merged in. Tests do not pass yet. |
71 |
|
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
72 |
def test_total_size(self): |
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
73 |
store = self.get_store(u'.') |
1442.1.43
by Robert Collins
add registration of suffixes, in preparation for ensuring iteration is regular |
74 |
store.register_suffix('dsc') |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
75 |
store.add(BytesIO(b'goodbye'), b'123123') |
76 |
store.add(BytesIO(b'goodbye2'), b'123123', 'dsc') |
|
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
77 |
# these get gzipped - content should be stable
|
78 |
self.assertEqual(store.total_size(), (2, 55)) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
79 |
|
1442.1.32
by Robert Collins
Teach CompressedTextStore._relpath to support file suffixes too. |
80 |
def test__relpath_suffixed(self): |
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
81 |
my_store = TextStore(MockTransport(), |
82 |
prefixed=True, compressed=True) |
|
1442.1.43
by Robert Collins
add registration of suffixes, in preparation for ensuring iteration is regular |
83 |
my_store.register_suffix('dsc') |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
84 |
self.assertEqual('45/foo.dsc', my_store._relpath(b'foo', ['dsc'])) |
1442.1.32
by Robert Collins
Teach CompressedTextStore._relpath to support file suffixes too. |
85 |
|
1404
by Robert Collins
only pull remote text weaves once per fetch operation |
86 |
|
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
87 |
class TestMemoryStore(TestCase): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
88 |
|
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
89 |
def get_store(self): |
1651.1.7
by Martin Pool
Move small ImmutableMemoryStore class into test module, |
90 |
return TextStore(MemoryTransport()) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
91 |
|
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
92 |
def test_add_and_retrieve(self): |
93 |
store = self.get_store() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
94 |
store.add(BytesIO(b'hello'), b'aa') |
95 |
self.assertNotEqual(store.get(b'aa'), None) |
|
96 |
self.assertEqual(store.get(b'aa').read(), b'hello') |
|
97 |
store.add(BytesIO(b'hello world'), b'bb') |
|
98 |
self.assertNotEqual(store.get(b'bb'), None) |
|
99 |
self.assertEqual(store.get(b'bb').read(), b'hello world') |
|
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
100 |
|
101 |
def test_missing_is_absent(self): |
|
102 |
store = self.get_store() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
103 |
self.assertNotIn(b'aa', store) |
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
104 |
|
105 |
def test_adding_fails_when_present(self): |
|
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
106 |
my_store = self.get_store() |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
107 |
my_store.add(BytesIO(b'hello'), b'aa') |
1442.1.44
by Robert Collins
Many transport related tweaks: |
108 |
self.assertRaises(BzrError, |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
109 |
my_store.add, BytesIO(b'hello'), b'aa') |
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
110 |
|
111 |
def test_total_size(self): |
|
112 |
store = self.get_store() |
|
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
113 |
store.add(BytesIO(b'goodbye'), b'123123') |
114 |
store.add(BytesIO(b'goodbye2'), b'123123.dsc') |
|
1092.2.1
by Robert Collins
minor refactors to store, create an ImmutableMemoryStore for testing or other such operations |
115 |
self.assertEqual(store.total_size(), (2, 15)) |
1393.2.1
by John Arbash Meinel
Merged in split-storage-2 branch. Need to cleanup a little bit more still. |
116 |
# TODO: Switch the exception form UnlistableStore to
|
117 |
# or make Stores throw UnlistableStore if their
|
|
118 |
# Transport doesn't support listing
|
|
119 |
# store_c = RemoteStore('http://example.com/')
|
|
120 |
# self.assertRaises(UnlistableStore, copy_all, store_c, store_b)
|
|
121 |
||
1404
by Robert Collins
only pull remote text weaves once per fetch operation |
122 |
|
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
123 |
class TestTextStore(TestCaseInTempDir, TestStores): |
124 |
||
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
125 |
def get_store(self, path=u'.'): |
6083.1.1
by Jelmer Vernooij
Use get_transport_from_{url,path} in more places. |
126 |
t = transport.get_transport_from_path(path) |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
127 |
return TextStore(t, compressed=False) |
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
128 |
|
129 |
def test_total_size(self): |
|
130 |
store = self.get_store() |
|
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
131 |
store.add(BytesIO(b'goodbye'), b'123123') |
132 |
store.add(BytesIO(b'goodbye2'), b'123123.dsc') |
|
1442.1.34
by Robert Collins
Remove the Store.get multiple-get interface which was not used, and remove much spurious duplication in teststore.py. |
133 |
self.assertEqual(store.total_size(), (2, 15)) |
1393.2.2
by John Arbash Meinel
Updated stores to use Transport |
134 |
# TODO: Switch the exception form UnlistableStore to
|
135 |
# or make Stores throw UnlistableStore if their
|
|
136 |
# Transport doesn't support listing
|
|
137 |
# store_c = RemoteStore('http://example.com/')
|
|
138 |
# self.assertRaises(UnlistableStore, copy_all, store_c, store_b)
|
|
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
139 |
|
140 |
||
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
141 |
class TestMixedTextStore(TestCaseInTempDir, TestStores): |
142 |
||
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
143 |
def get_store(self, path=u'.', compressed=True): |
6083.1.1
by Jelmer Vernooij
Use get_transport_from_{url,path} in more places. |
144 |
t = transport.get_transport_from_path(path) |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
145 |
return TextStore(t, compressed=compressed) |
146 |
||
147 |
def test_get_mixed(self): |
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
148 |
cs = self.get_store(u'.', compressed=True) |
149 |
s = self.get_store(u'.', compressed=False) |
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
150 |
cs.add(BytesIO(b'hello there'), b'a') |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
151 |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
152 |
self.assertPathExists('a.gz') |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
153 |
self.assertFalse(os.path.lexists('a')) |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
154 |
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
155 |
with gzip.GzipFile('a.gz') as f: |
156 |
self.assertEqual(f.read(), b'hello there') |
|
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
157 |
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
158 |
self.assertEqual(cs.has_id(b'a'), True) |
159 |
self.assertEqual(s.has_id(b'a'), True) |
|
160 |
self.assertEqual(cs.get(b'a').read(), b'hello there') |
|
161 |
self.assertEqual(s.get(b'a').read(), b'hello there') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
162 |
|
6973.7.6
by Jelmer Vernooij
Fix more tests. |
163 |
self.assertRaises(BzrError, s.add, BytesIO(b'goodbye'), b'a') |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
164 |
|
6973.7.6
by Jelmer Vernooij
Fix more tests. |
165 |
s.add(BytesIO(b'goodbye'), b'b') |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
166 |
self.assertPathExists('b') |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
167 |
self.assertFalse(os.path.lexists('b.gz')) |
6973.7.5
by Jelmer Vernooij
s/file/open. |
168 |
with open('b', 'rb') as f: |
169 |
self.assertEqual(f.read(), b'goodbye') |
|
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
170 |
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
171 |
self.assertEqual(cs.has_id(b'b'), True) |
172 |
self.assertEqual(s.has_id(b'b'), True) |
|
173 |
self.assertEqual(cs.get(b'b').read(), b'goodbye') |
|
174 |
self.assertEqual(s.get(b'b').read(), b'goodbye') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
175 |
|
6973.7.6
by Jelmer Vernooij
Fix more tests. |
176 |
self.assertRaises(BzrError, cs.add, BytesIO(b'again'), b'b') |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
177 |
|
6973.7.5
by Jelmer Vernooij
s/file/open. |
178 |
|
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
179 |
class MockTransport(transport.Transport): |
180 |
"""A fake transport for testing with.""" |
|
181 |
||
1442.1.30
by Robert Collins
Add stuf has and mkdir to MockTransport to enable testing store adds |
182 |
def has(self, filename): |
183 |
return False |
|
184 |
||
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
185 |
def __init__(self, url=None): |
186 |
if url is None: |
|
187 |
url = "http://example.com" |
|
188 |
super(MockTransport, self).__init__(url) |
|
189 |
||
1442.1.30
by Robert Collins
Add stuf has and mkdir to MockTransport to enable testing store adds |
190 |
def mkdir(self, filename): |
191 |
return
|
|
192 |
||
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
193 |
|
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
194 |
class InstrumentedTransportStore(TransportStore): |
1442.1.29
by Robert Collins
create an instrumented transport store for testing common logic. |
195 |
"""An instrumented TransportStore. |
196 |
||
197 |
Here we replace template method worker methods with calls that record the
|
|
198 |
expected results.
|
|
199 |
"""
|
|
200 |
||
201 |
def _add(self, filename, file): |
|
202 |
self._calls.append(("_add", filename, file)) |
|
203 |
||
204 |
def __init__(self, transport, prefixed=False): |
|
205 |
super(InstrumentedTransportStore, self).__init__(transport, prefixed) |
|
206 |
self._calls = [] |
|
207 |
||
208 |
||
209 |
class TestInstrumentedTransportStore(TestCase): |
|
210 |
||
211 |
def test__add_records(self): |
|
212 |
my_store = InstrumentedTransportStore(MockTransport()) |
|
1442.1.30
by Robert Collins
Add stuf has and mkdir to MockTransport to enable testing store adds |
213 |
my_store._add("filename", "file") |
1442.1.29
by Robert Collins
create an instrumented transport store for testing common logic. |
214 |
self.assertEqual([("_add", "filename", "file")], my_store._calls) |
215 |
||
216 |
||
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
217 |
class TestMockTransport(TestCase): |
218 |
||
219 |
def test_isinstance(self): |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
220 |
self.assertIsInstance(MockTransport(), transport.Transport) |
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
221 |
|
1442.1.30
by Robert Collins
Add stuf has and mkdir to MockTransport to enable testing store adds |
222 |
def test_has(self): |
223 |
self.assertEqual(False, MockTransport().has('foo')) |
|
224 |
||
225 |
def test_mkdir(self): |
|
226 |
MockTransport().mkdir('45') |
|
227 |
||
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
228 |
|
229 |
class TestTransportStore(TestCase): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
230 |
|
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
231 |
def test__relpath_invalid(self): |
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
232 |
my_store = TransportStore(MockTransport()) |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
233 |
self.assertRaises(ValueError, my_store._relpath, b'/foo') |
234 |
self.assertRaises(ValueError, my_store._relpath, b'foo/') |
|
1442.1.24
by Robert Collins
Pull up _check_id and _relpath from Text and CompressedText stores into TransportStore |
235 |
|
1442.1.43
by Robert Collins
add registration of suffixes, in preparation for ensuring iteration is regular |
236 |
def test_register_invalid_suffixes(self): |
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
237 |
my_store = TransportStore(MockTransport()) |
1442.1.43
by Robert Collins
add registration of suffixes, in preparation for ensuring iteration is regular |
238 |
self.assertRaises(ValueError, my_store.register_suffix, '/') |
239 |
self.assertRaises(ValueError, my_store.register_suffix, '.gz/bar') |
|
240 |
||
241 |
def test__relpath_unregister_suffixes(self): |
|
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
242 |
my_store = TransportStore(MockTransport()) |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
243 |
self.assertRaises(ValueError, my_store._relpath, b'foo', [b'gz']) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
244 |
self.assertRaises(ValueError, my_store._relpath, |
245 |
b'foo', [b'dsc', b'gz']) |
|
1442.1.27
by Robert Collins
Check that file suffixes in TransportStore are also valid |
246 |
|
1442.1.25
by Robert Collins
Test TransportStore._relpath for simple cases: pull up _prefixed attribute as a result. |
247 |
def test__relpath_simple(self): |
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
248 |
my_store = TransportStore(MockTransport()) |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
249 |
self.assertEqual("foo", my_store._relpath(b'foo')) |
1442.1.26
by Robert Collins
Pull up _relpath with gz suffix for CompressedTextStore into TransportStore |
250 |
|
251 |
def test__relpath_prefixed(self): |
|
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
252 |
my_store = TransportStore(MockTransport(), True) |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
253 |
self.assertEqual('45/foo', my_store._relpath(b'foo')) |
1442.1.26
by Robert Collins
Pull up _relpath with gz suffix for CompressedTextStore into TransportStore |
254 |
|
255 |
def test__relpath_simple_suffixed(self): |
|
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
256 |
my_store = TransportStore(MockTransport()) |
1442.1.43
by Robert Collins
add registration of suffixes, in preparation for ensuring iteration is regular |
257 |
my_store.register_suffix('bar') |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
258 |
my_store.register_suffix('baz') |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
259 |
self.assertEqual('foo.baz', my_store._relpath(b'foo', ['baz'])) |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
260 |
self.assertEqual('foo.bar.baz', my_store._relpath( |
261 |
b'foo', ['bar', 'baz'])) |
|
1442.1.27
by Robert Collins
Check that file suffixes in TransportStore are also valid |
262 |
|
263 |
def test__relpath_prefixed_suffixed(self): |
|
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
264 |
my_store = TransportStore(MockTransport(), True) |
1442.1.43
by Robert Collins
add registration of suffixes, in preparation for ensuring iteration is regular |
265 |
my_store.register_suffix('bar') |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
266 |
my_store.register_suffix('baz') |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
267 |
self.assertEqual('45/foo.baz', my_store._relpath(b'foo', ['baz'])) |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
268 |
self.assertEqual('45/foo.bar.baz', |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
269 |
my_store._relpath(b'foo', ['bar', 'baz'])) |
1442.1.27
by Robert Collins
Check that file suffixes in TransportStore are also valid |
270 |
|
1442.1.31
by Robert Collins
test that TransportStore.add calls _add appropriately. |
271 |
def test_add_simple(self): |
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
272 |
stream = BytesIO(b"content") |
1442.1.31
by Robert Collins
test that TransportStore.add calls _add appropriately. |
273 |
my_store = InstrumentedTransportStore(MockTransport()) |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
274 |
my_store.add(stream, b"foo") |
1442.1.31
by Robert Collins
test that TransportStore.add calls _add appropriately. |
275 |
self.assertEqual([("_add", "foo", stream)], my_store._calls) |
276 |
||
277 |
def test_add_prefixed(self): |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
278 |
stream = BytesIO(b"content") |
1442.1.31
by Robert Collins
test that TransportStore.add calls _add appropriately. |
279 |
my_store = InstrumentedTransportStore(MockTransport(), True) |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
280 |
my_store.add(stream, b"foo") |
1442.1.31
by Robert Collins
test that TransportStore.add calls _add appropriately. |
281 |
self.assertEqual([("_add", "45/foo", stream)], my_store._calls) |
1442.1.33
by Robert Collins
teach TransportStore.add to accept an optional file suffix, which does not alter the fileid. |
282 |
|
283 |
def test_add_simple_suffixed(self): |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
284 |
stream = BytesIO(b"content") |
1442.1.33
by Robert Collins
teach TransportStore.add to accept an optional file suffix, which does not alter the fileid. |
285 |
my_store = InstrumentedTransportStore(MockTransport()) |
1442.1.43
by Robert Collins
add registration of suffixes, in preparation for ensuring iteration is regular |
286 |
my_store.register_suffix('dsc') |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
287 |
my_store.add(stream, b"foo", b'dsc') |
1442.1.33
by Robert Collins
teach TransportStore.add to accept an optional file suffix, which does not alter the fileid. |
288 |
self.assertEqual([("_add", "foo.dsc", stream)], my_store._calls) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
289 |
|
1442.1.33
by Robert Collins
teach TransportStore.add to accept an optional file suffix, which does not alter the fileid. |
290 |
def test_add_simple_suffixed(self): |
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
291 |
stream = BytesIO(b"content") |
1442.1.33
by Robert Collins
teach TransportStore.add to accept an optional file suffix, which does not alter the fileid. |
292 |
my_store = InstrumentedTransportStore(MockTransport(), True) |
1442.1.43
by Robert Collins
add registration of suffixes, in preparation for ensuring iteration is regular |
293 |
my_store.register_suffix('dsc') |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
294 |
my_store.add(stream, b"foo", 'dsc') |
1442.1.33
by Robert Collins
teach TransportStore.add to accept an optional file suffix, which does not alter the fileid. |
295 |
self.assertEqual([("_add", "45/foo.dsc", stream)], my_store._calls) |
1442.1.46
by Robert Collins
test simple has_id |
296 |
|
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
297 |
def get_populated_store(self, prefixed=False, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
298 |
store_class=TextStore, compressed=False): |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
299 |
my_store = store_class(MemoryTransport(), prefixed, |
300 |
compressed=compressed) |
|
1442.1.46
by Robert Collins
test simple has_id |
301 |
my_store.register_suffix('sig') |
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
302 |
stream = BytesIO(b"signature") |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
303 |
my_store.add(stream, b"foo", 'sig') |
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
304 |
stream = BytesIO(b"content") |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
305 |
my_store.add(stream, b"foo") |
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
306 |
stream = BytesIO(b"signature for missing base") |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
307 |
my_store.add(stream, b"missing", 'sig') |
1442.1.46
by Robert Collins
test simple has_id |
308 |
return my_store |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
309 |
|
1442.1.46
by Robert Collins
test simple has_id |
310 |
def test_has_simple(self): |
311 |
my_store = self.get_populated_store() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
312 |
self.assertEqual(True, my_store.has_id(b'foo')) |
1442.1.47
by Robert Collins
test for has with suffixed files |
313 |
my_store = self.get_populated_store(True) |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
314 |
self.assertEqual(True, my_store.has_id(b'foo')) |
1442.1.47
by Robert Collins
test for has with suffixed files |
315 |
|
316 |
def test_has_suffixed(self): |
|
317 |
my_store = self.get_populated_store() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
318 |
self.assertEqual(True, my_store.has_id(b'foo', 'sig')) |
1442.1.47
by Robert Collins
test for has with suffixed files |
319 |
my_store = self.get_populated_store(True) |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
320 |
self.assertEqual(True, my_store.has_id(b'foo', 'sig')) |
1442.1.48
by Robert Collins
test that the presence of a signature does not make a missing base file magically appear present |
321 |
|
322 |
def test_has_suffixed_no_base(self): |
|
323 |
my_store = self.get_populated_store() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
324 |
self.assertEqual(False, my_store.has_id(b'missing')) |
1442.1.48
by Robert Collins
test that the presence of a signature does not make a missing base file magically appear present |
325 |
my_store = self.get_populated_store(True) |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
326 |
self.assertEqual(False, my_store.has_id(b'missing')) |
1442.1.50
by Robert Collins
test get with suffixes |
327 |
|
328 |
def test_get_simple(self): |
|
329 |
my_store = self.get_populated_store() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
330 |
self.assertEqual(b'content', my_store.get(b'foo').read()) |
1442.1.50
by Robert Collins
test get with suffixes |
331 |
my_store = self.get_populated_store(True) |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
332 |
self.assertEqual(b'content', my_store.get(b'foo').read()) |
1442.1.50
by Robert Collins
test get with suffixes |
333 |
|
334 |
def test_get_suffixed(self): |
|
335 |
my_store = self.get_populated_store() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
336 |
self.assertEqual(b'signature', my_store.get(b'foo', 'sig').read()) |
1442.1.50
by Robert Collins
test get with suffixes |
337 |
my_store = self.get_populated_store(True) |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
338 |
self.assertEqual(b'signature', my_store.get(b'foo', 'sig').read()) |
1442.1.50
by Robert Collins
test get with suffixes |
339 |
|
340 |
def test_get_suffixed_no_base(self): |
|
341 |
my_store = self.get_populated_store() |
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
342 |
self.assertEqual(b'signature for missing base', |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
343 |
my_store.get(b'missing', 'sig').read()) |
1442.1.50
by Robert Collins
test get with suffixes |
344 |
my_store = self.get_populated_store(True) |
6855.3.1
by Jelmer Vernooij
Several more fixes. |
345 |
self.assertEqual(b'signature for missing base', |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
346 |
my_store.get(b'missing', 'sig').read()) |
1442.1.51
by Robert Collins
teach iter about suffixes |
347 |
|
348 |
def test___iter__no_suffix(self): |
|
1185.58.4
by John Arbash Meinel
Added permission checking to Branch, and propogated that change into the stores. |
349 |
my_store = TextStore(MemoryTransport(), |
350 |
prefixed=False, compressed=False) |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
351 |
stream = BytesIO(b"content") |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
352 |
my_store.add(stream, b"foo") |
353 |
self.assertEqual({b'foo'}, |
|
1442.1.51
by Robert Collins
teach iter about suffixes |
354 |
set(my_store.__iter__())) |
355 |
||
356 |
def test___iter__(self): |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
357 |
self.assertEqual({b'foo'}, |
1442.1.51
by Robert Collins
teach iter about suffixes |
358 |
set(self.get_populated_store().__iter__())) |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
359 |
self.assertEqual({b'foo'}, |
1442.1.51
by Robert Collins
teach iter about suffixes |
360 |
set(self.get_populated_store(True).__iter__())) |
361 |
||
362 |
def test___iter__compressed(self): |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
363 |
self.assertEqual({b'foo'}, |
1442.1.51
by Robert Collins
teach iter about suffixes |
364 |
set(self.get_populated_store( |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
365 |
compressed=True).__iter__())) |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
366 |
self.assertEqual({b'foo'}, |
1442.1.51
by Robert Collins
teach iter about suffixes |
367 |
set(self.get_populated_store( |
1185.16.157
by John Arbash Meinel
Added ability for TextStore to handle both compressed and uncompressed, it just looks for one type first |
368 |
True, compressed=True).__iter__())) |
1442.1.51
by Robert Collins
teach iter about suffixes |
369 |
|
370 |
def test___len__(self): |
|
371 |
self.assertEqual(1, len(self.get_populated_store())) |
|
1442.1.54
by Robert Collins
Teach store.copy_all about fileid suffixes |
372 |
|
1469
by Robert Collins
Change Transport.* to work with URL's. |
373 |
def test_relpath_escaped(self): |
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
374 |
my_store = TransportStore(MemoryTransport()) |
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
375 |
self.assertEqual('%25', my_store._relpath(b'%')) |
1594.2.23
by Robert Collins
Test versioned file storage handling of clean/dirty status for accessed versioned files. |
376 |
|
1608.2.12
by Martin Pool
Store-escaping must quote uppercase characters too, so that they're safely |
377 |
def test_escaped_uppercase(self): |
378 |
"""Uppercase letters are escaped for safety on Windows""" |
|
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
379 |
my_store = TransportStore(MemoryTransport(), prefixed=True, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
380 |
escaped=True) |
1608.2.12
by Martin Pool
Store-escaping must quote uppercase characters too, so that they're safely |
381 |
# a particularly perverse file-id! :-)
|
6963.2.10
by Jelmer Vernooij
Fix a bunch of tests. |
382 |
self.assertEqual(my_store._relpath(b'C:<>'), 'be/%2543%253a%253c%253e') |
1608.2.12
by Martin Pool
Store-escaping must quote uppercase characters too, so that they're safely |
383 |
|
1594.2.23
by Robert Collins
Test versioned file storage handling of clean/dirty status for accessed versioned files. |
384 |
|
385 |
class TestVersionFileStore(TestCaseWithTransport): |
|
386 |
||
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
387 |
def get_scope(self): |
388 |
return self._transaction |
|
389 |
||
1594.2.23
by Robert Collins
Test versioned file storage handling of clean/dirty status for accessed versioned files. |
390 |
def setUp(self): |
391 |
super(TestVersionFileStore, self).setUp() |
|
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
392 |
self.vfstore = VersionedFileStore(MemoryTransport(), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
393 |
versionedfile_class=WeaveFile) |
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
394 |
self.vfstore.get_scope = self.get_scope |
395 |
self._transaction = None |
|
1594.2.23
by Robert Collins
Test versioned file storage handling of clean/dirty status for accessed versioned files. |
396 |
|
397 |
def test_get_weave_registers_dirty_in_write(self): |
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
398 |
self._transaction = transactions.WriteTransaction() |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
399 |
vf = self.vfstore.get_weave_or_empty(b'id', self._transaction) |
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
400 |
self._transaction.finish() |
401 |
self._transaction = None |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
402 |
self.assertRaises(errors.OutSideTransaction, |
403 |
vf.add_lines, b'b', [], []) |
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
404 |
self._transaction = transactions.WriteTransaction() |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
405 |
vf = self.vfstore.get_weave(b'id', self._transaction) |
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
406 |
self._transaction.finish() |
407 |
self._transaction = None |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
408 |
self.assertRaises(errors.OutSideTransaction, |
409 |
vf.add_lines, b'b', [], []) |
|
1594.2.23
by Robert Collins
Test versioned file storage handling of clean/dirty status for accessed versioned files. |
410 |
|
411 |
def test_get_weave_readonly_cant_write(self): |
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
412 |
self._transaction = transactions.WriteTransaction() |
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
413 |
vf = self.vfstore.get_weave_or_empty(b'id', self._transaction) |
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
414 |
self._transaction.finish() |
415 |
self._transaction = transactions.ReadOnlyTransaction() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
416 |
vf = self.vfstore.get_weave_or_empty(b'id', self._transaction) |
417 |
self.assertRaises(errors.ReadOnlyError, vf.add_lines, b'b', [], []) |
|
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
418 |
|
419 |
def test___iter__escaped(self): |
|
5582.9.21
by Jelmer Vernooij
Remove weave references from VersionedfileStore. |
420 |
self.vfstore = VersionedFileStore(MemoryTransport(), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
421 |
prefixed=True, escaped=True, versionedfile_class=WeaveFile) |
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
422 |
self.vfstore.get_scope = self.get_scope |
423 |
self._transaction = transactions.WriteTransaction() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
424 |
vf = self.vfstore.get_weave_or_empty(b' ', self._transaction) |
425 |
vf.add_lines(b'a', [], []) |
|
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
426 |
del vf |
427 |
self._transaction.finish() |
|
6963.2.18
by Jelmer Vernooij
Add bees to some of bp.weave_fmt. |
428 |
self.assertEqual([b' '], list(self.vfstore)) |