Rev 6027: Start at least testing the package_branch regex. in http://bazaar.launchpad.net/~jameinel/bzr/2.5-up-to-date-609187
John Arbash Meinel
john at arbash-meinel.com
Mon Jul 18 14:23:20 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.5-up-to-date-609187
------------------------------------------------------------
revno: 6027
revision-id: john at arbash-meinel.com-20110718142220-nwylw659oip1ene9
parent: john at arbash-meinel.com-20110713142603-te4c417d52ewglh9
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.5-up-to-date-609187
timestamp: Mon 2011-07-18 16:22:20 +0200
message:
Start at least testing the package_branch regex.
And start testing the is-up-to-date logic.
-------------- next part --------------
=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- a/bzrlib/plugins/launchpad/__init__.py 2011-07-13 14:22:55 +0000
+++ b/bzrlib/plugins/launchpad/__init__.py 2011-07-18 14:22:20 +0000
@@ -469,7 +469,8 @@
package_branch = lazy_regex.lazy_compile(
- r'bazaar.launchpad.net.*/(?P<archive>ubuntu|debian)/(?P<series>[^/]+/)?'
+ r'bazaar.launchpad.net.*/'
+ r'(?P<user>~[^/]+/)?(?P<archive>ubuntu|debian)/(?P<series>[^/]+/)?'
r'(?P<project>[^/]+)(?P<branch>/[^/]+)?'
)
def _check_is_up_to_date(the_branch):
@@ -477,7 +478,8 @@
if m is None:
return
from bzrlib.plugins.launchpad import lp_api_lite
- archive, series, project = m.group('archive', 'series', 'project')
+ archive, series, project, user = m.group('archive', 'series',
+ 'project', 'user')
if series is not None:
# series is optional, so the regex includes the extra '/', we don't
# want to send that on (it causes Internal Server Errors.)
=== modified file 'bzrlib/plugins/launchpad/lp_api_lite.py'
--- a/bzrlib/plugins/launchpad/lp_api_lite.py 2011-07-13 13:35:36 +0000
+++ b/bzrlib/plugins/launchpad/lp_api_lite.py 2011-07-18 14:22:20 +0000
@@ -39,8 +39,6 @@
from bzrlib import trace
-DEFAULT_SERIES = 'oneiric'
-
class LatestPublication(object):
"""Encapsulate how to find the latest publication for a given project."""
@@ -120,7 +118,7 @@
req = urllib2.Request(query_URL)
response = urllib2.urlopen(req)
json_info = response.read()
- # XXX: We haven't tested the HTTPError
+ # TODO: We haven't tested the HTTPError
except (urllib2.URLError, urllib2.HTTPError), e:
trace.mutter('failed to place query to %r' % (query_URL,))
trace.log_exception_quietly()
=== modified file 'bzrlib/plugins/launchpad/test_lp_api_lite.py'
--- a/bzrlib/plugins/launchpad/test_lp_api_lite.py 2011-07-13 13:35:36 +0000
+++ b/bzrlib/plugins/launchpad/test_lp_api_lite.py 2011-07-18 14:22:20 +0000
@@ -20,6 +20,7 @@
import socket
from bzrlib import tests
+from bzrlib.plugins import launchpad
from bzrlib.plugins.launchpad import lp_api_lite
class _JSONParserFeature(tests.Feature):
@@ -260,3 +261,19 @@
self.requireFeature(JSONParserFeature)
latest_pub = self.make_latest_publication()
self.assertIsNot(None, latest_pub.get_latest_version())
+
+
+class TestIsUpToDate(tests.TestCase):
+
+ def assertPackageBranchRe(self, url, user, archive, series, project):
+ m = launchpad.package_branch.search(url)
+ if m is None:
+ self.fail('package_branch regex did not match url: %s' % (url,))
+ self.assertEqual(
+ (user, archive, series, project),
+ m.group('user', 'archive', 'series', 'project'))
+
+ def test_package_branch_regex(self):
+ self.assertPackageBranchRe(
+ 'http://bazaar.launchpad.net/+branch/ubuntu/foo',
+ None, 'ubuntu', None, 'foo')
More information about the bazaar-commits
mailing list