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
1=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
2--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2009-11-30 10:21:23 +0000
3+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2009-12-21 16:10:28 +0000
4@@ -23,6 +23,17 @@
5 True
6
7
8+Getting the tracker to use
9+--------------------------
10+
11+Instances of BugzillaAPI always assume that they are the appropriate
12+bug tracker to use. They do not sniff the remote system to check for
13+support; they assume that has been done elsewhere.
14+
15+ >>> bugzilla.getExternalBugTrackerToUse() is bugzilla
16+ True
17+
18+
19 Authentication
20 --------------
21
22
23=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt'
24--- lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2009-12-13 01:11:01 +0000
25+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2009-12-21 16:10:28 +0000
26@@ -26,6 +26,17 @@
27 True
28
29
30+Getting the tracker to use
31+--------------------------
32+
33+Instances of BugzillaLPPlugin always assume that they are the
34+appropriate bug tracker to use. They do not sniff the remote system to
35+check for support; they assume that has been done elsewhere.
36+
37+ >>> bugzilla.getExternalBugTrackerToUse() is bugzilla
38+ True
39+
40+
41 Authentication
42 --------------
43
44
45=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
46--- lib/lp/bugs/externalbugtracker/bugzilla.py 2009-11-30 10:58:51 +0000
47+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2009-12-21 16:10:28 +0000
48@@ -444,6 +444,10 @@
49 else:
50 self.xmlrpc_transport = xmlrpc_transport
51
52+ def getExternalBugTrackerToUse(self):
53+ """The Bugzilla API has been chosen, so return self."""
54+ return self
55+
56 @property
57 def xmlrpc_proxy(self):
58 """Return an `xmlrpclib.ServerProxy` to self.xmlrpc_endpoint."""
59@@ -797,6 +801,10 @@
60 ISupportsBackLinking, ISupportsCommentImport,
61 ISupportsCommentPushing)
62
63+ def getExternalBugTrackerToUse(self):
64+ """The Bugzilla LP Plugin has been chosen, so return self."""
65+ return self
66+
67 def _authenticate(self):
68 """Authenticate with the remote Bugzilla instance.
69
70
71=== modified file 'lib/lp/bugs/scripts/tests/test_checkwatches.py'
72--- lib/lp/bugs/scripts/tests/test_checkwatches.py 2009-12-15 16:28:20 +0000
73+++ lib/lp/bugs/scripts/tests/test_checkwatches.py 2009-12-21 16:10:28 +0000
74@@ -18,42 +18,11 @@
75 from lp.testing import TestCaseWithFactory
76
77
78-def fudged_get_external_bugtracker(bugtracker):
79+def always_BugzillaAPI_get_external_bugtracker(bugtracker):
80 """A version of get_external_bugtracker that returns BugzillaAPI."""
81 return BugzillaAPI(bugtracker.baseurl)
82
83
84-class NonConnectingBugzillaAPI(BugzillaAPI):
85- """A non-connected version of the BugzillaAPI ExternalBugTracker."""
86-
87- bugs = {
88- 1: {'product': 'test-product'},
89- }
90-
91- def getExternalBugTrackerToUse(self):
92- return self
93-
94- def getProductsForRemoteBugs(self, remote_bugs):
95- """Return the products for some remote bugs.
96-
97- This method is basically the same as that of the superclass but
98- without the call to initializeRemoteBugDB().
99- """
100- bug_products = {}
101- for bug_id in bug_ids:
102- # If one of the bugs we're trying to get the product for
103- # doesn't exist, just skip it.
104- try:
105- actual_bug_id = self._getActualBugId(bug_id)
106- except BugNotFound:
107- continue
108-
109- bug_dict = self._bugs[actual_bug_id]
110- bug_products[bug_id] = bug_dict['product']
111-
112- return bug_products
113-
114-
115 class TestCheckwatchesWithSyncableGnomeProducts(TestCaseWithFactory):
116
117 layer = LaunchpadZopelessLayer
118@@ -66,7 +35,7 @@
119 self.original_get_external_bug_tracker = (
120 checkwatches.externalbugtracker.get_external_bugtracker)
121 checkwatches.externalbugtracker.get_external_bugtracker = (
122- fudged_get_external_bugtracker)
123+ always_BugzillaAPI_get_external_bugtracker)
124
125 # Create an updater with a limited set of syncable gnome
126 # products.
127@@ -96,4 +65,3 @@
128
129 def test_suite():
130 return unittest.TestLoader().loadTestsFromName(__name__)
131-