Esempio n. 1
0
 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))
Esempio n. 2
0
 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.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
                       directory._resolve('lp:///apt', factory))
Esempio n. 3
0
 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))
Esempio n. 4
0
 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.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
                       directory._resolve('lp:///apt', factory))
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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.assertEquals('bzr+ssh://example.com/~apt/apt/devel',
                       directory._resolve('lp:///apt', factory))
Esempio n. 8
0
 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))
Esempio n. 9
0
 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.assertEquals(
         'bzr+ssh://bazaar.launchpad.net/+branch/apt',
         directory._resolve('lp:///apt', factory, _lp_login='******'))
Esempio n. 10
0
 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.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
                       directory._resolve('lp:///apt', factory))
Esempio n. 11
0
 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.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
                       directory._resolve('lp:apt', factory))
     # Make sure that resolve went to the production server.
     self.assertEquals('https://xmlrpc.launchpad.net/bazaar/',
                       factory._service_url)
Esempio n. 12
0
 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)
Esempio n. 13
0
 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='******'))
Esempio n. 14
0
 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))
Esempio n. 15
0
 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='******'))
Esempio n. 16
0
 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))
Esempio n. 17
0
 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.assertEquals('http://bazaar.staging.launchpad.net/~apt/apt/devel',
                       directory._resolve(url, factory))
     # Make sure that resolve went to the staging server.
     self.assertEquals('https://xmlrpc.staging.launchpad.net/bazaar/',
                       factory._service_url)
Esempio n. 18
0
 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)
Esempio n. 19
0
 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))
Esempio n. 20
0
 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='******'))
Esempio n. 21
0
 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)
Esempio n. 22
0
 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)
Esempio n. 23
0
 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)
Esempio n. 24
0
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. "
Esempio n. 25
0
 def setUp(self):
     super(TestDebuntuExpansions, self).setUp()
     self.directory = LaunchpadDirectory()
