84
87
service = LaunchpadService(lp_instance='staging')
85
88
self.assertEqual('http://example.com/',
86
89
service.service_url)
92
class TestURLInference(TestCase):
93
"""Test the way we infer Launchpad web pages from branch URLs."""
95
def test_default_bzr_ssh_url(self):
96
service = LaunchpadService()
97
web_url = service.get_web_url_from_branch_url(
98
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
100
'https://code.edge.launchpad.net/~foo/bar/baz', web_url)
102
def test_product_bzr_ssh_url(self):
103
service = LaunchpadService(lp_instance='production')
104
web_url = service.get_web_url_from_branch_url(
105
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
107
'https://code.launchpad.net/~foo/bar/baz', web_url)
109
def test_sftp_branch_url(self):
110
service = LaunchpadService(lp_instance='production')
111
web_url = service.get_web_url_from_branch_url(
112
'sftp://bazaar.launchpad.net/~foo/bar/baz')
114
'https://code.launchpad.net/~foo/bar/baz', web_url)
116
def test_staging_branch_url(self):
117
service = LaunchpadService(lp_instance='production')
118
web_url = service.get_web_url_from_branch_url(
119
'bzr+ssh://bazaar.staging.launchpad.net/~foo/bar/baz')
121
'https://code.launchpad.net/~foo/bar/baz', web_url)
123
def test_non_launchpad_url(self):
124
service = LaunchpadService()
125
error = self.assertRaises(
126
NotLaunchpadBranch, service.get_web_url_from_branch_url,
127
'bzr+ssh://example.com/~foo/bar/baz')
129
'bzr+ssh://example.com/~foo/bar/baz is not hosted on Launchpad.',
132
def test_dodgy_launchpad_url(self):
133
service = LaunchpadService()
135
NotLaunchpadBranch, service.get_web_url_from_branch_url,
136
'bzr+ssh://launchpad.net/~foo/bar/baz')
138
def test_lp_branch_url(self):
139
service = LaunchpadService(lp_instance='production')
140
factory = FakeResolveFactory(
141
self, '~foo/bar/baz',
142
dict(urls=['http://bazaar.launchpad.net/~foo/bar/baz']))
143
web_url = service.get_web_url_from_branch_url(
144
'lp:~foo/bar/baz', factory)
146
'https://code.launchpad.net/~foo/bar/baz', web_url)
148
def test_lp_branch_shortcut(self):
149
service = LaunchpadService()
150
factory = FakeResolveFactory(
152
dict(urls=['http://bazaar.launchpad.net/~foo/bar/baz']))
153
web_url = service.get_web_url_from_branch_url('lp:foo', factory)
155
'https://code.edge.launchpad.net/~foo/bar/baz', web_url)
157
def test_lp_branch_fault(self):
158
service = LaunchpadService()
159
factory = FakeResolveFactory(self, 'foo', None)
161
raise xmlrpclib.Fault(42, 'something went wrong')
162
factory.submit = submit
164
errors.InvalidURL, service.get_web_url_from_branch_url, 'lp:foo',
167
def test_staging_url(self):
168
service = LaunchpadService(lp_instance='staging')
169
web_url = service.get_web_url_from_branch_url(
170
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
172
'https://code.staging.launchpad.net/~foo/bar/baz', web_url)
174
def test_edge_url(self):
175
service = LaunchpadService(lp_instance='edge')
176
web_url = service.get_web_url_from_branch_url(
177
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
179
'https://code.edge.launchpad.net/~foo/bar/baz', web_url)
181
def test_dev_url(self):
182
service = LaunchpadService(lp_instance='dev')
183
web_url = service.get_web_url_from_branch_url(
184
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
186
'https://code.launchpad.dev/~foo/bar/baz', web_url)
188
def test_demo_url(self):
189
service = LaunchpadService(lp_instance='demo')
190
web_url = service.get_web_url_from_branch_url(
191
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
193
'https://code.demo.launchpad.net/~foo/bar/baz', web_url)