Merge lp:~gary/launchpad/bug683115 into lp:launchpad

Proposed by Gary Poster
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: 12058
Proposed branch: lp:~gary/launchpad/bug683115
Merge into: lp:launchpad
Diff against target: 44 lines (+6/-10)
2 files modified
lib/canonical/launchpad/doc/google-searchservice.txt (+4/-7)
lib/canonical/launchpad/utilities/searchservice.py (+2/-3)
To merge this branch: bzr merge lp:~gary/launchpad/bug683115
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+43572@code.launchpad.net

Commit message

[r=abentley][ui=none][bug=683115] Fix bug 683115 by treating reported Google totals of less than 0 as 0.

Description of the change

Deploying the previous branch for this bug showed that my diagnosis was correct. Discussion with Curtis indicated that it should not be unexpected for Google to give us an approximate total of less than zero, and that treating numbers less than zero as zero should be fine. Therefore, this branch does that, simply, removing the error that I raised in my last branch.

Lint is happy, and the Google integration tests are too.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/doc/google-searchservice.txt'
2--- lib/canonical/launchpad/doc/google-searchservice.txt 2010-11-30 23:01:42 +0000
3+++ lib/canonical/launchpad/doc/google-searchservice.txt 2010-12-13 20:49:03 +0000
4@@ -295,8 +295,8 @@
5 GoogleWrongGSPVersion: Could not get the 'total' from the
6 GSP XML response.
7
8-Similarly, if the total were ever less than zero (which we are suspicious
9-of because of bug 683115), we would see an error.
10+On the other hand, if the total is ever less than zero (see bug 683115),
11+this is expected: we simply return a total of 0.
12
13 >>> gsp_xml_file_name = path.join(
14 ... base_path, 'googlesearchservice-negative-total.xml')
15@@ -308,11 +308,8 @@
16 <RES SN="1" EN="1">
17 <M>-1</M>...
18
19- >>> google_search._parse_google_search_protocol(gsp_xml)
20- Traceback (most recent call last):
21- ...
22- GoogleResponseError: The reported total (-1, from '-1') was less than
23- zero. See bug 683115.
24+ >>> google_search._parse_google_search_protocol(gsp_xml).total
25+ 0
26
27 A PageMatch requires a title, url, and a summary. If those elements
28 ('<T>', '<U>', '<S>') cannot be found nested in an '<R>' a PageMatch
29
30=== modified file 'lib/canonical/launchpad/utilities/searchservice.py'
31--- lib/canonical/launchpad/utilities/searchservice.py 2010-11-30 23:06:43 +0000
32+++ lib/canonical/launchpad/utilities/searchservice.py 2010-12-13 20:49:03 +0000
33@@ -290,9 +290,8 @@
34 raise GoogleWrongGSPVersion(
35 "Could not get the 'total' from the GSP XML response.")
36 if total < 0:
37- raise GoogleResponseError(
38- ("The reported total (%d, from %r) was less than zero. "
39- "See bug 683115.") % (total, results.find('M').text))
40+ # See bug 683115.
41+ total = 0
42 for result in results.findall('R'):
43 url_tag = result.find('U')
44 title_tag = result.find('T')