def test_url_from_directory(self): """A launchpad url should map to a http url""" factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'http://bazaar.launchpad.net/~apt/apt/devel'])) directory = LaunchpadDirectory() self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', directory._resolve('lp:///apt', factory))
def test_tilde_fails_no_login(self): factory = FakeResolveFactory( self, '~username/apt/test', dict(urls=[ 'bzr+ssh://bazaar.launchpad.net/~username/apt/test'])) self.assertIs(None, get_lp_login()) directory = LaunchpadDirectory() self.assertRaises(errors.InvalidURL, directory._resolve, 'lp:~/apt/test', factory)
def assertResolve(self, expected, url, submitted=False): path = url[url.index(':')+1:].lstrip('/') factory = FakeResolveFactory(self, path, dict(urls=['bzr+ssh://fake-resolved'])) directory = LaunchpadDirectory() self.assertEqual(expected, directory._resolve(url, factory, _lp_login='******')) # We are testing local resolution, and the fallback when necessary. self.assertEqual(submitted, factory._submitted)
def test_directory_fault(self): # Test that XMLRPC faults get converted to InvalidURL errors. factory = FakeResolveFactory(self, 'apt', None) def submit(service): raise xmlrpclib.Fault(42, 'something went wrong') factory.submit = submit directory = LaunchpadDirectory() self.assertRaises(errors.InvalidURL, directory._resolve, 'lp:///apt', factory)
def test_directory_no_matching_schemes(self): # If the XMLRPC call does not return any protocols we support, # invalidURL is raised. factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'bad-scheme://bazaar.launchpad.net/~apt/apt/devel'])) directory = LaunchpadDirectory() self.assertRaises(errors.InvalidURL, directory._resolve, 'lp:///apt', factory)
def test_directory_skip_bad_schemes(self): factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'bad-scheme://bazaar.launchpad.net/~apt/apt/devel', 'http://bazaar.launchpad.net/~apt/apt/devel', 'http://another/location'])) directory = LaunchpadDirectory() self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', directory._resolve('lp:///apt', factory))
def test_no_rewrite_of_other_bzr_ssh(self): # Test that we don't rewrite bzr+ssh URLs for other self.assertEqual(None, get_lp_login()) factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'bzr+ssh://example.com/~apt/apt/devel', 'http://bazaar.launchpad.net/~apt/apt/devel'])) directory = LaunchpadDirectory() self.assertEqual('bzr+ssh://example.com/~apt/apt/devel', directory._resolve('lp:///apt', factory))
def test_with_login_avoid_resolve_factory(self): # Test that bzr+ssh URLs get rewritten to include the user's # Launchpad ID (assuming we know the Launchpad ID). factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'bzr+ssh://my-super-custom/special/devel', 'http://bazaar.launchpad.net/~apt/apt/devel'])) directory = LaunchpadDirectory() self.assertEqual( 'bzr+ssh://bazaar.launchpad.net/+branch/apt', directory._resolve('lp:///apt', factory, _lp_login='******'))
def test_skip_sftp_launchpad_net_when_anonymous(self): # Test that sftp://bazaar.launchpad.net gets skipped if # Bazaar does not know the user's Launchpad ID: self.assertEqual(None, get_lp_login()) factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'sftp://bazaar.launchpad.net/~apt/apt/devel', 'http://bazaar.launchpad.net/~apt/apt/devel'])) directory = LaunchpadDirectory() self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', directory._resolve('lp:///apt', factory))
def test_short_form(self): """A launchpad url should map to a http url""" factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'http://bazaar.launchpad.net/~apt/apt/devel'])) directory = LaunchpadDirectory() self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', directory._resolve('lp:apt', factory)) # Make sure that resolve went to the production server. self.assertEqual('https://xmlrpc.launchpad.net/bazaar/', factory._service_url)
def test_staging(self): """A launchpad url should map to a http url""" factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'http://bazaar.staging.launchpad.net/~apt/apt/devel'])) url = 'lp://staging/apt' directory = LaunchpadDirectory() self.assertEqual('http://bazaar.staging.launchpad.net/~apt/apt/devel', directory._resolve(url, factory)) # Make sure that resolve went to the staging server. self.assertEqual('https://xmlrpc.staging.launchpad.net/bazaar/', factory._service_url)
def test_resolve_tilde_to_user(self): factory = FakeResolveFactory( self, '~username/apt/test', dict(urls=['bzr+ssh://bazaar.launchpad.net/~username/apt/test'])) directory = LaunchpadDirectory() self.assertEquals( 'bzr+ssh://bazaar.launchpad.net/~username/apt/test', directory._resolve('lp:~/apt/test', factory, _lp_login='******')) # Should also happen when the login is just set by config set_lp_login('username') self.assertEquals('bzr+ssh://bazaar.launchpad.net/~username/apt/test', directory._resolve('lp:~/apt/test', factory))
def test_rewrite_bzr_ssh_launchpad_net(self): # Test that bzr+ssh URLs get rewritten to include the user's # Launchpad ID (assuming we know the Launchpad ID). factory = FakeResolveFactory( self, 'apt', dict(urls=[ 'bzr+ssh://bazaar.launchpad.net/~apt/apt/devel', 'http://bazaar.launchpad.net/~apt/apt/devel' ])) directory = LaunchpadDirectory() self.assertEquals( 'bzr+ssh://[email protected]/~apt/apt/devel', directory._resolve('lp:///apt', factory, _lp_login='******'))
from ..utils import check_output from .base import SUBPROCESS_ENV from .base import BaseRepo from .base import update_check_call from .base import clone_check_call from .base import UpdateError from .base import CloneError logger = logging.getLogger(__name__) try: from bzrlib.plugins.launchpad.lp_directory import LaunchpadDirectory except ImportError: LPDIR = None else: LPDIR = LaunchpadDirectory() class BzrBranch(BaseRepo): """Represent a Bazaar branch tied to a reference branch.""" vcs_control_dir = '.bzr' vcs_official_name = 'Bazaar' def __init__(self, *a, **kw): super(BzrBranch, self).__init__(*a, **kw) if self.options.get('bzr-init') == "ligthweight-checkout": logger.warn("The 'ligthweight-checkout' *misspelling* is " "deprecated as of version 1.7.1 of this buildout " "recipe. "
def setUp(self): super(TestDebuntuExpansions, self).setUp() self.directory = LaunchpadDirectory()
def test_error_for_bad_url(self): directory = LaunchpadDirectory() self.assertRaises(errors.InvalidURL, directory._resolve, 'lp://ratotehunoahu')