Esempio n. 26
0
class TestDebuntuExpansions(TestCaseInTempDir):
    """Test expansions for ubuntu: and debianlp: schemes."""

    def setUp(self):
        super(TestDebuntuExpansions, self).setUp()
        self.directory = LaunchpadDirectory()

    def _make_factory(self, package='foo', distro='ubuntu', series=None):
        if series is None:
            path = '%s/%s' % (distro, package)
            url_suffix = '~branch/%s/%s' % (distro, package)
        else:
            path = '%s/%s/%s' % (distro, series, package)
            url_suffix = '~branch/%s/%s/%s' % (distro, series, package)
        return FakeResolveFactory(
            self, path, dict(urls=[
                'http://bazaar.launchpad.net/' + url_suffix]))

    def assertURL(self, expected_url, shortcut, package='foo', distro='ubuntu',
                  series=None):
        factory = self._make_factory(package=package, distro=distro,
                                     series=series)
        self.assertEqual('http://bazaar.launchpad.net/~branch/' + expected_url,
                         self.directory._resolve(shortcut, factory))

    # Bogus distro.

    def test_bogus_distro(self):
        self.assertRaises(errors.InvalidURL,
                          self.directory._resolve, 'gentoo:foo')

    def test_trick_bogus_distro_u(self):
        self.assertRaises(errors.InvalidURL,
                          self.directory._resolve, 'utube:foo')

    def test_trick_bogus_distro_d(self):
        self.assertRaises(errors.InvalidURL,
                          self.directory._resolve, 'debuntu:foo')

    def test_missing_ubuntu_distroseries_without_project(self):
        # Launchpad does not hold source packages for Intrepid.  Missing or
        # bogus distroseries with no project name is treated like a project.
        self.assertURL('ubuntu/intrepid', 'ubuntu:intrepid', package='intrepid')

    def test_missing_ubuntu_distroseries_with_project(self):
        # Launchpad does not hold source packages for Intrepid.  Missing or
        # bogus distroseries with a project name is treated like an unknown
        # series (i.e. we keep it verbatim).
        self.assertURL('ubuntu/intrepid/foo',
                       'ubuntu:intrepid/foo', series='intrepid')

    def test_missing_debian_distroseries(self):
        # Launchpad does not hold source packages for unstable.  Missing or
        # bogus distroseries is treated like a project.
        self.assertURL('debian/sid',
                       'debianlp:sid', package='sid', distro='debian')

    # Ubuntu Default distro series.

    def test_ubuntu_default_distroseries_expansion(self):
        self.assertURL('ubuntu/foo', 'ubuntu:foo')

    def test_ubuntu_natty_distroseries_expansion(self):
        self.assertURL('ubuntu/natty/foo', 'ubuntu:natty/foo', series='natty')

    def test_ubuntu_n_distroseries_expansion(self):
        self.assertURL('ubuntu/natty/foo', 'ubuntu:n/foo', series='natty')

    def test_ubuntu_maverick_distroseries_expansion(self):
        self.assertURL('ubuntu/maverick/foo', 'ubuntu:maverick/foo',
                       series='maverick')

    def test_ubuntu_m_distroseries_expansion(self):
        self.assertURL('ubuntu/maverick/foo', 'ubuntu:m/foo', series='maverick')

    def test_ubuntu_lucid_distroseries_expansion(self):
        self.assertURL('ubuntu/lucid/foo', 'ubuntu:lucid/foo', series='lucid')

    def test_ubuntu_l_distroseries_expansion(self):
        self.assertURL('ubuntu/lucid/foo', 'ubuntu:l/foo', series='lucid')

    def test_ubuntu_karmic_distroseries_expansion(self):
        self.assertURL('ubuntu/karmic/foo', 'ubuntu:karmic/foo',
                       series='karmic')

    def test_ubuntu_k_distroseries_expansion(self):
        self.assertURL('ubuntu/karmic/foo', 'ubuntu:k/foo', series='karmic')

    def test_ubuntu_jaunty_distroseries_expansion(self):
        self.assertURL('ubuntu/jaunty/foo', 'ubuntu:jaunty/foo',
                       series='jaunty')

    def test_ubuntu_j_distroseries_expansion(self):
        self.assertURL('ubuntu/jaunty/foo', 'ubuntu:j/foo', series='jaunty')

    def test_ubuntu_hardy_distroseries_expansion(self):
        self.assertURL('ubuntu/hardy/foo', 'ubuntu:hardy/foo', series='hardy')

    def test_ubuntu_h_distroseries_expansion(self):
        self.assertURL('ubuntu/hardy/foo', 'ubuntu:h/foo', series='hardy')

    def test_ubuntu_dapper_distroseries_expansion(self):
        self.assertURL('ubuntu/dapper/foo', 'ubuntu:dapper/foo',
                       series='dapper')

    def test_ubuntu_d_distroseries_expansion(self):
        self.assertURL('ubuntu/dapper/foo', 'ubuntu:d/foo', series='dapper')

    # Debian default distro series.

    def test_debian_default_distroseries_expansion(self):
        self.assertURL('debian/foo', 'debianlp:foo', distro='debian')

    def test_debian_squeeze_distroseries_expansion(self):
        self.assertURL('debian/squeeze/foo', 'debianlp:squeeze/foo',
                       distro='debian', series='squeeze')

    def test_debian_lenny_distroseries_expansion(self):
        self.assertURL('debian/lenny/foo', 'debianlp:lenny/foo',
                       distro='debian', series='lenny')
Esempio n. 27
0
 def test_error_for_bad_url(self):
     directory = LaunchpadDirectory()
     self.assertRaises(errors.InvalidURL,
         directory._resolve, 'lp://ratotehunoahu')
