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
=== modified file 'lib/canonical/launchpad/webapp/servers.py'
--- lib/canonical/launchpad/webapp/servers.py 2011-08-16 19:08:01 +0000
+++ lib/canonical/launchpad/webapp/servers.py 2011-08-31 21:06:26 +0000
@@ -1180,7 +1180,7 @@
1180 pageid += ':' + collection_identifier1180 pageid += ':' + collection_identifier
1181 op = (view.request.get('ws.op')1181 op = (view.request.get('ws.op')
1182 or view.request.query_string_params.get('ws.op'))1182 or view.request.query_string_params.get('ws.op'))
1183 if op:1183 if op and isinstance(op, basestring):
1184 pageid += ':' + op1184 pageid += ':' + op
1185 return pageid1185 return pageid
11861186
11871187
=== modified file 'lib/canonical/launchpad/webapp/tests/test_pageid.py'
--- lib/canonical/launchpad/webapp/tests/test_pageid.py 2010-08-27 16:01:05 +0000
+++ lib/canonical/launchpad/webapp/tests/test_pageid.py 2011-08-31 21:06:26 +0000
@@ -99,3 +99,24 @@
99 self.assertEqual(99 self.assertEqual(
100 self.makePageID(),100 self.makePageID(),
101 'FakeContext:FakeCollectionResourceView:#milestone-page-resource')101 'FakeContext:FakeCollectionResourceView:#milestone-page-resource')
102
103
104class TestPageIdCorners(TestCase):
105 """Ensure that the page ID generation handles corner cases well."""
106
107 def setUp(self):
108 super(TestPageIdCorners, self).setUp()
109 self.publication = WebServicePublication(db=None)
110 self.view = FakeView()
111 self.context = FakeContext()
112
113 def makePageID(self):
114 return self.publication.constructPageID(self.view, self.context)
115
116 def test_pageid_with_multiple_op_fields(self):
117 # The publisher will combine multiple form values with the same name
118 # into a list. If those values are for "ws.op", the page ID mechanism
119 # should just ignore the op altogether. (It used to generate an
120 # error, see bug 810113).
121 self.view.request.form_values['ws.op'] = ['one', 'another']
122 self.assertEqual(self.makePageID(), 'FakeContext:FakeView')