224
224
def test_relpath(self):
225
225
from bzrlib.transport.sftp import SFTPTransport
226
from bzrlib.errors import NonRelativePath
226
from bzrlib.errors import PathNotChild
228
228
s = SFTPTransport('sftp://user@host.com//abs/path', clone_from=fake)
229
229
self.assertEquals(s.relpath('sftp://user@host.com//abs/path/sub'), 'sub')
230
230
# Can't test this one, because we actually get an AssertionError
231
231
# TODO: Consider raising an exception rather than an assert
232
#self.assertRaises(NonRelativePath, s.relpath, 'http://user@host.com//abs/path/sub')
233
self.assertRaises(NonRelativePath, s.relpath, 'sftp://user2@host.com//abs/path/sub')
234
self.assertRaises(NonRelativePath, s.relpath, 'sftp://user@otherhost.com//abs/path/sub')
235
self.assertRaises(NonRelativePath, s.relpath, 'sftp://user@host.com:33//abs/path/sub')
236
self.assertRaises(NonRelativePath, s.relpath, 'sftp://user@host.com/abs/path/sub')
232
#self.assertRaises(PathNotChild, s.relpath, 'http://user@host.com//abs/path/sub')
233
self.assertRaises(PathNotChild, s.relpath, 'sftp://user2@host.com//abs/path/sub')
234
self.assertRaises(PathNotChild, s.relpath, 'sftp://user@otherhost.com//abs/path/sub')
235
self.assertRaises(PathNotChild, s.relpath, 'sftp://user@host.com:33//abs/path/sub')
236
self.assertRaises(PathNotChild, s.relpath, 'sftp://user@host.com/abs/path/sub')
238
238
# Make sure it works when we don't supply a username
239
239
s = SFTPTransport('sftp://host.com//abs/path', clone_from=fake)
248
248
self.assertEquals(s.relpath('sftp://host.com/dev/%path/sub'), 'sub')
250
250
def test_parse_invalid_url(self):
251
from bzrlib.transport.sftp import SFTPTransport, SFTPTransportError
251
from bzrlib.transport.sftp import SFTPTransport, TransportError
253
253
s = SFTPTransport('sftp://lilypond.org:~janneke/public_html/bzr/gub',
255
255
self.fail('expected exception not raised')
256
except SFTPTransportError, e:
256
except TransportError, e:
257
257
self.assertEquals(str(e),
258
258
'~janneke: invalid port number')