Merge lp://staging/~allenap/launchpad/syncable-gnome-test-failure-bug-498602 into lp://staging/launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: not available
Merged at revision: not available
Proposed branch: lp://staging/~allenap/launchpad/syncable-gnome-test-failure-bug-498602
Merge into: lp://staging/launchpad
Diff against target: 131 lines (+32/-34)
4 files modified
lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt (+11/-0)
lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt (+11/-0)
lib/lp/bugs/externalbugtracker/bugzilla.py (+8/-0)
lib/lp/bugs/scripts/tests/test_checkwatches.py (+2/-34)
To merge this branch: bzr merge lp://staging/~allenap/launchpad/syncable-gnome-test-failure-bug-498602
Reviewer Review Type Date Requested Status
Deryck Hodge (community) code Approve
Review via email: mp+16429@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Bugzilla.getExternalBugTrackerToUse() makes network calls to sniff out the support offered by the remote Bugzilla.

TestCheckwatchesWithSyncableGnomeProducts.setUp() (in lib/lp/bugs/scripts/tests/test_checkwatches.py) patches in get_external_bugtracker() to always return a BugzillaAPI instance, in the assumption (I think) that BugzillaAPI.getExternalBugTrackerToUse() would return self, as the default implementation does.

However, BugzillaAPI inherits from Bugzilla, so sniffs anyway. This fails in PQM when landing to production-devel.

I've changed BugzillaAPI (and BugzillaLPPlugin for good measure) to just return self.

I would like to refactor this code to have a BugzillaSniffer class, which getExternalBugTrackerToUse() method can return one of Bugzilla, BugzillaAPI or BugzillaLPPlugin, none of which inherit from BugzillaSniffer. However, this branch is a simpler solution to get the test working again while I/we work on a better fix.

Revision history for this message
Deryck Hodge (deryck) wrote :

Looks good. Thanks for fixing this failure!

Cheers,
deryck

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2009-11-30 10:21:23 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2009-12-21 16:10:28 +0000
@@ -23,6 +23,17 @@
23 True23 True
2424
2525
26Getting the tracker to use
27--------------------------
28
29Instances of BugzillaAPI always assume that they are the appropriate
30bug tracker to use. They do not sniff the remote system to check for
31support; they assume that has been done elsewhere.
32
33 >>> bugzilla.getExternalBugTrackerToUse() is bugzilla
34 True
35
36
26Authentication37Authentication
27--------------38--------------
2839
2940
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2009-12-13 01:11:01 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2009-12-21 16:10:28 +0000
@@ -26,6 +26,17 @@
26 True26 True
2727
2828
29Getting the tracker to use
30--------------------------
31
32Instances of BugzillaLPPlugin always assume that they are the
33appropriate bug tracker to use. They do not sniff the remote system to
34check for support; they assume that has been done elsewhere.
35
36 >>> bugzilla.getExternalBugTrackerToUse() is bugzilla
37 True
38
39
29Authentication40Authentication
30--------------41--------------
3142
3243
=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py 2009-11-30 10:58:51 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2009-12-21 16:10:28 +0000
@@ -444,6 +444,10 @@
444 else:444 else:
445 self.xmlrpc_transport = xmlrpc_transport445 self.xmlrpc_transport = xmlrpc_transport
446446
447 def getExternalBugTrackerToUse(self):
448 """The Bugzilla API has been chosen, so return self."""
449 return self
450
447 @property451 @property
448 def xmlrpc_proxy(self):452 def xmlrpc_proxy(self):
449 """Return an `xmlrpclib.ServerProxy` to self.xmlrpc_endpoint."""453 """Return an `xmlrpclib.ServerProxy` to self.xmlrpc_endpoint."""
@@ -797,6 +801,10 @@
797 ISupportsBackLinking, ISupportsCommentImport,801 ISupportsBackLinking, ISupportsCommentImport,
798 ISupportsCommentPushing)802 ISupportsCommentPushing)
799803
804 def getExternalBugTrackerToUse(self):
805 """The Bugzilla LP Plugin has been chosen, so return self."""
806 return self
807
800 def _authenticate(self):808 def _authenticate(self):
801 """Authenticate with the remote Bugzilla instance.809 """Authenticate with the remote Bugzilla instance.
802810
803811
=== modified file 'lib/lp/bugs/scripts/tests/test_checkwatches.py'
--- lib/lp/bugs/scripts/tests/test_checkwatches.py 2009-12-15 16:28:20 +0000
+++ lib/lp/bugs/scripts/tests/test_checkwatches.py 2009-12-21 16:10:28 +0000
@@ -18,42 +18,11 @@
18from lp.testing import TestCaseWithFactory18from lp.testing import TestCaseWithFactory
1919
2020
21def fudged_get_external_bugtracker(bugtracker):21def always_BugzillaAPI_get_external_bugtracker(bugtracker):
22 """A version of get_external_bugtracker that returns BugzillaAPI."""22 """A version of get_external_bugtracker that returns BugzillaAPI."""
23 return BugzillaAPI(bugtracker.baseurl)23 return BugzillaAPI(bugtracker.baseurl)
2424
2525
26class NonConnectingBugzillaAPI(BugzillaAPI):
27 """A non-connected version of the BugzillaAPI ExternalBugTracker."""
28
29 bugs = {
30 1: {'product': 'test-product'},
31 }
32
33 def getExternalBugTrackerToUse(self):
34 return self
35
36 def getProductsForRemoteBugs(self, remote_bugs):
37 """Return the products for some remote bugs.
38
39 This method is basically the same as that of the superclass but
40 without the call to initializeRemoteBugDB().
41 """
42 bug_products = {}
43 for bug_id in bug_ids:
44 # If one of the bugs we're trying to get the product for
45 # doesn't exist, just skip it.
46 try:
47 actual_bug_id = self._getActualBugId(bug_id)
48 except BugNotFound:
49 continue
50
51 bug_dict = self._bugs[actual_bug_id]
52 bug_products[bug_id] = bug_dict['product']
53
54 return bug_products
55
56
57class TestCheckwatchesWithSyncableGnomeProducts(TestCaseWithFactory):26class TestCheckwatchesWithSyncableGnomeProducts(TestCaseWithFactory):
5827
59 layer = LaunchpadZopelessLayer28 layer = LaunchpadZopelessLayer
@@ -66,7 +35,7 @@
66 self.original_get_external_bug_tracker = (35 self.original_get_external_bug_tracker = (
67 checkwatches.externalbugtracker.get_external_bugtracker)36 checkwatches.externalbugtracker.get_external_bugtracker)
68 checkwatches.externalbugtracker.get_external_bugtracker = (37 checkwatches.externalbugtracker.get_external_bugtracker = (
69 fudged_get_external_bugtracker)38 always_BugzillaAPI_get_external_bugtracker)
7039
71 # Create an updater with a limited set of syncable gnome40 # Create an updater with a limited set of syncable gnome
72 # products.41 # products.
@@ -96,4 +65,3 @@
9665
97def test_suite():66def test_suite():
98 return unittest.TestLoader().loadTestsFromName(__name__)67 return unittest.TestLoader().loadTestsFromName(__name__)
99