Merge ~cjwatson/launchpad:zope.testbrowser-5-prepare into launchpad:master
- Git
- lp:~cjwatson/launchpad
- zope.testbrowser-5-prepare
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | a213eae94c9000d6ce11b9b6aae7f1cb3560246c |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:zope.testbrowser-5-prepare |
Merge into: | launchpad:master |
Diff against target: |
543 lines (+83/-73) 22 files modified
lib/lp/blueprints/stories/blueprints/xx-creation.txt (+2/-2) lib/lp/bugs/stories/bugattachments/xx-bugattachments.txt (+2/-2) lib/lp/bugs/stories/bugattachments/xx-delete-bug-attachment.txt (+1/-1) lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt (+1/-1) lib/lp/buildmaster/stories/xx-builder-page.txt (+1/-1) lib/lp/code/browser/tests/test_branch.py (+7/-5) lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt (+2/-1) lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt (+2/-1) lib/lp/registry/stories/mailinglists/subscriptions.txt (+3/-3) lib/lp/registry/stories/milestone/object-milestones.txt (+2/-2) lib/lp/registry/stories/product/xx-product-add.txt (+1/-1) lib/lp/registry/stories/team/xx-team-home.txt (+1/-1) lib/lp/services/webapp/login.py (+2/-0) lib/lp/services/webapp/tests/test_error.py (+26/-20) lib/lp/snappy/tests/test_snapbuild.py (+6/-7) lib/lp/soyuz/stories/ppa/xx-ppa-workflow.txt (+5/-5) lib/lp/soyuz/tests/test_livefsbuild.py (+6/-7) lib/lp/soyuz/tests/test_packageupload.py (+7/-7) lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt (+1/-2) lib/lp/translations/stories/standalone/xx-potemplate-admin.txt (+2/-2) lib/lp/translations/stories/standalone/xx-potemplate-edit.txt (+1/-1) lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt (+2/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ioana Lasc (community) | Approve | ||
Review via email: mp+375407@code.launchpad.net |
Commit message
Improve compatibility with zope.testbrowser 5.x
Description of the change
Upgrading to zope.testbrowser 5.x involves quite a number of test changes: some because the test browser has got stricter, and some to work around bugs or misfeatures in the new test browser. Since there are quite a lot of things to change, it seems helpful to separate out those that can be done in a way that's compatible with both 4.x and 5.x.
To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/blueprints/stories/blueprints/xx-creation.txt b/lib/lp/blueprints/stories/blueprints/xx-creation.txt |
2 | index a1802e5..a9e3e31 100644 |
3 | --- a/lib/lp/blueprints/stories/blueprints/xx-creation.txt |
4 | +++ b/lib/lp/blueprints/stories/blueprints/xx-creation.txt |
5 | @@ -301,7 +301,7 @@ Canceling creation, brings one back to the blueprints Hoary home. |
6 | |
7 | By default, blueprints are not proposed as series goals: |
8 | |
9 | - >>> control('series goal').control.value |
10 | + >>> bool(control('series goal').control.value) |
11 | False |
12 | |
13 | Pressing the "Register Blueprint" button creates a blueprint targeted to the |
14 | @@ -414,7 +414,7 @@ Let's register a blueprint from the Mozilla Firefox 1.0 product series: |
15 | |
16 | By default, blueprints are not proposed as series goals: |
17 | |
18 | - >>> control('series goal').control.value |
19 | + >>> bool(control('series goal').control.value) |
20 | False |
21 | |
22 | Pressing the "Register Blueprint" button creates a blueprint targeted to the |
23 | diff --git a/lib/lp/bugs/stories/bugattachments/xx-bugattachments.txt b/lib/lp/bugs/stories/bugattachments/xx-bugattachments.txt |
24 | index e4dd3cf..7126637 100644 |
25 | --- a/lib/lp/bugs/stories/bugattachments/xx-bugattachments.txt |
26 | +++ b/lib/lp/bugs/stories/bugattachments/xx-bugattachments.txt |
27 | @@ -260,7 +260,7 @@ We can also edit the attachment details, let's navigate to that page. |
28 | |
29 | >>> import re |
30 | >>> user_browser.open('http://bugs.launchpad.test/firefox/+bug/1') |
31 | - >>> user_browser.getLink(url=re.compile(r'[+]attachment/\d+$')).click() |
32 | + >>> user_browser.getLink(url=re.compile(r'.*/\+attachment/\d+$')).click() |
33 | >>> user_browser.url |
34 | 'http://bugs.launchpad.test/firefox/+bug/1/+attachment/...' |
35 | |
36 | @@ -290,7 +290,7 @@ whitespace to test that's correctly stripped)... |
37 | |
38 | We can edit the attachment to be a patch. |
39 | |
40 | - >>> user_browser.getLink(url=re.compile(r'[+]attachment/\d+$')).click() |
41 | + >>> user_browser.getLink(url=re.compile(r'.*/\+attachment/\d+$')).click() |
42 | >>> patch_control = user_browser.getControl( |
43 | ... 'This attachment contains a solution (patch) for this bug') |
44 | >>> patch_control.selected = True |
45 | diff --git a/lib/lp/bugs/stories/bugattachments/xx-delete-bug-attachment.txt b/lib/lp/bugs/stories/bugattachments/xx-delete-bug-attachment.txt |
46 | index 03901c1..53ab490 100644 |
47 | --- a/lib/lp/bugs/stories/bugattachments/xx-delete-bug-attachment.txt |
48 | +++ b/lib/lp/bugs/stories/bugattachments/xx-delete-bug-attachment.txt |
49 | @@ -36,7 +36,7 @@ If we go to the attachment edit page, there's an option to delete the |
50 | attachment. |
51 | |
52 | >>> import re |
53 | - >>> user_browser.getLink(url=re.compile(r'[+]attachment/\d+$')).click() |
54 | + >>> user_browser.getLink(url=re.compile(r'.*/\+attachment/\d+$')).click() |
55 | >>> print(user_browser.title) |
56 | Bug #2... |
57 | >>> user_browser.getControl('Delete Attachment') is not None |
58 | diff --git a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt |
59 | index 94edcd6..03484d4 100644 |
60 | --- a/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt |
61 | +++ b/lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt |
62 | @@ -200,7 +200,7 @@ bug reporting guidelines can be changed, but admins do. |
63 | >>> def extract_text_from_link(link): |
64 | ... pass |
65 | |
66 | - >>> edit_url_re = re.compile('/[+]edit$') |
67 | + >>> edit_url_re = re.compile('.*/\+edit$') |
68 | >>> for context_name, context_path, view in contexts: |
69 | ... overview_url = 'http://launchpad.test/%s' % (context_path,) |
70 | ... print('* ' + context_name) |
71 | diff --git a/lib/lp/buildmaster/stories/xx-builder-page.txt b/lib/lp/buildmaster/stories/xx-builder-page.txt |
72 | index bde5653..fed6bf4 100644 |
73 | --- a/lib/lp/buildmaster/stories/xx-builder-page.txt |
74 | +++ b/lib/lp/buildmaster/stories/xx-builder-page.txt |
75 | @@ -132,7 +132,7 @@ Other administration fields are available on the 'Change details' form |
76 | as currently administrators are the only users with permission to use the |
77 | Edit page: |
78 | |
79 | - >>> cprov_browser.getControl(name="field.manual").value |
80 | + >>> bool(cprov_browser.getControl(name="field.manual").value) |
81 | False |
82 | |
83 | >>> cprov_browser.getControl(name="field.vm_host").value |
84 | diff --git a/lib/lp/code/browser/tests/test_branch.py b/lib/lp/code/browser/tests/test_branch.py |
85 | index 5a173cb..4c9f473 100644 |
86 | --- a/lib/lp/code/browser/tests/test_branch.py |
87 | +++ b/lib/lp/code/browser/tests/test_branch.py |
88 | @@ -1306,11 +1306,13 @@ class TestBranchDiffView(BrowserTestCase): |
89 | hosting_fixture = self.useFixture(BranchHostingFixture()) |
90 | person = self.factory.makePerson() |
91 | branch = self.factory.makeBranch(owner=person) |
92 | - e = self.assertRaises( |
93 | - HTTPError, self.getUserBrowser, |
94 | - canonical_url(branch) + "/+diff/2/1") |
95 | - self.assertEqual(401, e.code) |
96 | - self.assertEqual("Proxying of branch diffs is disabled.\n", e.read()) |
97 | + branch_url = canonical_url(branch) |
98 | + browser = self.getUserBrowser() |
99 | + browser.raiseHttpErrors = False |
100 | + browser.open(branch_url + "/+diff/2/1") |
101 | + self.assertEqual(401, int(browser.headers["Status"].split(" ", 1)[0])) |
102 | + self.assertEqual( |
103 | + "Proxying of branch diffs is disabled.\n", browser.contents) |
104 | self.assertEqual([], hosting_fixture.getDiff.calls) |
105 | |
106 | def test_render(self): |
107 | diff --git a/lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt b/lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt |
108 | index 5a812f5..07a4613 100644 |
109 | --- a/lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt |
110 | +++ b/lib/lp/registry/stories/distribution/xx-distribution-launchpad-usage.txt |
111 | @@ -46,7 +46,8 @@ The distribution's registrant can access the page and change the usage. |
112 | LAUNCHPAD |
113 | >>> print registrant.getControl(name='field.answers_usage').value[0] |
114 | LAUNCHPAD |
115 | - >>> print registrant.getControl(name='field.require_virtualized').value |
116 | + >>> print bool( |
117 | + ... registrant.getControl(name='field.require_virtualized').value) |
118 | False |
119 | >>> print registrant.getControl(name='field.processors').value |
120 | ['386', 'amd64', 'hppa'] |
121 | diff --git a/lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt b/lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt |
122 | index 34ab34c..f83f7e5 100644 |
123 | --- a/lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt |
124 | +++ b/lib/lp/registry/stories/gpg-coc/xx-gpg-coc.txt |
125 | @@ -324,7 +324,8 @@ On a mad whim they decide to de-activate the key they just imported. |
126 | |
127 | Coming to their senses, they ask for a re-validation of the key. |
128 | |
129 | - >>> browser.getControl(name="REACTIVATE_GPGKEY").value = ['3'] |
130 | + >>> browser.getControl(name="REACTIVATE_GPGKEY").value = [ |
131 | + ... '447DBF38C4F9C4ED752246B77D88913717B05A8F'] |
132 | >>> browser.getControl('Reactivate Key').click() |
133 | |
134 | >>> print_feedback_messages(browser.contents) |
135 | diff --git a/lib/lp/registry/stories/mailinglists/subscriptions.txt b/lib/lp/registry/stories/mailinglists/subscriptions.txt |
136 | index f1f7c3f..c0a3408 100644 |
137 | --- a/lib/lp/registry/stories/mailinglists/subscriptions.txt |
138 | +++ b/lib/lp/registry/stories/mailinglists/subscriptions.txt |
139 | @@ -217,8 +217,7 @@ Now Jdub can apply for team membership and mailing list access. |
140 | >>> browser.url |
141 | 'http://launchpad.test/~rosetta-admins/+join' |
142 | |
143 | - >>> browser.getControl(name='field.mailinglist_subscribe').value = [ |
144 | - ... 'checked'] |
145 | + >>> browser.getControl(name='field.mailinglist_subscribe').value = True |
146 | >>> browser.getControl(name='field.actions.join').click() |
147 | >>> browser.url |
148 | 'http://launchpad.test/~rosetta-admins' |
149 | @@ -595,7 +594,8 @@ lists will not have the box checked. |
150 | |
151 | >>> browser.open('http://launchpad.test/~rosetta-admins') |
152 | >>> browser.getLink('Join the team').click() |
153 | - >>> print browser.getControl(name='field.mailinglist_subscribe').value |
154 | + >>> print bool( |
155 | + ... browser.getControl(name='field.mailinglist_subscribe').value) |
156 | False |
157 | |
158 | # Restore James' setting. |
159 | diff --git a/lib/lp/registry/stories/milestone/object-milestones.txt b/lib/lp/registry/stories/milestone/object-milestones.txt |
160 | index f0752f1..d1ef248 100644 |
161 | --- a/lib/lp/registry/stories/milestone/object-milestones.txt |
162 | +++ b/lib/lp/registry/stories/milestone/object-milestones.txt |
163 | @@ -322,7 +322,7 @@ We'll use a specific URL pattern to avoid matching unrelated links. |
164 | Let's start with the first bug task: |
165 | |
166 | >>> import re |
167 | - >>> edit_status_url = re.compile(r'1.0/\+bug/[0-9]+/\+editstatus') |
168 | + >>> edit_status_url = re.compile(r'.*/1.0/\+bug/[0-9]+/\+editstatus') |
169 | >>> browser.getLink(url=edit_status_url).click() |
170 | |
171 | Completing the "edit status" form allows us to add the bug task to the |
172 | @@ -339,7 +339,7 @@ milestone: |
173 | Now we'll add the second bug task to the test milestone, using the same |
174 | method. However this time we'll use a different importance: |
175 | |
176 | - >>> edit_status_url = re.compile(r'2.0/\+bug/[0-9]+/\+editstatus') |
177 | + >>> edit_status_url = re.compile(r'.*/2.0/\+bug/[0-9]+/\+editstatus') |
178 | >>> browser.getLink(url=edit_status_url).click() |
179 | >>> browser.getControl('Milestone').displayValue = [milestone] |
180 | >>> browser.getControl('Importance').value = ['High'] |
181 | diff --git a/lib/lp/registry/stories/product/xx-product-add.txt b/lib/lp/registry/stories/product/xx-product-add.txt |
182 | index b2841b2..b418979 100644 |
183 | --- a/lib/lp/registry/stories/product/xx-product-add.txt |
184 | +++ b/lib/lp/registry/stories/product/xx-product-add.txt |
185 | @@ -142,7 +142,7 @@ interested in being the project maintainer for the long run. |
186 | >>> user_browser.getControl('Continue').click() |
187 | >>> user_browser.getControl('Python Licence').click() |
188 | >>> disclaim = user_browser.getControl(name='field.disclaim_maintainer') |
189 | - >>> disclaim.value = ['checked'] |
190 | + >>> disclaim.value = True |
191 | >>> user_browser.getControl('Complete Registration').click() |
192 | |
193 | Sample person is shown as the registrant but the maintainer is now |
194 | diff --git a/lib/lp/registry/stories/team/xx-team-home.txt b/lib/lp/registry/stories/team/xx-team-home.txt |
195 | index b75b1e2..006b1a4 100644 |
196 | --- a/lib/lp/registry/stories/team/xx-team-home.txt |
197 | +++ b/lib/lp/registry/stories/team/xx-team-home.txt |
198 | @@ -159,7 +159,7 @@ address: |
199 | As teams do not have OpenID Logins, there is no link in the Contact |
200 | details section for help. |
201 | |
202 | - >>> sample_browser.getLink('(What\xe2\x80\x99s\xc2\xa0this?)') |
203 | + >>> sample_browser.getLink('OpenID help') |
204 | Traceback (most recent call last): |
205 | ... |
206 | LinkNotFoundError |
207 | diff --git a/lib/lp/services/webapp/login.py b/lib/lp/services/webapp/login.py |
208 | index 0dcb795..b9076b1 100644 |
209 | --- a/lib/lp/services/webapp/login.py |
210 | +++ b/lib/lp/services/webapp/login.py |
211 | @@ -225,6 +225,8 @@ class OpenIDLogin(LaunchpadView): |
212 | return_to = urlappend(trust_root, '+openid-callback') |
213 | return_to = "%s?%s" % (return_to, starting_url) |
214 | form_html = self.openid_request.htmlMarkup(trust_root, return_to) |
215 | + self.request.response.setHeader( |
216 | + 'Content-Type', 'text/html; charset="utf-8"') |
217 | |
218 | # The consumer.begin() call above will insert rows into the |
219 | # OpenIDAssociations table, but since this will be a GET request, the |
220 | diff --git a/lib/lp/services/webapp/tests/test_error.py b/lib/lp/services/webapp/tests/test_error.py |
221 | index 7f52168..4485f09 100644 |
222 | --- a/lib/lp/services/webapp/tests/test_error.py |
223 | +++ b/lib/lp/services/webapp/tests/test_error.py |
224 | @@ -147,11 +147,13 @@ class TestDatabaseErrorViews(TestCase): |
225 | super(Disconnects, self).__init__( |
226 | ('DisconnectionError', message)) |
227 | |
228 | + browser = Browser() |
229 | + browser.raiseHttpErrors = False |
230 | with CaptureOops() as oopses: |
231 | - error = self.getHTTPError(url) |
232 | - self.assertEqual(503, error.code) |
233 | - self.assertThat(error.read(), |
234 | - Contains(DisconnectionErrorView.reason)) |
235 | + browser.open(url) |
236 | + self.assertEqual(503, int(browser.headers['Status'].split(' ', 1)[0])) |
237 | + self.assertThat( |
238 | + browser.contents, Contains(DisconnectionErrorView.reason)) |
239 | self.assertThat( |
240 | [(oops['type'], oops['value'].split('\n')[0]) |
241 | for oops in oopses.oopses], |
242 | @@ -168,10 +170,10 @@ class TestDatabaseErrorViews(TestCase): |
243 | |
244 | # We keep seeing the correct exception on subsequent requests. |
245 | with CaptureOops() as oopses: |
246 | - error = self.getHTTPError(url) |
247 | - self.assertEqual(503, error.code) |
248 | - self.assertThat(error.read(), |
249 | - Contains(DisconnectionErrorView.reason)) |
250 | + browser.open(url) |
251 | + self.assertEqual(503, int(browser.headers['Status'].split(' ', 1)[0])) |
252 | + self.assertThat( |
253 | + browser.contents, Contains(DisconnectionErrorView.reason)) |
254 | self.assertThat( |
255 | [(oops['type'], oops['value'].split('\n')[0]) |
256 | for oops in oopses.oopses], |
257 | @@ -198,10 +200,10 @@ class TestDatabaseErrorViews(TestCase): |
258 | cur.execute("RESUME " + dbname) |
259 | |
260 | with CaptureOops() as oopses: |
261 | - error = self.getHTTPError(url) |
262 | - self.assertEqual(503, error.code) |
263 | - self.assertThat(error.read(), |
264 | - Contains(DisconnectionErrorView.reason)) |
265 | + browser.open(url) |
266 | + self.assertEqual(503, int(browser.headers['Status'].split(' ', 1)[0])) |
267 | + self.assertThat( |
268 | + browser.contents, Contains(DisconnectionErrorView.reason)) |
269 | self.assertThat( |
270 | [(oops['type'], oops['value'].split('\n')[0]) |
271 | for oops in oopses.oopses], |
272 | @@ -209,10 +211,10 @@ class TestDatabaseErrorViews(TestCase): |
273 | |
274 | # A second request doesn't log any OOPSes. |
275 | with CaptureOops() as oopses: |
276 | - error = self.getHTTPError(url) |
277 | - self.assertEqual(503, error.code) |
278 | - self.assertThat(error.read(), |
279 | - Contains(DisconnectionErrorView.reason)) |
280 | + browser.open(url) |
281 | + self.assertEqual(503, int(browser.headers['Status'].split(' ', 1)[0])) |
282 | + self.assertThat( |
283 | + browser.contents, Contains(DisconnectionErrorView.reason)) |
284 | self.assertEqual( |
285 | [], |
286 | [(oops['type'], oops['value'].split('\n')[0]) |
287 | @@ -240,10 +242,14 @@ class TestDatabaseErrorViews(TestCase): |
288 | "error-test")) |
289 | |
290 | url = 'http://launchpad.test/error-test' |
291 | - error = self.getHTTPError(url) |
292 | - self.assertEqual(httplib.SERVICE_UNAVAILABLE, error.code) |
293 | - self.assertThat(error.read(), |
294 | - Contains(OperationalErrorView.reason)) |
295 | + browser = Browser() |
296 | + browser.raiseHttpErrors = False |
297 | + browser.open(url) |
298 | + self.assertEqual( |
299 | + httplib.SERVICE_UNAVAILABLE, |
300 | + int(browser.headers['Status'].split(' ', 1)[0])) |
301 | + self.assertThat( |
302 | + browser.contents, Contains(OperationalErrorView.reason)) |
303 | |
304 | def test_operationalerror_view(self): |
305 | request = LaunchpadTestRequest() |
306 | diff --git a/lib/lp/snappy/tests/test_snapbuild.py b/lib/lp/snappy/tests/test_snapbuild.py |
307 | index aa69ae3..67e2be1 100644 |
308 | --- a/lib/lp/snappy/tests/test_snapbuild.py |
309 | +++ b/lib/lp/snappy/tests/test_snapbuild.py |
310 | @@ -11,10 +11,7 @@ from datetime import ( |
311 | datetime, |
312 | timedelta, |
313 | ) |
314 | -from urllib2 import ( |
315 | - HTTPError, |
316 | - urlopen, |
317 | - ) |
318 | +from urllib2 import urlopen |
319 | |
320 | from fixtures import FakeLogger |
321 | from pymacaroons import Macaroon |
322 | @@ -802,9 +799,9 @@ class TestSnapBuildWebservice(TestCaseWithFactory): |
323 | self.assertEqual(5000, build["score"]) |
324 | |
325 | def assertCanOpenRedirectedUrl(self, browser, url): |
326 | - redirection = self.assertRaises(HTTPError, browser.open, url) |
327 | - self.assertEqual(303, redirection.code) |
328 | - urlopen(redirection.hdrs["Location"]).close() |
329 | + browser.open(url) |
330 | + self.assertEqual(303, int(browser.headers["Status"].split(" ", 1)[0])) |
331 | + urlopen(browser.headers["Location"]).close() |
332 | |
333 | def test_logs(self): |
334 | # API clients can fetch the build and upload logs. |
335 | @@ -815,6 +812,7 @@ class TestSnapBuildWebservice(TestCaseWithFactory): |
336 | logout() |
337 | build = self.webservice.get(build_url).jsonBody() |
338 | browser = self.getNonRedirectingBrowser(user=self.person) |
339 | + browser.raiseHttpErrors = False |
340 | self.assertIsNotNone(build["build_log_url"]) |
341 | self.assertCanOpenRedirectedUrl(browser, build["build_log_url"]) |
342 | self.assertIsNotNone(build["upload_log_url"]) |
343 | @@ -834,6 +832,7 @@ class TestSnapBuildWebservice(TestCaseWithFactory): |
344 | self.assertEqual(200, response.status) |
345 | self.assertContentEqual(file_urls, response.jsonBody()) |
346 | browser = self.getNonRedirectingBrowser(user=self.person) |
347 | + browser.raiseHttpErrors = False |
348 | for file_url in file_urls: |
349 | self.assertCanOpenRedirectedUrl(browser, file_url) |
350 | |
351 | diff --git a/lib/lp/soyuz/stories/ppa/xx-ppa-workflow.txt b/lib/lp/soyuz/stories/ppa/xx-ppa-workflow.txt |
352 | index f22cd6b..95e5e11 100644 |
353 | --- a/lib/lp/soyuz/stories/ppa/xx-ppa-workflow.txt |
354 | +++ b/lib/lp/soyuz/stories/ppa/xx-ppa-workflow.txt |
355 | @@ -372,10 +372,10 @@ build on a virtualized builder. |
356 | |
357 | >>> admin_browser.getControl(name="field.enabled").value |
358 | True |
359 | - >>> admin_browser.getControl(name="field.private").value |
360 | + >>> bool(admin_browser.getControl(name="field.private").value) |
361 | False |
362 | - >>> admin_browser.getControl( |
363 | - ... name="field.suppress_subscription_notifications").value |
364 | + >>> bool(admin_browser.getControl( |
365 | + ... name="field.suppress_subscription_notifications").value) |
366 | False |
367 | >>> admin_browser.getControl(name="field.require_virtualized").value |
368 | True |
369 | @@ -730,12 +730,12 @@ Going back to the edit page, we can see the publish flag was cleared: |
370 | |
371 | >>> no_priv_browser.open( |
372 | ... "http://launchpad.test/~no-priv/+archive/ppa/+edit") |
373 | - >>> print(no_priv_browser.getControl(name='field.publish').value) |
374 | + >>> bool(no_priv_browser.getControl(name='field.publish').value) |
375 | False |
376 | |
377 | Once we re-enable the PPA the "disabled" warning message will be gone. |
378 | |
379 | - >>> print(no_priv_browser.getControl(name='field.enabled').value) |
380 | + >>> bool(no_priv_browser.getControl(name='field.enabled').value) |
381 | False |
382 | |
383 | >>> no_priv_browser.getControl(name='field.enabled').value = True |
384 | diff --git a/lib/lp/soyuz/tests/test_livefsbuild.py b/lib/lp/soyuz/tests/test_livefsbuild.py |
385 | index 13499bc..987c6b1 100644 |
386 | --- a/lib/lp/soyuz/tests/test_livefsbuild.py |
387 | +++ b/lib/lp/soyuz/tests/test_livefsbuild.py |
388 | @@ -11,10 +11,7 @@ from datetime import ( |
389 | datetime, |
390 | timedelta, |
391 | ) |
392 | -from urllib2 import ( |
393 | - HTTPError, |
394 | - urlopen, |
395 | - ) |
396 | +from urllib2 import urlopen |
397 | |
398 | import pytz |
399 | from zope.component import getUtility |
400 | @@ -453,9 +450,9 @@ class TestLiveFSBuildWebservice(TestCaseWithFactory): |
401 | self.assertEqual(5000, build["score"]) |
402 | |
403 | def assertCanOpenRedirectedUrl(self, browser, url): |
404 | - redirection = self.assertRaises(HTTPError, browser.open, url) |
405 | - self.assertEqual(303, redirection.code) |
406 | - urlopen(redirection.hdrs["Location"]).close() |
407 | + browser.open(url) |
408 | + self.assertEqual(303, int(browser.headers["Status"].split(" ", 1)[0])) |
409 | + urlopen(browser.headers["Location"]).close() |
410 | |
411 | def test_logs(self): |
412 | # API clients can fetch the build and upload logs. |
413 | @@ -466,6 +463,7 @@ class TestLiveFSBuildWebservice(TestCaseWithFactory): |
414 | logout() |
415 | build = self.webservice.get(build_url).jsonBody() |
416 | browser = self.getNonRedirectingBrowser(user=self.person) |
417 | + browser.raiseHttpErrors = False |
418 | self.assertIsNotNone(build["build_log_url"]) |
419 | self.assertCanOpenRedirectedUrl(browser, build["build_log_url"]) |
420 | self.assertIsNotNone(build["upload_log_url"]) |
421 | @@ -486,5 +484,6 @@ class TestLiveFSBuildWebservice(TestCaseWithFactory): |
422 | self.assertEqual(200, response.status) |
423 | self.assertContentEqual(file_urls, response.jsonBody()) |
424 | browser = self.getNonRedirectingBrowser(user=self.person) |
425 | + browser.raiseHttpErrors = False |
426 | for file_url in file_urls: |
427 | self.assertCanOpenRedirectedUrl(browser, file_url) |
428 | diff --git a/lib/lp/soyuz/tests/test_packageupload.py b/lib/lp/soyuz/tests/test_packageupload.py |
429 | index 3fe2e73..5f78fe2 100644 |
430 | --- a/lib/lp/soyuz/tests/test_packageupload.py |
431 | +++ b/lib/lp/soyuz/tests/test_packageupload.py |
432 | @@ -7,10 +7,7 @@ from __future__ import absolute_import, print_function, unicode_literals |
433 | |
434 | from datetime import timedelta |
435 | import io |
436 | -from urllib2 import ( |
437 | - HTTPError, |
438 | - urlopen, |
439 | - ) |
440 | +from urllib2 import urlopen |
441 | |
442 | from debian.deb822 import Changes |
443 | from lazr.restfulclient.errors import ( |
444 | @@ -1044,9 +1041,9 @@ class TestPackageUploadWebservice(TestCaseWithFactory): |
445 | return upload, self.load(upload, person) |
446 | |
447 | def assertCanOpenRedirectedUrl(self, browser, url): |
448 | - redirection = self.assertRaises(HTTPError, browser.open, url) |
449 | - self.assertEqual(303, redirection.code) |
450 | - urlopen(redirection.hdrs["Location"]).close() |
451 | + browser.open(url) |
452 | + self.assertEqual(303, int(browser.headers["Status"].split(" ", 1)[0])) |
453 | + urlopen(browser.headers["Location"]).close() |
454 | |
455 | def assertRequiresEdit(self, method_name, **kwargs): |
456 | """Test that a web service queue method requires launchpad.Edit.""" |
457 | @@ -1128,6 +1125,7 @@ class TestPackageUploadWebservice(TestCaseWithFactory): |
458 | self.assertContentEqual(source_file_urls, ws_source_file_urls) |
459 | |
460 | browser = self.getNonRedirectingBrowser(user=person) |
461 | + browser.raiseHttpErrors = False |
462 | for ws_source_file_url in ws_source_file_urls: |
463 | self.assertCanOpenRedirectedUrl(browser, ws_source_file_url) |
464 | self.assertCanOpenRedirectedUrl(browser, ws_upload.changes_file_url) |
465 | @@ -1217,6 +1215,7 @@ class TestPackageUploadWebservice(TestCaseWithFactory): |
466 | self.assertContentEqual(binary_file_urls, ws_binary_file_urls) |
467 | |
468 | browser = self.getNonRedirectingBrowser(user=person) |
469 | + browser.raiseHttpErrors = False |
470 | for ws_binary_file_url in ws_binary_file_urls: |
471 | self.assertCanOpenRedirectedUrl(browser, ws_binary_file_url) |
472 | self.assertCanOpenRedirectedUrl(browser, ws_upload.changes_file_url) |
473 | @@ -1380,6 +1379,7 @@ class TestPackageUploadWebservice(TestCaseWithFactory): |
474 | self.assertContentEqual(custom_file_urls, ws_custom_file_urls) |
475 | |
476 | browser = self.getNonRedirectingBrowser(user=person) |
477 | + browser.raiseHttpErrors = False |
478 | for ws_custom_file_url in ws_custom_file_urls: |
479 | self.assertCanOpenRedirectedUrl(browser, ws_custom_file_url) |
480 | self.assertCanOpenRedirectedUrl(browser, ws_upload.changes_file_url) |
481 | diff --git a/lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt b/lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt |
482 | index c6dc1ff..b7cb1c1 100644 |
483 | --- a/lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt |
484 | +++ b/lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt |
485 | @@ -201,8 +201,7 @@ navigation. |
486 | 1 ... 10 of 22 results |
487 | |
488 | >>> user_browser.getControl( |
489 | - ... name='msgset_1_en_AU_translation_0_new_checkbox').value = [ |
490 | - ... 'msgset_1_en_AU_translation_0_new'] |
491 | + ... name='msgset_1_en_AU_translation_0_new_checkbox').value = True |
492 | >>> user_browser.getControl( |
493 | ... name='msgset_1_en_AU_translation_0_new').value = 'fnord' |
494 | >>> user_browser.getControl('Save & Continue').click() |
495 | diff --git a/lib/lp/translations/stories/standalone/xx-potemplate-admin.txt b/lib/lp/translations/stories/standalone/xx-potemplate-admin.txt |
496 | index 500a58c..bf9852a 100644 |
497 | --- a/lib/lp/translations/stories/standalone/xx-potemplate-admin.txt |
498 | +++ b/lib/lp/translations/stories/standalone/xx-potemplate-admin.txt |
499 | @@ -59,7 +59,7 @@ a Rosetta Expert to administer it. |
500 | '' |
501 | >>> browser.getControl(name='field.sourcepackageversion').value |
502 | '' |
503 | - >>> browser.getControl(name='field.languagepack').value |
504 | + >>> bool(browser.getControl(name='field.languagepack').value) |
505 | False |
506 | >>> browser.getControl(name='field.path').value |
507 | 'po/evolution-2.2.pot' |
508 | @@ -105,7 +105,7 @@ an admin to administer it. |
509 | '' |
510 | >>> admin_browser.getControl(name='field.sourcepackageversion').value |
511 | '' |
512 | - >>> admin_browser.getControl(name='field.languagepack').value |
513 | + >>> bool(admin_browser.getControl(name='field.languagepack').value) |
514 | False |
515 | >>> admin_browser.getControl(name='field.path').value |
516 | 'po/evolution-2.2.pot' |
517 | diff --git a/lib/lp/translations/stories/standalone/xx-potemplate-edit.txt b/lib/lp/translations/stories/standalone/xx-potemplate-edit.txt |
518 | index 03665bd..d46ac09 100644 |
519 | --- a/lib/lp/translations/stories/standalone/xx-potemplate-edit.txt |
520 | +++ b/lib/lp/translations/stories/standalone/xx-potemplate-edit.txt |
521 | @@ -139,7 +139,7 @@ page. |
522 | >>> browser.getControl(name='field.priority').value |
523 | '100' |
524 | |
525 | - >>> browser.getControl(name='field.iscurrent').value |
526 | + >>> bool(browser.getControl(name='field.iscurrent').value) |
527 | False |
528 | |
529 | >>> browser.getControl(name='field.path').value |
530 | diff --git a/lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt b/lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt |
531 | index a15080f..dda582b 100644 |
532 | --- a/lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt |
533 | +++ b/lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt |
534 | @@ -348,7 +348,8 @@ Check for the translator note: |
535 | |
536 | Also check that the alternative language selection is working: |
537 | |
538 | - >>> browser.getControl('Catalan (ca)').click() |
539 | + >>> browser.getControl(name='field.alternative_language').getControl( |
540 | + ... 'Catalan (ca)').click() |
541 | >>> browser.getControl('Change').click() |
542 | >>> browser.url |
543 | 'http:/...field.alternative_language=ca...' |