55
55
from bzrlib.transport.memory import MemoryTransport
56
56
from bzrlib.transport.local import (LocalTransport,
57
57
EmulatedWin32LocalTransport)
58
from bzrlib.transport.remote import (
60
64
# TODO: Should possibly split transport-specific tests into their own files.
618
622
def test_parse_url(self):
619
623
t = ConnectedTransport('sftp://simple.example.com/home/source')
620
624
self.assertEquals(t._host, 'simple.example.com')
621
self.assertEquals(t._port, None)
625
self.assertEquals(t._port, 22)
622
626
self.assertEquals(t._path, '/home/source/')
623
627
self.failUnless(t._user is None)
624
628
self.failUnless(t._password is None)
713
717
self.assertIsNot(t1, t2)
720
class TestRemoteTCPTransport(TestCase):
721
"""Tests for bzr:// transport (RemoteTCPTransport)."""
723
def test_relpath_with_implicit_port(self):
724
"""Connected transports with the same URL are the same, even if the
727
So t.relpath(url) should always be '' if t.base is the same as url, or
728
if the only difference is that one explicitly specifies the default
729
port and the other doesn't specify a port.
731
t_implicit_port = RemoteTCPTransport('bzr://host.com/')
732
self.assertEquals('', t_implicit_port.relpath('bzr://host.com/'))
733
self.assertEquals('', t_implicit_port.relpath('bzr://host.com:4155/'))
734
t_explicit_port = RemoteTCPTransport('bzr://host.com:4155/')
735
self.assertEquals('', t_explicit_port.relpath('bzr://host.com/'))
736
self.assertEquals('', t_explicit_port.relpath('bzr://host.com:4155/'))
738
def test_construct_uses_default_port(self):
739
"""If no port is specified, then RemoteTCPTransport uses
742
t = get_transport('bzr://host.com/')
743
self.assertEquals(BZR_DEFAULT_PORT, t._port)
745
def test_url_omits_default_port(self):
746
"""If a RemoteTCPTransport uses the default port, then its base URL
749
This is like how ":80" is omitted from "http://example.com/".
751
t = get_transport('bzr://host.com:4155/')
752
self.assertEquals('bzr://host.com/', t.base)
754
def test_url_includes_non_default_port(self):
755
"""Non-default ports are included in the transport's URL.
757
Contrast this to `test_url_omits_default_port`.
759
t = get_transport('bzr://host.com:666/')
760
self.assertEquals('bzr://host.com:666/', t.base)
716
764
def get_test_permutations():
717
765
"""Return transport permutations to be used in testing.