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_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_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))
Exemple #4
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))
 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)
Exemple #6
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))
 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))
Exemple #8
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)
 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))
Exemple #10
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))
Exemple #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.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_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='******'))
 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))
 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)
Exemple #15
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='******'))
Exemple #16
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='******'))
Exemple #17
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))
 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)
Exemple #19
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)
 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='******'))
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')
Exemple #22
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')