~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

Merge more bzr.dev, addressing some bugs. [still broken]

Show diffs side-by-side

added added

removed removed

Lines of Context:
229
229
 
230
230
        self.assertRaises(NoSuchFile, t.get_bytes, 'c')
231
231
 
232
 
    def test_get_with_open_file_stream_sees_all_content(self):
 
232
    def test_get_with_open_write_stream_sees_all_content(self):
233
233
        t = self.get_transport()
234
234
        if t.is_readonly():
235
235
            return
236
 
        handle = t.open_file_stream('foo')
 
236
        handle = t.open_write_stream('foo')
237
237
        try:
238
 
            handle('b')
 
238
            handle.write('b')
239
239
            self.assertEqual('b', t.get('foo').read())
240
240
        finally:
241
 
            t.close_file_stream('foo')
 
241
            handle.close()
242
242
 
243
 
    def test_get_bytes_with_open_file_stream_sees_all_content(self):
 
243
    def test_get_bytes_with_open_write_stream_sees_all_content(self):
244
244
        t = self.get_transport()
245
245
        if t.is_readonly():
246
246
            return
247
 
        handle = t.open_file_stream('foo')
 
247
        handle = t.open_write_stream('foo')
248
248
        try:
249
 
            handle('b')
 
249
            handle.write('b')
250
250
            self.assertEqual('b', t.get_bytes('foo'))
251
251
            self.assertEqual('b', t.get('foo').read())
252
252
        finally:
253
 
            t.close_file_stream('foo')
 
253
            handle.close()
254
254
 
255
255
    def test_put_bytes(self):
256
256
        t = self.get_transport()
583
583
        t = self.get_transport()
584
584
        if t.is_readonly():
585
585
            return
586
 
        handle = t.open_file_stream('foo')
 
586
        handle = t.open_write_stream('foo')
587
587
        try:
588
588
            self.assertEqual('', t.get_bytes('foo'))
589
589
        finally:
590
 
            t.close_file_stream('foo')
 
590
            handle.close()
591
591
 
592
592
    def test_opening_a_file_stream_can_set_mode(self):
593
593
        t = self.get_transport()
597
597
            # Can't roundtrip, so no need to run this test
598
598
            return
599
599
        def check_mode(name, mode, expected):
600
 
            handle = t.open_file_stream(name, mode=mode)
601
 
            t.close_file_stream(name)
 
600
            handle = t.open_write_stream(name, mode=mode)
 
601
            handle.close()
602
602
            self.assertTransportMode(t, name, expected)
603
603
        check_mode('mode644', 0644, 0644)
604
604
        check_mode('mode666', 0666, 0666)
1485
1485
        self.assertEqual(d[2], (0, '0'))
1486
1486
        self.assertEqual(d[3], (3, '34'))
1487
1487
 
1488
 
    def test_get_with_open_file_stream_sees_all_content(self):
 
1488
    def test_get_with_open_write_stream_sees_all_content(self):
1489
1489
        t = self.get_transport()
1490
1490
        if t.is_readonly():
1491
1491
            return
1492
 
        handle = t.open_file_stream('foo')
 
1492
        handle = t.open_write_stream('foo')
1493
1493
        try:
1494
 
            handle('bcd')
 
1494
            handle.write('bcd')
1495
1495
            self.assertEqual([(0, 'b'), (2, 'd')], list(t.readv('foo', ((0,1), (2,1)))))
1496
1496
        finally:
1497
 
            t.close_file_stream('foo')
 
1497
            handle.close()
1498
1498
 
1499
1499
    def test_get_smart_medium(self):
1500
1500
        """All transports must either give a smart medium, or know they can't.