1
# Copyright (C) 2004, 2005, 2006, 2007 Canonical Ltd
1
# Copyright (C) 2005-2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
79
80
permutations = get_transport_test_permutations(
80
81
reduce(getattr, (module).split('.')[1:], __import__(module)))
81
82
for (klass, server_factory) in permutations:
82
scenario = (server_factory.__name__,
83
scenario = ('%s,%s' % (klass.__name__, server_factory.__name__),
83
84
{"transport_class":klass,
84
85
"transport_server":server_factory})
85
86
result.append(scenario)
170
171
self.assertEqual(True, t.has_any(['b', 'b', 'b']))
172
173
def test_has_root_works(self):
173
from bzrlib.smart import server
174
if self.transport_server is server.SmartTCPServer_for_testing:
174
if self.transport_server is test_server.SmartTCPServer_for_testing:
175
175
raise TestNotApplicable(
176
176
"SmartTCPServer_for_testing intentionally does not allow "
1083
1082
subdir.stat('./file')
1084
1083
subdir.stat('.')
1085
def test_hardlink(self):
1086
from stat import ST_NLINK
1088
t = self.get_transport()
1090
source_name = "original_target"
1091
link_name = "target_link"
1093
self.build_tree([source_name], transport=t)
1096
t.hardlink(source_name, link_name)
1098
self.failUnless(t.has(source_name))
1099
self.failUnless(t.has(link_name))
1101
st = t.stat(link_name)
1102
self.failUnlessEqual(st[ST_NLINK], 2)
1103
except TransportNotPossible:
1104
raise TestSkipped("Transport %s does not support hardlinks." %
1105
self._server.__class__)
1107
def test_symlink(self):
1108
from stat import S_ISLNK
1110
t = self.get_transport()
1112
source_name = "original_target"
1113
link_name = "target_link"
1115
self.build_tree([source_name], transport=t)
1118
t.symlink(source_name, link_name)
1120
self.failUnless(t.has(source_name))
1121
self.failUnless(t.has(link_name))
1123
st = t.stat(link_name)
1124
self.failUnless(S_ISLNK(st.st_mode),
1125
"expected symlink, got mode %o" % st.st_mode)
1126
except TransportNotPossible:
1127
raise TestSkipped("Transport %s does not support symlinks." %
1128
self._server.__class__)
1130
raise tests.KnownFailure("Paramiko fails to create symlinks during tests")
1086
1132
def test_list_dir(self):
1087
1133
# TODO: Test list_dir, just try once, and if it throws, stop testing
1088
1134
t = self.get_transport()
1219
1265
self.assertIs(t._get_connection(), c._get_connection())
1221
1267
# Temporary failure, we need to create a new dummy connection
1222
new_connection = object()
1268
new_connection = None
1223
1269
t._set_connection(new_connection)
1224
1270
# Check that both transports use the same connection
1225
1271
self.assertIs(new_connection, t._get_connection())
1497
1543
u'\u65e5', # Kanji person
1546
no_unicode_support = getattr(self._server, 'no_unicode_support', False)
1547
if no_unicode_support:
1548
raise tests.KnownFailure("test server cannot handle unicode paths")
1501
1551
self.build_tree(files, transport=t, line_endings='binary')
1502
1552
except UnicodeError:
1715
1765
# also raise a special error
1716
1766
self.assertListRaises((errors.ShortReadvError, errors.InvalidRange),
1717
1767
transport.readv, 'a', [(12,2)])
1769
def test_stat_symlink(self):
1770
# if a transport points directly to a symlink (and supports symlinks
1771
# at all) you can tell this. helps with bug 32669.
1772
t = self.get_transport()
1774
t.symlink('target', 'link')
1775
except TransportNotPossible:
1776
raise TestSkipped("symlinks not supported")
1777
t2 = t.clone('link')
1779
self.assertTrue(stat.S_ISLNK(st.st_mode))