Merge lp:~benji/launchpad/bug-810113 into lp:launchpad

Proposed by Benji York
Status: Merged
Approved by: Benji York
Approved revision: no longer in the source branch.
Merged at revision: 13843
Proposed branch: lp:~benji/launchpad/bug-810113
Merge into: lp:launchpad
Diff against target: 41 lines (+22/-1)
2 files modified
lib/canonical/launchpad/webapp/servers.py (+1/-1)
lib/canonical/launchpad/webapp/tests/test_pageid.py (+21/-0)
To merge this branch: bzr merge lp:~benji/launchpad/bug-810113
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+73591@code.launchpad.net

Commit message

[r=bac][bug=810113] if multiple ws.op fields are provided, ignore them when generating the page ID

Description of the change

This branch fixes a very simple bug, the page ID mechanism wasn't able to cope with multiple ws.op fields (which are represented as lists instead of strings).

Lint: the lint report is clean

Test: bin/test -c -m canonical.launchpad.webapp.tests -t TestPageIdCorners

QA: load a URL like this: https://api.launchpad.net/1.0/checkbox?ws.op=1&ws.op=2

Review music: http://www.youtube.com/watch?v=0O2aH4XLbto

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Looks good save for a couple of typos:

mutliple
alltogether -> altogether

review: Approve (code)
Revision history for this message
Brad Crittenden (bac) wrote :

Your review would've been much faster if it weren't for the insane music.

Revision history for this message
Benji York (benji) wrote :

On Wed, Aug 31, 2011 at 5:03 PM, Brad Crittenden <email address hidden> wrote:
> Review: Approve code
> Looks good save for a couple of typos:

Fixed. Thanks.
--
Benji York

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

> Review music: http://www.youtube.com/watch?v=0O2aH4XLbto

Seriously!!! That put a smile on my face. Thanks for that!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/webapp/servers.py'
2--- lib/canonical/launchpad/webapp/servers.py 2011-08-16 19:08:01 +0000
3+++ lib/canonical/launchpad/webapp/servers.py 2011-08-31 21:06:26 +0000
4@@ -1180,7 +1180,7 @@
5 pageid += ':' + collection_identifier
6 op = (view.request.get('ws.op')
7 or view.request.query_string_params.get('ws.op'))
8- if op:
9+ if op and isinstance(op, basestring):
10 pageid += ':' + op
11 return pageid
12
13
14=== modified file 'lib/canonical/launchpad/webapp/tests/test_pageid.py'
15--- lib/canonical/launchpad/webapp/tests/test_pageid.py 2010-08-27 16:01:05 +0000
16+++ lib/canonical/launchpad/webapp/tests/test_pageid.py 2011-08-31 21:06:26 +0000
17@@ -99,3 +99,24 @@
18 self.assertEqual(
19 self.makePageID(),
20 'FakeContext:FakeCollectionResourceView:#milestone-page-resource')
21+
22+
23+class TestPageIdCorners(TestCase):
24+ """Ensure that the page ID generation handles corner cases well."""
25+
26+ def setUp(self):
27+ super(TestPageIdCorners, self).setUp()
28+ self.publication = WebServicePublication(db=None)
29+ self.view = FakeView()
30+ self.context = FakeContext()
31+
32+ def makePageID(self):
33+ return self.publication.constructPageID(self.view, self.context)
34+
35+ def test_pageid_with_multiple_op_fields(self):
36+ # The publisher will combine multiple form values with the same name
37+ # into a list. If those values are for "ws.op", the page ID mechanism
38+ # should just ignore the op altogether. (It used to generate an
39+ # error, see bug 810113).
40+ self.view.request.form_values['ws.op'] = ['one', 'another']
41+ self.assertEqual(self.makePageID(), 'FakeContext:FakeView')