122
120
transport.get_transport_from_url('ssh://fooserver/foo')
123
121
except errors.UnsupportedProtocol as e:
124
self.assertEqual('Unsupported protocol'
125
' for url "ssh://fooserver/foo":'
126
' bzr supports bzr+ssh to operate over ssh,'
127
' use "bzr+ssh://fooserver/foo".',
123
'Unsupported protocol'
124
' for url "ssh://fooserver/foo":'
125
' Use bzr+ssh for Bazaar operations over SSH, '
126
'e.g. "bzr+ssh://fooserver/foo". Use git+ssh '
127
'for Git operations over SSH, e.g. "git+ssh://fooserver/foo".',
130
130
self.fail('Did not raise UnsupportedProtocol')
1107
1107
result = http.unhtml_roughly(fake_html)
1108
1108
self.assertEqual(len(result), 1000)
1109
1109
self.assertStartsWith(result, " something!")
1112
class SomeDirectory(object):
1114
def look_up(self, name, url):
1118
class TestLocationToUrl(tests.TestCase):
1120
def get_base_location(self):
1121
path = osutils.abspath('/foo/bar')
1122
if path.startswith('/'):
1123
url = 'file://%s' % (path,)
1125
# On Windows, abspaths start with the drive letter, so we have to
1126
# add in the extra '/'
1127
url = 'file:///%s' % (path,)
1130
def test_regular_url(self):
1131
self.assertEqual("file://foo", location_to_url("file://foo"))
1133
def test_directory(self):
1134
directories.register("bar:", SomeDirectory, "Dummy directory")
1135
self.addCleanup(directories.remove, "bar:")
1136
self.assertEqual("http://bar", location_to_url("bar:"))
1138
def test_unicode_url(self):
1139
self.assertRaises(urlutils.InvalidURL, location_to_url,
1140
b"http://fo/\xc3\xaf".decode("utf-8"))
1142
def test_unicode_path(self):
1143
path, url = self.get_base_location()
1144
location = path + b"\xc3\xaf".decode("utf-8")
1146
self.assertEqual(url, location_to_url(location))
1148
def test_path(self):
1149
path, url = self.get_base_location()
1150
self.assertEqual(url, location_to_url(path))
1152
def test_relative_file_url(self):
1153
self.assertEqual(urlutils.local_path_to_url(".") + "/bar",
1154
location_to_url("file:bar"))
1156
def test_absolute_file_url(self):
1157
self.assertEqual("file:///bar", location_to_url("file:/bar"))