1
# Copyright (C) 2005-2009, 2011 Canonical Ltd
1
# Copyright (C) 2005-2011, 2016 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
82
82
class TestCompressedTextStore(TestCaseInTempDir, TestStores):
84
84
def get_store(self, path=u'.'):
85
t = transport.get_transport(path)
85
t = transport.get_transport_from_path(path)
86
86
return TextStore(t, compressed=True)
88
88
def test_total_size(self):
139
139
class TestTextStore(TestCaseInTempDir, TestStores):
141
141
def get_store(self, path=u'.'):
142
t = transport.get_transport(path)
142
t = transport.get_transport_from_path(path)
143
143
return TextStore(t, compressed=False)
145
145
def test_total_size(self):
157
157
class TestMixedTextStore(TestCaseInTempDir, TestStores):
159
159
def get_store(self, path=u'.', compressed=True):
160
t = transport.get_transport(path)
160
t = transport.get_transport_from_path(path)
161
161
return TextStore(t, compressed=compressed)
163
163
def test_get_mixed(self):
168
168
self.assertPathExists('a.gz')
169
169
self.assertFalse(os.path.lexists('a'))
171
self.assertEquals(gzip.GzipFile('a.gz').read(), 'hello there')
171
self.assertEqual(gzip.GzipFile('a.gz').read(), 'hello there')
173
self.assertEquals(cs.has_id('a'), True)
174
self.assertEquals(s.has_id('a'), True)
175
self.assertEquals(cs.get('a').read(), 'hello there')
176
self.assertEquals(s.get('a').read(), 'hello there')
173
self.assertEqual(cs.has_id('a'), True)
174
self.assertEqual(s.has_id('a'), True)
175
self.assertEqual(cs.get('a').read(), 'hello there')
176
self.assertEqual(s.get('a').read(), 'hello there')
178
178
self.assertRaises(BzrError, s.add, StringIO('goodbye'), 'a')
180
180
s.add(StringIO('goodbye'), 'b')
181
181
self.assertPathExists('b')
182
182
self.assertFalse(os.path.lexists('b.gz'))
183
self.assertEquals(open('b').read(), 'goodbye')
183
self.assertEqual(open('b').read(), 'goodbye')
185
self.assertEquals(cs.has_id('b'), True)
186
self.assertEquals(s.has_id('b'), True)
187
self.assertEquals(cs.get('b').read(), 'goodbye')
188
self.assertEquals(s.get('b').read(), 'goodbye')
185
self.assertEqual(cs.has_id('b'), True)
186
self.assertEqual(s.has_id('b'), True)
187
self.assertEqual(cs.get('b').read(), 'goodbye')
188
self.assertEqual(s.get('b').read(), 'goodbye')
190
190
self.assertRaises(BzrError, cs.add, StringIO('again'), 'b')
402
402
my_store = TransportStore(MemoryTransport(), prefixed=True,
404
404
# a particularly perverse file-id! :-)
405
self.assertEquals(my_store._relpath('C:<>'), 'be/%2543%253a%253c%253e')
405
self.assertEqual(my_store._relpath('C:<>'), 'be/%2543%253a%253c%253e')
408
408
class TestVersionFileStore(TestCaseWithTransport):