/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

  • Committer: Martin Pool
  • Date: 2007-10-03 05:25:50 UTC
  • mfrom: (2814.6.5 0.91)
  • mto: This revision was merged to the branch mainline in revision 2881.
  • Revision ID: mbp@sourcefrog.net-20071003052550-lqew94cmeb1oqfpp
Preparing to merge 0.91 back into trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 (
 
59
    BZR_DEFAULT_PORT,
 
60
    RemoteTCPTransport
 
61
    )
58
62
 
59
63
 
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)
714
718
 
715
719
 
 
720
class TestRemoteTCPTransport(TestCase):
 
721
    """Tests for bzr:// transport (RemoteTCPTransport)."""
 
722
 
 
723
    def test_relpath_with_implicit_port(self):
 
724
        """Connected transports with the same URL are the same, even if the
 
725
        port is implicit.
 
726
 
 
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.
 
730
        """
 
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/'))
 
737
 
 
738
    def test_construct_uses_default_port(self):
 
739
        """If no port is specified, then RemoteTCPTransport uses
 
740
        BZR_DEFAULT_PORT.
 
741
        """
 
742
        t = get_transport('bzr://host.com/')
 
743
        self.assertEquals(BZR_DEFAULT_PORT, t._port)
 
744
 
 
745
    def test_url_omits_default_port(self):
 
746
        """If a RemoteTCPTransport uses the default port, then its base URL
 
747
        will omit the port.
 
748
 
 
749
        This is like how ":80" is omitted from "http://example.com/".
 
750
        """
 
751
        t = get_transport('bzr://host.com:4155/')
 
752
        self.assertEquals('bzr://host.com/', t.base)
 
753
 
 
754
    def test_url_includes_non_default_port(self):
 
755
        """Non-default ports are included in the transport's URL.
 
756
 
 
757
        Contrast this to `test_url_omits_default_port`.
 
758
        """
 
759
        t = get_transport('bzr://host.com:666/')
 
760
        self.assertEquals('bzr://host.com:666/', t.base)
 
761
 
 
762
 
 
763
 
716
764
def get_test_permutations():
717
765
    """Return transport permutations to be used in testing.
718
766