593
594
t = t.clone('..')
594
595
self.assertEquals(t.base, 'file://HOST/')
597
class TestConnectedTransport(TestCase):
598
"""Tests for connected to remote server transports"""
600
def test_parse_url(self):
601
t = ConnectedTransport('sftp://simple.example.com/home/source')
602
self.assertEquals(t._host, 'simple.example.com')
603
self.assertEquals(t._port, None)
604
self.assertEquals(t._path, '/home/source/')
605
self.failUnless(t._user is None)
606
self.failUnless(t._password is None)
608
self.assertEquals(t.base, 'sftp://simple.example.com/home/source/')
610
def test_parse_quoted_url(self):
611
t = ConnectedTransport('http://ro%62ey:h%40t@ex%41mple.com:2222/path')
612
self.assertEquals(t._host, 'exAmple.com')
613
self.assertEquals(t._port, 2222)
614
self.assertEquals(t._user, 'robey')
615
self.assertEquals(t._password, 'h@t')
616
self.assertEquals(t._path, '/path/')
618
# Base should not keep track of the password
619
self.assertEquals(t.base, 'http://robey@exAmple.com:2222/path/')
621
def test_parse_invalid_url(self):
622
self.assertRaises(errors.InvalidURL,
624
'sftp://lily.org:~janneke/public/bzr/gub')
626
def test_relpath(self):
627
t = ConnectedTransport('sftp://user@host.com/abs/path')
629
self.assertEquals(t.relpath('sftp://user@host.com/abs/path/sub'), 'sub')
630
self.assertRaises(errors.PathNotChild, t.relpath,
631
'http://user@host.com/abs/path/sub')
632
self.assertRaises(errors.PathNotChild, t.relpath,
633
'sftp://user2@host.com/abs/path/sub')
634
self.assertRaises(errors.PathNotChild, t.relpath,
635
'sftp://user@otherhost.com/abs/path/sub')
636
self.assertRaises(errors.PathNotChild, t.relpath,
637
'sftp://user@host.com:33/abs/path/sub')
638
# Make sure it works when we don't supply a username
639
t = ConnectedTransport('sftp://host.com/abs/path')
640
self.assertEquals(t.relpath('sftp://host.com/abs/path/sub'), 'sub')
642
# Make sure it works when parts of the path will be url encoded
643
t = ConnectedTransport('sftp://host.com/dev/%path')
644
self.assertEquals(t.relpath('sftp://host.com/dev/%path/sub'), 'sub')
597
647
class TestReusedTransports(TestCase):
648
"""Tests for transport reuse"""
599
650
def test_reuse_same_transport(self):
600
651
t = get_transport('http://foo/')