144
144
t.put, 'b', StringIO('file-like\ncontents\n'))
145
145
self.check_transport_contents('file-like\ncontents\n', t, 'b')
147
self.assertRaises(NoSuchFile,
148
t.put, 'path/doesnt/exist/c', StringIO('contents'))
147
150
def test_put_bytes(self):
148
151
t = self.get_transport()
400
403
self.check_transport_contents('diff\ncontents for\na\n', t, 'a')
401
404
self.check_transport_contents('another contents\nfor d\n', t, 'd')
406
def test_put_permissions(self):
407
t = self.get_transport()
411
if not t._can_roundtrip_unix_modebits():
412
# Can't roundtrip, so no need to run this test
414
self.applyDeprecated(zero_eleven, t.put, 'mode644',
415
StringIO('test text\n'), mode=0644)
416
self.assertTransportMode(t, 'mode644', 0644)
417
self.applyDeprecated(zero_eleven, t.put, 'mode666',
418
StringIO('test text\n'), mode=0666)
419
self.assertTransportMode(t, 'mode666', 0666)
420
self.applyDeprecated(zero_eleven, t.put, 'mode600',
421
StringIO('test text\n'), mode=0600)
422
self.assertTransportMode(t, 'mode600', 0600)
423
# Yes, you can put a file such that it becomes readonly
424
self.applyDeprecated(zero_eleven, t.put, 'mode400',
425
StringIO('test text\n'), mode=0400)
426
self.assertTransportMode(t, 'mode400', 0400)
427
self.applyDeprecated(zero_eleven, t.put_multi,
428
[('mmode644', StringIO('text\n'))], mode=0644)
429
self.assertTransportMode(t, 'mmode644', 0644)
431
# The default permissions should be based on the current umask
432
umask = osutils.get_umask()
433
self.applyDeprecated(zero_eleven, t.put, 'nomode',
434
StringIO('test text\n'), mode=None)
435
self.assertTransportMode(t, 'nomode', 0666 & ~umask)
403
437
def test_mkdir(self):
404
438
t = self.get_transport()
998
1032
self.failUnless(t2.has('d'))
999
1033
self.failUnless(t3.has('b/d'))
1035
def test_clone_to_root(self):
1036
orig_transport = self.get_transport()
1037
# Repeatedly go up to a parent directory until we're at the root
1038
# directory of this transport
1039
root_transport = orig_transport
1040
while root_transport.clone("..").base != root_transport.base:
1041
root_transport = root_transport.clone("..")
1043
# Cloning to "/" should take us to exactly the same location.
1044
self.assertEqual(root_transport.base, orig_transport.clone("/").base)
1046
# At the root, the URL must still end with / as its a directory
1047
self.assertEqual(root_transport.base[-1], '/')
1049
def test_clone_from_root(self):
1050
"""At the root, cloning to a simple dir should just do string append."""
1051
orig_transport = self.get_transport()
1052
root_transport = orig_transport.clone('/')
1053
self.assertEqual(root_transport.base + '.bzr/',
1054
root_transport.clone('.bzr').base)
1056
def test_base_url(self):
1057
t = self.get_transport()
1058
self.assertEqual('/', t.base[-1])
1001
1060
def test_relpath(self):
1002
1061
t = self.get_transport()
1003
1062
self.assertEqual('', t.relpath(t.base))
1031
1090
self.assertEqual(transport.base + 'relpath',
1032
1091
transport.abspath('relpath'))
1093
# This should work without raising an error.
1094
transport.abspath("/")
1096
# the abspath of "/" and "/foo/.." should result in the same location
1097
self.assertEqual(transport.abspath("/"), transport.abspath("/foo/.."))
1034
1099
def test_local_abspath(self):
1035
1100
transport = self.get_transport()