1
# Copyright (C) 2007-2010 Canonical Ltd
1
# Copyright (C) 2007, 2008 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
31
30
TestCaseWithMemoryTransport
32
from bzrlib.transport import get_transport
33
33
from bzrlib.plugins.launchpad import (
34
34
_register_directory,
37
37
from bzrlib.plugins.launchpad.lp_directory import (
38
38
LaunchpadDirectory)
39
from bzrlib.plugins.launchpad.account import get_lp_login, set_lp_login
39
from bzrlib.plugins.launchpad.account import get_lp_login
40
40
from bzrlib.tests import (
91
91
self.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
92
92
directory._resolve('lp:apt', factory))
93
93
# Make sure that resolve went to the production server.
94
self.assertEquals('https://xmlrpc.launchpad.net/bazaar/',
94
self.assertEquals('https://xmlrpc.edge.launchpad.net/bazaar/',
95
95
factory._service_url)
97
97
def test_staging(self):
199
199
self.assertRaises(errors.InvalidURL,
200
200
directory._resolve, 'lp://ratotehunoahu')
202
def test_resolve_tilde_to_user(self):
203
factory = FakeResolveFactory(
204
self, '~username/apt/test', dict(urls=[
205
'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))
206
directory = LaunchpadDirectory()
208
'bzr+ssh://bazaar.launchpad.net/~username/apt/test',
209
directory._resolve('lp:~/apt/test', factory, _lp_login='username'))
210
# Should also happen when the login is just set by config
211
set_lp_login('username')
213
'bzr+ssh://bazaar.launchpad.net/~username/apt/test',
214
directory._resolve('lp:~/apt/test', factory))
216
def test_tilde_fails_no_login(self):
217
factory = FakeResolveFactory(
218
self, '~username/apt/test', dict(urls=[
219
'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))
220
self.assertIs(None, get_lp_login())
221
directory = LaunchpadDirectory()
222
e = self.assertRaises(errors.InvalidURL,
223
directory._resolve, 'lp:~/apt/test', factory)
226
203
class DirectoryOpenBranchTests(TestCaseWithMemoryTransport):
240
217
directories.register('lp:', FooService, 'Map lp URLs to local urls')
241
218
self.addCleanup(_register_directory)
242
219
self.addCleanup(directories.remove, 'lp:')
243
t = transport.get_transport('lp:///apt')
244
branch = Branch.open_from_transport(t)
220
transport = get_transport('lp:///apt')
221
branch = Branch.open_from_transport(transport)
245
222
self.assertEqual(target_branch.base, branch.base)