Esempio n. 28
0
class TestDebuntuExpansions(TestCaseInTempDir):
    """Test expansions for ubuntu: and debianlp: schemes."""

    def setUp(self):
        super(TestDebuntuExpansions, self).setUp()
        self.directory = LaunchpadDirectory()

    def _make_factory(self, package='foo', distro='ubuntu', series=None):
        if series is None:
            path = '%s/%s' % (distro, package)
            url_suffix = '~branch/%s/%s' % (distro, package)
        else:
            path = '%s/%s/%s' % (distro, series, package)
            url_suffix = '~branch/%s/%s/%s' % (distro, series, package)
        return FakeResolveFactory(
            self, path, dict(urls=[
                'http://bazaar.launchpad.net/' + url_suffix]))

    def assertURL(self, expected_url, shortcut, package='foo', distro='ubuntu',
                  series=None):
        factory = self._make_factory(package=package, distro=distro,
                                     series=series)
        self.assertEqual('http://bazaar.launchpad.net/~branch/' + expected_url,
                         self.directory._resolve(shortcut, factory))

    # Bogus distro.

    def test_bogus_distro(self):
        self.assertRaises(errors.InvalidURL,
                          self.directory._resolve, 'gentoo:foo')

    def test_trick_bogus_distro_u(self):
        self.assertRaises(errors.InvalidURL,
                          self.directory._resolve, 'utube:foo')

    def test_trick_bogus_distro_d(self):
        self.assertRaises(errors.InvalidURL,
                          self.directory._resolve, 'debuntu:foo')

    def test_missing_ubuntu_distroseries_without_project(self):
        # Launchpad does not hold source packages for Intrepid.  Missing or
        # bogus distroseries with no project name is treated like a project.
        self.assertURL('ubuntu/intrepid', 'ubuntu:intrepid', package='intrepid')

    def test_missing_ubuntu_distroseries_with_project(self):
        # Launchpad does not hold source packages for Intrepid.  Missing or
        # bogus distroseries with a project name is treated like an unknown
        # series (i.e. we keep it verbatim).
        self.assertURL('ubuntu/intrepid/foo',
                       'ubuntu:intrepid/foo', series='intrepid')

    def test_missing_debian_distroseries(self):
        # Launchpad does not hold source packages for unstable.  Missing or
        # bogus distroseries is treated like a project.
        self.assertURL('debian/sid',
                       'debianlp:sid', package='sid', distro='debian')

    # Ubuntu Default distro series.

    def test_ubuntu_default_distroseries_expansion(self):
        self.assertURL('ubuntu/foo', 'ubuntu:foo')

    def test_ubuntu_natty_distroseries_expansion(self):
        self.assertURL('ubuntu/natty/foo', 'ubuntu:natty/foo', series='natty')

    def test_ubuntu_n_distroseries_expansion(self):
        self.assertURL('ubuntu/natty/foo', 'ubuntu:n/foo', series='natty')

    def test_ubuntu_maverick_distroseries_expansion(self):
        self.assertURL('ubuntu/maverick/foo', 'ubuntu:maverick/foo',
                       series='maverick')

    def test_ubuntu_m_distroseries_expansion(self):
        self.assertURL('ubuntu/maverick/foo', 'ubuntu:m/foo', series='maverick')

    def test_ubuntu_lucid_distroseries_expansion(self):
        self.assertURL('ubuntu/lucid/foo', 'ubuntu:lucid/foo', series='lucid')

    def test_ubuntu_l_distroseries_expansion(self):
        self.assertURL('ubuntu/lucid/foo', 'ubuntu:l/foo', series='lucid')

    def test_ubuntu_karmic_distroseries_expansion(self):
        self.assertURL('ubuntu/karmic/foo', 'ubuntu:karmic/foo',
                       series='karmic')

    def test_ubuntu_k_distroseries_expansion(self):
        self.assertURL('ubuntu/karmic/foo', 'ubuntu:k/foo', series='karmic')

    def test_ubuntu_jaunty_distroseries_expansion(self):
        self.assertURL('ubuntu/jaunty/foo', 'ubuntu:jaunty/foo',
                       series='jaunty')

    def test_ubuntu_j_distroseries_expansion(self):
        self.assertURL('ubuntu/jaunty/foo', 'ubuntu:j/foo', series='jaunty')

    def test_ubuntu_hardy_distroseries_expansion(self):
        self.assertURL('ubuntu/hardy/foo', 'ubuntu:hardy/foo', series='hardy')

    def test_ubuntu_h_distroseries_expansion(self):
        self.assertURL('ubuntu/hardy/foo', 'ubuntu:h/foo', series='hardy')

    def test_ubuntu_dapper_distroseries_expansion(self):
        self.assertURL('ubuntu/dapper/foo', 'ubuntu:dapper/foo',
                       series='dapper')

    def test_ubuntu_d_distroseries_expansion(self):
        self.assertURL('ubuntu/dapper/foo', 'ubuntu:d/foo', series='dapper')

    # Debian default distro series.

    def test_debian_default_distroseries_expansion(self):
        self.assertURL('debian/foo', 'debianlp:foo', distro='debian')

    def test_debian_squeeze_distroseries_expansion(self):
        self.assertURL('debian/squeeze/foo', 'debianlp:squeeze/foo',
                       distro='debian', series='squeeze')

    def test_debian_lenny_distroseries_expansion(self):
        self.assertURL('debian/lenny/foo', 'debianlp:lenny/foo',
                       distro='debian', series='lenny')
Esempio n. 29
0
 def setUp(self):
     super(TestDebuntuExpansions, self).setUp()
     self.directory = LaunchpadDirectory()