230
230
self.assertRaises(NoSuchFile, t.get_bytes, 'c')
232
def test_get_with_open_write_stream_sees_all_content(self):
233
t = self.get_transport()
236
handle = t.open_write_stream('foo')
239
self.assertEqual('b', t.get('foo').read())
243
def test_get_bytes_with_open_write_stream_sees_all_content(self):
244
t = self.get_transport()
247
handle = t.open_write_stream('foo')
250
self.assertEqual('b', t.get_bytes('foo'))
251
self.assertEqual('b', t.get('foo').read())
232
255
def test_put_bytes(self):
233
256
t = self.get_transport()
556
579
t.mkdir('dnomode', mode=None)
557
580
self.assertTransportMode(t, 'dnomode', 0777 & ~umask)
582
def test_opening_a_file_stream_creates_file(self):
583
t = self.get_transport()
586
handle = t.open_write_stream('foo')
588
self.assertEqual('', t.get_bytes('foo'))
592
def test_opening_a_file_stream_can_set_mode(self):
593
t = self.get_transport()
596
if not t._can_roundtrip_unix_modebits():
597
# Can't roundtrip, so no need to run this test
599
def check_mode(name, mode, expected):
600
handle = t.open_write_stream(name, mode=mode)
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())
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('.'))
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)
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'))
1488
def test_get_with_open_write_stream_sees_all_content(self):
1489
t = self.get_transport()
1492
handle = t.open_write_stream('foo')
1495
self.assertEqual([(0, 'b'), (2, 'd')], list(t.readv('foo', ((0,1), (2,1)))))
1433
1499
def test_get_smart_medium(self):
1434
1500
"""All transports must either give a smart medium, or know they can't.