222
223
def test_relpath(self):
223
224
from bzrlib.transport.sftp import SFTPTransport
224
from bzrlib.errors import NonRelativePath
225
from bzrlib.errors import PathNotChild
226
227
s = SFTPTransport('sftp://user@host.com//abs/path', clone_from=fake)
227
228
self.assertEquals(s.relpath('sftp://user@host.com//abs/path/sub'), 'sub')
228
229
# Can't test this one, because we actually get an AssertionError
229
230
# TODO: Consider raising an exception rather than an assert
230
#self.assertRaises(NonRelativePath, s.relpath, 'http://user@host.com//abs/path/sub')
231
self.assertRaises(NonRelativePath, s.relpath, 'sftp://user2@host.com//abs/path/sub')
232
self.assertRaises(NonRelativePath, s.relpath, 'sftp://user@otherhost.com//abs/path/sub')
233
self.assertRaises(NonRelativePath, s.relpath, 'sftp://user@host.com:33//abs/path/sub')
234
self.assertRaises(NonRelativePath, s.relpath, 'sftp://user@host.com/abs/path/sub')
231
#self.assertRaises(PathNotChild, s.relpath, 'http://user@host.com//abs/path/sub')
232
self.assertRaises(PathNotChild, s.relpath, 'sftp://user2@host.com//abs/path/sub')
233
self.assertRaises(PathNotChild, s.relpath, 'sftp://user@otherhost.com//abs/path/sub')
234
self.assertRaises(PathNotChild, s.relpath, 'sftp://user@host.com:33//abs/path/sub')
235
self.assertRaises(PathNotChild, s.relpath, 'sftp://user@host.com/abs/path/sub')
236
237
# Make sure it works when we don't supply a username
237
238
s = SFTPTransport('sftp://host.com//abs/path', clone_from=fake)
246
247
self.assertEquals(s.relpath('sftp://host.com/dev/%path/sub'), 'sub')
248
249
def test_parse_invalid_url(self):
249
from bzrlib.transport.sftp import SFTPTransport, SFTPTransportError
250
from bzrlib.transport.sftp import SFTPTransport, TransportError
251
252
s = SFTPTransport('sftp://lilypond.org:~janneke/public_html/bzr/gub',
253
254
self.fail('expected exception not raised')
254
except SFTPTransportError, e:
255
except TransportError, e:
255
256
self.assertEquals(str(e),
256
257
'~janneke: invalid port number')
276
277
self.failIf(os.path.lexists('.bzr/branch-lock.write-lock'))
279
def test_no_working_tree(self):
280
from bzrlib.branch import Branch
282
b = Branch.initialize(self._sftp_url)
283
self.assertRaises(errors.NoWorkingTree, b.working_tree)
285
def test_push_support(self):
286
from bzrlib.branch import Branch
289
self.build_tree(['a/', 'a/foo'])
290
b = Branch.initialize('a')
293
t.commit('foo', rev_id='a1')
296
b2 = Branch.initialize(self._sftp_url + 'b')
299
self.assertEquals(b2.revision_history(), ['a1'])
279
302
if not paramiko_loaded:
280
303
# TODO: Skip these