85
85
def test_total_size(self):
86
86
store = self.get_store('.')
87
store.register_suffix('dsc')
87
88
store.add(StringIO('goodbye'), '123123')
88
store.add(StringIO('goodbye2'), '123123', '.dsc')
89
store.add(StringIO('goodbye2'), '123123', 'dsc')
89
90
# these get gzipped - content should be stable
90
91
self.assertEqual(store.total_size(), (2, 55))
92
93
def test__relpath_suffixed(self):
93
94
my_store = CompressedTextStore(MockTransport(), True)
95
my_store.register_suffix('dsc')
94
96
self.assertEqual('45/foo.dsc.gz', my_store._relpath('foo', ['dsc']))
208
210
self.assertRaises(ValueError, my_store._relpath, '/foo')
209
211
self.assertRaises(ValueError, my_store._relpath, 'foo/')
211
def test__relpath_invalid_suffixes(self):
212
my_store = store.TransportStore(MockTransport())
213
self.assertRaises(ValueError, my_store._relpath, 'foo', '/')
214
self.assertRaises(ValueError, my_store._relpath, 'foo', '.gz/bar')
213
def test_register_invalid_suffixes(self):
214
my_store = store.TransportStore(MockTransport())
215
self.assertRaises(ValueError, my_store.register_suffix, '/')
216
self.assertRaises(ValueError, my_store.register_suffix, '.gz/bar')
218
def test__relpath_unregister_suffixes(self):
219
my_store = store.TransportStore(MockTransport())
220
self.assertRaises(ValueError, my_store._relpath, 'foo', ['gz'])
221
self.assertRaises(ValueError, my_store._relpath, 'foo', ['dsc', 'gz'])
216
223
def test__relpath_simple(self):
217
224
my_store = store.TransportStore(MockTransport())
224
231
def test__relpath_simple_suffixed(self):
225
232
my_store = store.TransportStore(MockTransport())
233
my_store.register_suffix('gz')
234
my_store.register_suffix('bar')
226
235
self.assertEqual('foo.gz', my_store._relpath('foo', ['gz']))
227
236
self.assertEqual('foo.gz.bar', my_store._relpath('foo', ['gz', 'bar']))
229
238
def test__relpath_prefixed_suffixed(self):
230
239
my_store = store.TransportStore(MockTransport(), True)
240
my_store.register_suffix('gz')
241
my_store.register_suffix('bar')
231
242
self.assertEqual('45/foo.gz', my_store._relpath('foo', ['gz']))
232
243
self.assertEqual('45/foo.gz.bar',
233
244
my_store._relpath('foo', ['gz', 'bar']))
247
258
def test_add_simple_suffixed(self):
248
259
stream = StringIO("content")
249
260
my_store = InstrumentedTransportStore(MockTransport())
261
my_store.register_suffix('dsc')
250
262
my_store.add(stream, "foo", 'dsc')
251
263
self.assertEqual([("_add", "foo.dsc", stream)], my_store._calls)
253
265
def test_add_simple_suffixed(self):
254
266
stream = StringIO("content")
255
267
my_store = InstrumentedTransportStore(MockTransport(), True)
268
my_store.register_suffix('dsc')
256
269
my_store.add(stream, "foo", 'dsc')
257
270
self.assertEqual([("_add", "45/foo.dsc", stream)], my_store._calls)