~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-07-19 13:06:44 UTC
  • mfrom: (6030.2.7 locspec-to-url)
  • Revision ID: pqm@pqm.ubuntu.com-20110719130644-efx0i6dq30myjhmk
(jelmer) Split location to URL conversion out into a separate function from
 get_transport. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    transport,
28
28
    urlutils,
29
29
    )
 
30
from bzrlib.directory_service import directories
30
31
from bzrlib.transport import (
31
32
    chroot,
32
33
    fakenfs,
33
34
    http,
34
35
    local,
 
36
    location_to_url,
35
37
    memory,
36
38
    pathfilter,
37
39
    readonly,
993
995
        result = http.unhtml_roughly(fake_html)
994
996
        self.assertEquals(len(result), 1000)
995
997
        self.assertStartsWith(result, " something!")
 
998
 
 
999
 
 
1000
class SomeDirectory(object):
 
1001
 
 
1002
    def look_up(self, name, url):
 
1003
        return "http://bar"
 
1004
 
 
1005
 
 
1006
class TestLocationToUrl(tests.TestCase):
 
1007
 
 
1008
    def test_regular_url(self):
 
1009
        self.assertEquals("file://foo", location_to_url("file://foo"))
 
1010
 
 
1011
    def test_directory(self):
 
1012
        directories.register("bar:", SomeDirectory, "Dummy directory")
 
1013
        self.addCleanup(directories.remove, "bar:")
 
1014
        self.assertEquals("http://bar", location_to_url("bar:"))
 
1015
 
 
1016
    def test_unicode_url(self):
 
1017
        self.assertRaises(errors.InvalidURL, location_to_url,
 
1018
            "http://fo/\xc3\xaf".decode("utf-8"))
 
1019
 
 
1020
    def test_unicode_path(self):
 
1021
        self.assertEquals("file:///foo/bar%C3%AF",
 
1022
            location_to_url("/foo/bar\xc3\xaf".decode("utf-8")))
 
1023
 
 
1024
    def test_path(self):
 
1025
        self.assertEquals("file:///foo/bar", location_to_url("/foo/bar"))