~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/teststore.py

  • Committer: Robert Collins
  • Date: 2005-10-17 00:46:10 UTC
  • mto: This revision was merged to the branch mainline in revision 1459.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051017004610-6130019f89a92d04
teach iter about suffixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
270
270
        my_store.add(stream, "foo", 'dsc')
271
271
        self.assertEqual([("_add", "45/foo.dsc", stream)], my_store._calls)
272
272
 
273
 
    def get_populated_store(self, prefixed=False):
274
 
        my_store = TextStore(MemoryTransport(), prefixed)
 
273
    def get_populated_store(self, prefixed=False, store_class=TextStore):
 
274
        my_store = store_class(MemoryTransport(), prefixed)
275
275
        my_store.register_suffix('sig')
276
276
        stream = StringIO("signature")
277
277
        my_store.add(stream, "foo", 'sig')
318
318
        my_store = self.get_populated_store(True)
319
319
        self.assertEqual('signature for missing base',
320
320
                         my_store.get('missing', 'sig').read())
 
321
 
 
322
    def test___iter__no_suffix(self):
 
323
        my_store = TextStore(MemoryTransport(), False)
 
324
        stream = StringIO("content")
 
325
        my_store.add(stream, "foo")
 
326
        self.assertEqual(set(['foo']),
 
327
                         set(my_store.__iter__()))
 
328
 
 
329
    def test___iter__(self):
 
330
        self.assertEqual(set(['foo']),
 
331
                         set(self.get_populated_store().__iter__()))
 
332
        self.assertEqual(set(['foo']),
 
333
                         set(self.get_populated_store(True).__iter__()))
 
334
 
 
335
    def test___iter__compressed(self):
 
336
        self.assertEqual(set(['foo']),
 
337
                         set(self.get_populated_store(
 
338
                             store_class=CompressedTextStore).__iter__()))
 
339
        self.assertEqual(set(['foo']),
 
340
                         set(self.get_populated_store(
 
341
                             True, CompressedTextStore).__iter__()))
 
342
 
 
343
    def test___len__(self):
 
344
        self.assertEqual(1, len(self.get_populated_store()))