~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_transport.py

  • Committer: Patch Queue Manager
  • Date: 2011-10-14 16:54:26 UTC
  • mfrom: (6216.1.1 remove-this-file)
  • Revision ID: pqm@pqm.ubuntu.com-20111014165426-tjix4e6idryf1r2z
(jelmer) Remove an accidentally committed .THIS file. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
from bzrlib.tests.test_transport import TestTransportImplementation
54
54
from bzrlib.transport import (
55
55
    ConnectedTransport,
56
 
    Transport,
57
56
    _get_transport_modules,
58
57
    )
59
58
from bzrlib.transport.memory import MemoryTransport
60
 
from bzrlib.transport.remote import RemoteTransport
61
59
 
62
60
 
63
61
def get_transport_test_permutations(module):
1793
1791
        transport = _mod_transport.get_transport_from_url(url)
1794
1792
        self.assertEquals(parameters, transport.get_segment_parameters())
1795
1793
 
1796
 
    def test_set_segment_parameters(self):
1797
 
        """Segment parameters can be set and show up in base."""
1798
 
        transport = self.get_transport("foo")
1799
 
        orig_base = transport.base
1800
 
        transport.set_segment_parameter("arm", "board")
1801
 
        self.assertEquals("%s,arm=board" % orig_base, transport.base)
1802
 
        self.assertEquals({"arm": "board"}, transport.get_segment_parameters())
1803
 
        transport.set_segment_parameter("arm", None)
1804
 
        transport.set_segment_parameter("nonexistant", None)
1805
 
        self.assertEquals({}, transport.get_segment_parameters())
1806
 
        self.assertEquals(orig_base, transport.base)
1807
 
 
1808
1794
    def test_stat_symlink(self):
1809
1795
        # if a transport points directly to a symlink (and supports symlinks
1810
1796
        # at all) you can tell this.  helps with bug 32669.
1816
1802
        t2 = t.clone('link')
1817
1803
        st = t2.stat('')
1818
1804
        self.assertTrue(stat.S_ISLNK(st.st_mode))
1819
 
 
1820
 
    def test_abspath_url_unquote_unreserved(self):
1821
 
        """URLs from abspath should have unreserved characters unquoted
1822
 
        
1823
 
        Need consistent quoting notably for tildes, see lp:842223 for more.
1824
 
        """
1825
 
        t = self.get_transport()
1826
 
        needlessly_escaped_dir = "%2D%2E%30%39%41%5A%5F%61%7A%7E/"
1827
 
        self.assertEqual(t.base + "-.09AZ_az~",
1828
 
            t.abspath(needlessly_escaped_dir))
1829
 
 
1830
 
    def test_clone_url_unquote_unreserved(self):
1831
 
        """Base URL of a cloned branch needs unreserved characters unquoted
1832
 
        
1833
 
        Cloned transports should be prefix comparable for things like the
1834
 
        isolation checking of tests, see lp:842223 for more.
1835
 
        """
1836
 
        t1 = self.get_transport()
1837
 
        needlessly_escaped_dir = "%2D%2E%30%39%41%5A%5F%61%7A%7E/"
1838
 
        self.build_tree([needlessly_escaped_dir], transport=t1)
1839
 
        t2 = t1.clone(needlessly_escaped_dir)
1840
 
        self.assertEqual(t1.base + "-.09AZ_az~/", t2.base)
1841
 
 
1842
 
    def test_hook_post_connection_one(self):
1843
 
        """Fire post_connect hook after a ConnectedTransport is first used"""
1844
 
        log = []
1845
 
        Transport.hooks.install_named_hook("post_connect", log.append, None)
1846
 
        t = self.get_transport()
1847
 
        self.assertEqual([], log)
1848
 
        t.has("non-existant")
1849
 
        if isinstance(t, RemoteTransport):
1850
 
            self.assertEqual([t.get_smart_medium()], log)
1851
 
        elif isinstance(t, ConnectedTransport):
1852
 
            self.assertEqual([t], log)
1853
 
        else:
1854
 
            self.assertEqual([], log)
1855
 
 
1856
 
    def test_hook_post_connection_multi(self):
1857
 
        """Fire post_connect hook once per unshared underlying connection"""
1858
 
        log = []
1859
 
        Transport.hooks.install_named_hook("post_connect", log.append, None)
1860
 
        t1 = self.get_transport()
1861
 
        t2 = t1.clone(".")
1862
 
        t3 = self.get_transport()
1863
 
        self.assertEqual([], log)
1864
 
        t1.has("x")
1865
 
        t2.has("x")
1866
 
        t3.has("x")
1867
 
        if isinstance(t1, RemoteTransport):
1868
 
            self.assertEqual([t.get_smart_medium() for t in [t1, t3]], log)
1869
 
        elif isinstance(t1, ConnectedTransport):
1870
 
            self.assertEqual([t1, t3], log)
1871
 
        else:
1872
 
            self.assertEqual([], log)