~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport_implementations.py

Merge bzr.dev

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_write_stream_sees_all_content(self):
 
233
        t = self.get_transport()
 
234
        if t.is_readonly():
 
235
            return
 
236
        handle = t.open_write_stream('foo')
 
237
        try:
 
238
            handle.write('b')
 
239
            self.assertEqual('b', t.get('foo').read())
 
240
        finally:
 
241
            handle.close()
 
242
 
 
243
    def test_get_bytes_with_open_write_stream_sees_all_content(self):
 
244
        t = self.get_transport()
 
245
        if t.is_readonly():
 
246
            return
 
247
        handle = t.open_write_stream('foo')
 
248
        try:
 
249
            handle.write('b')
 
250
            self.assertEqual('b', t.get_bytes('foo'))
 
251
            self.assertEqual('b', t.get('foo').read())
 
252
        finally:
 
253
            handle.close()
 
254
 
232
255
    def test_put_bytes(self):
233
256
        t = self.get_transport()
234
257
 
556
579
        t.mkdir('dnomode', mode=None)
557
580
        self.assertTransportMode(t, 'dnomode', 0777 & ~umask)
558
581
 
 
582
    def test_opening_a_file_stream_creates_file(self):
 
583
        t = self.get_transport()
 
584
        if t.is_readonly():
 
585
            return
 
586
        handle = t.open_write_stream('foo')
 
587
        try:
 
588
            self.assertEqual('', t.get_bytes('foo'))
 
589
        finally:
 
590
            handle.close()
 
591
 
 
592
    def test_opening_a_file_stream_can_set_mode(self):
 
593
        t = self.get_transport()
 
594
        if t.is_readonly():
 
595
            return
 
596
        if not t._can_roundtrip_unix_modebits():
 
597
            # Can't roundtrip, so no need to run this test
 
598
            return
 
599
        def check_mode(name, mode, expected):
 
600
            handle = t.open_write_stream(name, mode=mode)
 
601
            handle.close()
 
602
            self.assertTransportMode(t, name, expected)
 
603
        check_mode('mode644', 0644, 0644)
 
604
        check_mode('mode666', 0666, 0666)
 
605
        check_mode('mode600', 0600, 0600)
 
606
        # The default permissions should be based on the current umask
 
607
        check_mode('nomode', None, 0666 & ~osutils.get_umask())
 
608
 
559
609
    def test_copy_to(self):
560
610
        # FIXME: test:   same server to same server (partly done)
561
611
        # same protocol two servers
769
819
        # plain "listdir".
770
820
        # self.assertEqual([], os.listdir('.'))
771
821
 
 
822
    def test_recommended_page_size(self):
 
823
        """Transports recommend a page size for partial access to files."""
 
824
        t = self.get_transport()
 
825
        self.assertIsInstance(t.recommended_page_size(), int)
 
826
 
772
827
    def test_rmdir(self):
773
828
        t = self.get_transport()
774
829
        # Not much to do with a readonly transport
1430
1485
        self.assertEqual(d[2], (0, '0'))
1431
1486
        self.assertEqual(d[3], (3, '34'))
1432
1487
 
 
1488
    def test_get_with_open_write_stream_sees_all_content(self):
 
1489
        t = self.get_transport()
 
1490
        if t.is_readonly():
 
1491
            return
 
1492
        handle = t.open_write_stream('foo')
 
1493
        try:
 
1494
            handle.write('bcd')
 
1495
            self.assertEqual([(0, 'b'), (2, 'd')], list(t.readv('foo', ((0,1), (2,1)))))
 
1496
        finally:
 
1497
            handle.close()
 
1498
 
1433
1499
    def test_get_smart_medium(self):
1434
1500
        """All transports must either give a smart medium, or know they can't.
1435
1501
        """