~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_store.py

  • Committer: John Arbash Meinel
  • Date: 2009-02-23 15:29:35 UTC
  • mfrom: (3943.7.7 bzr.code_style_cleanup)
  • mto: This revision was merged to the branch mainline in revision 4033.
  • Revision ID: john@arbash-meinel.com-20090223152935-oel9m92mwcc6nb4h
Merge the removal of all trailing whitespace, and resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
    def test_get(self):
65
65
        store = self.get_store()
66
66
        self.fill_store(store)
67
 
    
 
67
 
68
68
        self.check_content(store, 'a', 'hello')
69
69
        self.check_content(store, 'b', 'other')
70
70
        self.check_content(store, 'c', 'something')
71
 
    
 
71
 
72
72
        # Make sure that requesting a non-existing file fails
73
73
        self.assertRaises(KeyError, self.check_content, store, 'd', None)
74
74
 
92
92
        store.add(StringIO('goodbye2'), '123123', 'dsc')
93
93
        # these get gzipped - content should be stable
94
94
        self.assertEqual(store.total_size(), (2, 55))
95
 
        
 
95
 
96
96
    def test__relpath_suffixed(self):
97
97
        my_store = TextStore(MockTransport(),
98
98
                             prefixed=True, compressed=True)
101
101
 
102
102
 
103
103
class TestMemoryStore(TestCase):
104
 
    
 
104
 
105
105
    def get_store(self):
106
106
        return TextStore(MemoryTransport())
107
 
    
 
107
 
108
108
    def test_add_and_retrieve(self):
109
109
        store = self.get_store()
110
110
        store.add(StringIO('hello'), 'aa')
174
174
        self.assertEquals(s.has_id('a'), True)
175
175
        self.assertEquals(cs.get('a').read(), 'hello there')
176
176
        self.assertEquals(s.get('a').read(), 'hello there')
177
 
        
 
177
 
178
178
        self.assertRaises(BzrError, s.add, StringIO('goodbye'), 'a')
179
179
 
180
180
        s.add(StringIO('goodbye'), 'b')
186
186
        self.assertEquals(s.has_id('b'), True)
187
187
        self.assertEquals(cs.get('b').read(), 'goodbye')
188
188
        self.assertEquals(s.get('b').read(), 'goodbye')
189
 
        
 
189
 
190
190
        self.assertRaises(BzrError, cs.add, StringIO('again'), 'b')
191
191
 
192
192
class MockTransport(transport.Transport):
240
240
 
241
241
 
242
242
class TestTransportStore(TestCase):
243
 
    
 
243
 
244
244
    def test__relpath_invalid(self):
245
245
        my_store = store.TransportStore(MockTransport())
246
246
        self.assertRaises(ValueError, my_store._relpath, '/foo')
297
297
        my_store.register_suffix('dsc')
298
298
        my_store.add(stream, "foo", 'dsc')
299
299
        self.assertEqual([("_add", "foo.dsc", stream)], my_store._calls)
300
 
        
 
300
 
301
301
    def test_add_simple_suffixed(self):
302
302
        stream = StringIO("content")
303
303
        my_store = InstrumentedTransportStore(MockTransport(), True)
317
317
        stream = StringIO("signature for missing base")
318
318
        my_store.add(stream, "missing", 'sig')
319
319
        return my_store
320
 
        
 
320
 
321
321
    def test_has_simple(self):
322
322
        my_store = self.get_populated_store()
323
323
        self.assertEqual(True, my_store.has_id('foo'))