Merge lp:~cjwatson/launchpad/soyuz-browser-tests-future-imports into lp:launchpad
- soyuz-browser-tests-future-imports
- Merge into devel
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 18545 |
Proposed branch: | lp:~cjwatson/launchpad/soyuz-browser-tests-future-imports |
Merge into: | lp:launchpad |
Diff against target: |
833 lines (+175/-69) 26 files modified
lib/lp/code/browser/tests/test_branch.py (+2/-2) lib/lp/code/browser/tests/test_branchmergeproposal.py (+17/-12) lib/lp/code/browser/tests/test_gitlisting.py (+4/-4) lib/lp/code/browser/tests/test_gitrepository.py (+2/-2) lib/lp/services/webapp/servers.py (+37/-1) lib/lp/services/webapp/tests/test_servers.py (+25/-0) lib/lp/soyuz/browser/tests/test_archive.py (+4/-2) lib/lp/soyuz/browser/tests/test_archive_admin_view.py (+3/-1) lib/lp/soyuz/browser/tests/test_archive_packages.py (+4/-2) lib/lp/soyuz/browser/tests/test_archive_webservice.py (+3/-1) lib/lp/soyuz/browser/tests/test_breadcrumbs.py (+3/-1) lib/lp/soyuz/browser/tests/test_build_views.py (+5/-3) lib/lp/soyuz/browser/tests/test_distributionsourcepackagerelease.py (+3/-1) lib/lp/soyuz/browser/tests/test_distroarchseries_view.py (+3/-1) lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py (+3/-1) lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py (+3/-1) lib/lp/soyuz/browser/tests/test_livefs.py (+14/-12) lib/lp/soyuz/browser/tests/test_livefsbuild.py (+12/-8) lib/lp/soyuz/browser/tests/test_package_copying_mixin.py (+3/-1) lib/lp/soyuz/browser/tests/test_personal_archive_subscription.py (+3/-1) lib/lp/soyuz/browser/tests/test_publishing.py (+3/-1) lib/lp/soyuz/browser/tests/test_publishing_webservice.py (+3/-1) lib/lp/soyuz/browser/tests/test_queue.py (+4/-2) lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py (+3/-1) lib/lp/soyuz/browser/tests/test_sourceslistentries.py (+5/-3) lib/lp/soyuz/browser/tests/test_views.py (+4/-4) |
To merge this branch: | bzr merge lp:~cjwatson/launchpad/soyuz-browser-tests-future-imports |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+337010@code.launchpad.net |
Commit message
Convert lp.soyuz.
Description of the change
In the process of doing this I realised that we need to go to a bit of effort to satisfy the requirements of PEP 3333, and in the process of testing *that* I found that there were various tests that passed a principal into LaunchpadTestRe
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
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/code/browser/tests/test_branch.py' |
2 | --- lib/lp/code/browser/tests/test_branch.py 2018-01-02 16:10:26 +0000 |
3 | +++ lib/lp/code/browser/tests/test_branch.py 2018-02-01 18:46:27 +0000 |
4 | @@ -1,4 +1,4 @@ |
5 | -# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
6 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
7 | # GNU Affero General Public License version 3 (see the file LICENSE). |
8 | |
9 | """Unit tests for BranchView.""" |
10 | @@ -1109,7 +1109,7 @@ |
11 | if user is None: |
12 | user = removeSecurityProxy(branch).owner |
13 | with person_logged_in(user): |
14 | - view = create_initialized_view(branch, '+edit', user=user) |
15 | + view = create_initialized_view(branch, '+edit', principal=user) |
16 | self.assertContentEqual(types, view.getInformationTypesToShow()) |
17 | |
18 | def test_public_branch(self): |
19 | |
20 | === modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py' |
21 | --- lib/lp/code/browser/tests/test_branchmergeproposal.py 2018-01-02 10:54:31 +0000 |
22 | +++ lib/lp/code/browser/tests/test_branchmergeproposal.py 2018-02-01 18:46:27 +0000 |
23 | @@ -1,4 +1,4 @@ |
24 | -# Copyright 2009-2017 Canonical Ltd. This software is licensed under the |
25 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
26 | # GNU Affero General Public License version 3 (see the file LICENSE). |
27 | |
28 | """Unit tests for BranchMergeProposals.""" |
29 | @@ -565,8 +565,8 @@ |
30 | target_branch = self._makeTargetBranch() |
31 | reviewer = self.factory.makePerson() |
32 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
33 | - request = LaunchpadTestRequest( |
34 | - method='POST', principal=owner, **extra) |
35 | + request = LaunchpadTestRequest(method='POST', **extra) |
36 | + request.setPrincipal(owner) |
37 | view = self._createView(request=request) |
38 | with person_logged_in(owner): |
39 | result_data = view.register_action.success(self._getFormValues( |
40 | @@ -767,8 +767,8 @@ |
41 | owner=owner, information_type=InformationType.USERDATA) |
42 | reviewer = self.factory.makePerson() |
43 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
44 | - request = LaunchpadTestRequest( |
45 | - method='POST', principal=owner, **extra) |
46 | + request = LaunchpadTestRequest(method='POST', **extra) |
47 | + request.setPrincipal(owner) |
48 | view = self._createView(request=request) |
49 | with person_logged_in(owner): |
50 | branches_to_check = [self.source_branch.unique_name, |
51 | @@ -796,12 +796,13 @@ |
52 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
53 | with person_logged_in(owner): |
54 | request = LaunchpadTestRequest( |
55 | - method='POST', principal=owner, |
56 | + method='POST', |
57 | form={ |
58 | 'field.actions.register': 'Propose Merge', |
59 | 'field.target_branch.target_branch': |
60 | target_branch.unique_name}, |
61 | **extra) |
62 | + request.setPrincipal(owner) |
63 | view = create_initialized_view( |
64 | target_branch, |
65 | name='+register-merge', |
66 | @@ -856,8 +857,8 @@ |
67 | owner=owner, information_type=InformationType.USERDATA) |
68 | reviewer = self.factory.makePerson() |
69 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
70 | - request = LaunchpadTestRequest( |
71 | - method='POST', principal=owner, **extra) |
72 | + request = LaunchpadTestRequest(method='POST', **extra) |
73 | + request.setPrincipal(owner) |
74 | view = self._createView(request=request) |
75 | with person_logged_in(owner): |
76 | repositories_to_check = [ |
77 | @@ -887,7 +888,7 @@ |
78 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
79 | with person_logged_in(owner): |
80 | request = LaunchpadTestRequest( |
81 | - method='POST', principal=owner, |
82 | + method='POST', |
83 | form={ |
84 | 'field.actions.register': 'Propose Merge', |
85 | 'field.target_git_repository.target_git_repository': |
86 | @@ -895,6 +896,7 @@ |
87 | 'field.target_git_path': target_branch.path, |
88 | }, |
89 | **extra) |
90 | + request.setPrincipal(owner) |
91 | view = create_initialized_view( |
92 | target_branch, |
93 | name='+register-merge', |
94 | @@ -916,7 +918,7 @@ |
95 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
96 | with person_logged_in(owner): |
97 | request = LaunchpadTestRequest( |
98 | - method='POST', principal=owner, |
99 | + method='POST', |
100 | form={ |
101 | 'field.actions.register': 'Propose Merge', |
102 | 'field.target_git_repository.target_git_repository': '', |
103 | @@ -924,6 +926,7 @@ |
104 | 'field.target_git_path': 'master', |
105 | }, |
106 | **extra) |
107 | + request.setPrincipal(owner) |
108 | view = create_initialized_view( |
109 | self.source_branch, |
110 | name='+register-merge', |
111 | @@ -946,13 +949,14 @@ |
112 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
113 | with person_logged_in(owner): |
114 | request = LaunchpadTestRequest( |
115 | - method='POST', principal=owner, |
116 | + method='POST', |
117 | form={ |
118 | 'field.actions.register': 'Propose Merge', |
119 | 'field.target_git_repository.target_git_repository': |
120 | target_branch.repository.unique_name, |
121 | }, |
122 | **extra) |
123 | + request.setPrincipal(owner) |
124 | view = create_initialized_view( |
125 | self.source_branch, |
126 | name='+register-merge', |
127 | @@ -979,7 +983,7 @@ |
128 | extra = {'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'} |
129 | with person_logged_in(owner): |
130 | request = LaunchpadTestRequest( |
131 | - method='POST', principal=owner, |
132 | + method='POST', |
133 | form={ |
134 | 'field.actions.register': 'Propose Merge', |
135 | 'field.target_git_repository.target_git_repository': |
136 | @@ -989,6 +993,7 @@ |
137 | prerequisite_branch.repository.unique_name, |
138 | }, |
139 | **extra) |
140 | + request.setPrincipal(owner) |
141 | view = create_initialized_view( |
142 | self.source_branch, |
143 | name='+register-merge', |
144 | |
145 | === modified file 'lib/lp/code/browser/tests/test_gitlisting.py' |
146 | --- lib/lp/code/browser/tests/test_gitlisting.py 2017-10-21 18:14:14 +0000 |
147 | +++ lib/lp/code/browser/tests/test_gitlisting.py 2018-02-01 18:46:27 +0000 |
148 | @@ -1,4 +1,4 @@ |
149 | -# Copyright 2015-2017 Canonical Ltd. This software is licensed under the |
150 | +# Copyright 2015-2018 Canonical Ltd. This software is licensed under the |
151 | # GNU Affero General Public License version 3 (see the file LICENSE). |
152 | |
153 | """Unit tests for Git listing views.""" |
154 | @@ -163,7 +163,7 @@ |
155 | # But someone who can see the repo gets the normal view. |
156 | with person_logged_in(self.owner): |
157 | owner_view = create_initialized_view( |
158 | - self.target, '+git', user=self.owner) |
159 | + self.target, '+git', principal=self.owner) |
160 | self.assertEqual(invisible_repo, owner_view.default_git_repository) |
161 | self.assertContentEqual( |
162 | [invisible_repo, other_repo], |
163 | @@ -291,7 +291,7 @@ |
164 | # But someone who can see the repo gets the normal view. |
165 | with person_logged_in(self.owner): |
166 | owner_view = create_initialized_view( |
167 | - self.owner_target, '+git', user=self.owner) |
168 | + self.owner_target, '+git', principal=self.owner) |
169 | self.assertEqual(invisible_repo, owner_view.default_git_repository) |
170 | self.assertContentEqual( |
171 | [invisible_repo, other_repo], |
172 | @@ -434,7 +434,7 @@ |
173 | # But someone who can see the repo gets the full view. |
174 | with person_logged_in(self.user): |
175 | owner_view = create_initialized_view( |
176 | - self.context, '+git', user=self.user) |
177 | + self.context, '+git', principal=self.user) |
178 | self.assertContentEqual( |
179 | [invisible_repo, other_repo], |
180 | owner_view.repo_collection.getRepositories()) |
181 | |
182 | === modified file 'lib/lp/code/browser/tests/test_gitrepository.py' |
183 | --- lib/lp/code/browser/tests/test_gitrepository.py 2017-10-21 18:14:14 +0000 |
184 | +++ lib/lp/code/browser/tests/test_gitrepository.py 2018-02-01 18:46:27 +0000 |
185 | @@ -1,4 +1,4 @@ |
186 | -# Copyright 2015-2017 Canonical Ltd. This software is licensed under the |
187 | +# Copyright 2015-2018 Canonical Ltd. This software is licensed under the |
188 | # GNU Affero General Public License version 3 (see the file LICENSE). |
189 | |
190 | """Unit tests for GitRepositoryView.""" |
191 | @@ -808,7 +808,7 @@ |
192 | if user is None: |
193 | user = removeSecurityProxy(repository).owner |
194 | with person_logged_in(user): |
195 | - view = create_initialized_view(repository, "+edit", user=user) |
196 | + view = create_initialized_view(repository, "+edit", principal=user) |
197 | self.assertContentEqual(types, view.getInformationTypesToShow()) |
198 | |
199 | def test_public_repository(self): |
200 | |
201 | === modified file 'lib/lp/services/webapp/servers.py' |
202 | --- lib/lp/services/webapp/servers.py 2018-01-30 17:49:56 +0000 |
203 | +++ lib/lp/services/webapp/servers.py 2018-02-01 18:46:27 +0000 |
204 | @@ -20,6 +20,7 @@ |
205 | ) |
206 | from lazr.restful.utils import get_current_browser_request |
207 | from lazr.uri import URI |
208 | +import six |
209 | import transaction |
210 | from transaction.interfaces import ISynchronizer |
211 | from zc.zservertracelog.tracelog import Server as ZServerTracelogServer |
212 | @@ -533,6 +534,31 @@ |
213 | return decoded_qs |
214 | |
215 | |
216 | +def wsgi_native_string(s): |
217 | + """Make a native string suitable for use in WSGI. |
218 | + |
219 | + PEP 3333 requires environment variables to be native strings that |
220 | + contain only code points representable in ISO-8859-1. To support |
221 | + porting to Python 3 via an intermediate stage of Unicode literals in |
222 | + Python 2, we enforce this here. |
223 | + """ |
224 | + # Based on twisted.python.compat.nativeString, but using a different |
225 | + # encoding. |
226 | + if not isinstance(s, (bytes, unicode)): |
227 | + raise TypeError('%r is neither bytes nor unicode' % s) |
228 | + if six.PY3: |
229 | + if isinstance(s, bytes): |
230 | + return s.decode('ISO-8859-1') |
231 | + else: |
232 | + # Ensure we're limited to ISO-8859-1. |
233 | + s.encode('ISO-8859-1') |
234 | + else: |
235 | + if isinstance(s, unicode): |
236 | + return s.encode('ISO-8859-1') |
237 | + # Bytes objects are always decodable as ISO-8859-1. |
238 | + return s |
239 | + |
240 | + |
241 | class LaunchpadBrowserRequestMixin: |
242 | """Provides methods used for both API and web browser requests.""" |
243 | |
244 | @@ -927,9 +953,19 @@ |
245 | def __init__(self, body_instream=None, environ=None, form=None, |
246 | skin=None, outstream=None, method='GET', |
247 | force_fresh_login_for_testing=False, **kw): |
248 | + # PEP 3333 requires environment variables to be native strings that |
249 | + # contain only code points representable in ISO-8859-1. To support |
250 | + # porting to Python 3 via an intermediate stage of Unicode literals |
251 | + # in Python 2, we enforce this here. |
252 | + native_kw = {} |
253 | + for key, value in kw.items(): |
254 | + if value is not None: |
255 | + value = wsgi_native_string(value) |
256 | + native_kw[key] = value |
257 | super(LaunchpadTestRequest, self).__init__( |
258 | body_instream=body_instream, environ=environ, form=form, |
259 | - skin=skin, outstream=outstream, REQUEST_METHOD=method, **kw) |
260 | + skin=skin, outstream=outstream, |
261 | + REQUEST_METHOD=wsgi_native_string(method), **native_kw) |
262 | self.traversed_objects = [] |
263 | # Use an existing feature controller if one exists, otherwise use the |
264 | # null controller. |
265 | |
266 | === modified file 'lib/lp/services/webapp/tests/test_servers.py' |
267 | --- lib/lp/services/webapp/tests/test_servers.py 2018-01-25 12:45:47 +0000 |
268 | +++ lib/lp/services/webapp/tests/test_servers.py 2018-02-01 18:46:27 +0000 |
269 | @@ -21,6 +21,7 @@ |
270 | IGenericEntry, |
271 | WebServiceTestCase, |
272 | ) |
273 | +import six |
274 | from zope.component import ( |
275 | getGlobalSiteManager, |
276 | getUtility, |
277 | @@ -47,6 +48,7 @@ |
278 | WebServicePublication, |
279 | WebServiceRequestPublicationFactory, |
280 | WebServiceTestRequest, |
281 | + wsgi_native_string, |
282 | ) |
283 | from lp.testing import ( |
284 | EventRecorder, |
285 | @@ -353,6 +355,29 @@ |
286 | request.response.getHeader('Vary'), 'Accept') |
287 | |
288 | |
289 | +class TestWSGINativeString(TestCase): |
290 | + |
291 | + def _toNative(self, s): |
292 | + if six.PY3: |
293 | + return s |
294 | + else: |
295 | + return s.encode('ISO-8859-1') |
296 | + |
297 | + def test_not_bytes_or_unicode(self): |
298 | + self.assertRaises(TypeError, wsgi_native_string, object()) |
299 | + |
300 | + def test_bytes_iso_8859_1(self): |
301 | + self.assertEqual( |
302 | + self._toNative(u'foo\xfe'), wsgi_native_string(b'foo\xfe')) |
303 | + |
304 | + def test_unicode_iso_8859_1(self): |
305 | + self.assertEqual( |
306 | + self._toNative(u'foo\xfe'), wsgi_native_string(u'foo\xfe')) |
307 | + |
308 | + def test_unicode_not_iso_8859_1(self): |
309 | + self.assertRaises(UnicodeEncodeError, wsgi_native_string, u'foo\u2014') |
310 | + |
311 | + |
312 | class TestBasicLaunchpadRequest(TestCase): |
313 | """Tests for the base request class""" |
314 | |
315 | |
316 | === modified file 'lib/lp/soyuz/browser/tests/test_archive.py' |
317 | --- lib/lp/soyuz/browser/tests/test_archive.py 2015-10-21 09:37:08 +0000 |
318 | +++ lib/lp/soyuz/browser/tests/test_archive.py 2018-02-01 18:46:27 +0000 |
319 | @@ -1,6 +1,8 @@ |
320 | -# Copyright 2014-2015 Canonical Ltd. This software is licensed under the |
321 | +# Copyright 2014-2018 Canonical Ltd. This software is licensed under the |
322 | # GNU Affero General Public License version 3 (see the file LICENSE). |
323 | |
324 | +from __future__ import absolute_import, print_function, unicode_literals |
325 | + |
326 | __metaclass__ = type |
327 | |
328 | from fixtures import FakeLogger |
329 | @@ -171,6 +173,6 @@ |
330 | login_person(person) |
331 | recorder1, recorder2 = record_two_runs( |
332 | lambda: create_initialized_view( |
333 | - source, '+copy-packages', user=person), |
334 | + source, '+copy-packages', principal=person), |
335 | create_targets, nb_objects) |
336 | self.assertThat(recorder2, HasQueryCount.byEquality(recorder1)) |
337 | |
338 | === modified file 'lib/lp/soyuz/browser/tests/test_archive_admin_view.py' |
339 | --- lib/lp/soyuz/browser/tests/test_archive_admin_view.py 2015-09-22 20:26:36 +0000 |
340 | +++ lib/lp/soyuz/browser/tests/test_archive_admin_view.py 2018-02-01 18:46:27 +0000 |
341 | @@ -1,6 +1,8 @@ |
342 | -# Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
343 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
344 | # GNU Affero General Public License version 3 (see the file LICENSE). |
345 | |
346 | +from __future__ import absolute_import, print_function, unicode_literals |
347 | + |
348 | __metaclass__ = type |
349 | |
350 | from lp.services.webapp.servers import LaunchpadTestRequest |
351 | |
352 | === modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py' |
353 | --- lib/lp/soyuz/browser/tests/test_archive_packages.py 2018-01-02 16:10:26 +0000 |
354 | +++ lib/lp/soyuz/browser/tests/test_archive_packages.py 2018-02-01 18:46:27 +0000 |
355 | @@ -1,8 +1,10 @@ |
356 | -# Copyright 2010-2015 Canonical Ltd. This software is licensed under the |
357 | +# Copyright 2010-2018 Canonical Ltd. This software is licensed under the |
358 | # GNU Affero General Public License version 3 (see the file LICENSE). |
359 | |
360 | """Unit tests for TestP3APackages.""" |
361 | |
362 | +from __future__ import absolute_import, print_function, unicode_literals |
363 | + |
364 | __metaclass__ = type |
365 | __all__ = [ |
366 | 'TestP3APackages', |
367 | @@ -396,7 +398,7 @@ |
368 | soup.findAll( |
369 | 'div', attrs={'class': 'pending-job', 'job_id': jobs[-1].id})) |
370 | self.assertEqual( |
371 | - [u'Showing 5 of 7'], |
372 | + ['Showing 5 of 7'], |
373 | soup.findAll('span', text=re.compile('Showing 5 of .'))) |
374 | |
375 | def test_job_notifications_display_owner_is_team(self): |
376 | |
377 | === modified file 'lib/lp/soyuz/browser/tests/test_archive_webservice.py' |
378 | --- lib/lp/soyuz/browser/tests/test_archive_webservice.py 2016-10-20 11:49:45 +0000 |
379 | +++ lib/lp/soyuz/browser/tests/test_archive_webservice.py 2018-02-01 18:46:27 +0000 |
380 | @@ -1,6 +1,8 @@ |
381 | -# Copyright 2010-2015 Canonical Ltd. This software is licensed under the |
382 | +# Copyright 2010-2018 Canonical Ltd. This software is licensed under the |
383 | # GNU Affero General Public License version 3 (see the file LICENSE). |
384 | |
385 | +from __future__ import absolute_import, print_function, unicode_literals |
386 | + |
387 | __metaclass__ = type |
388 | |
389 | from datetime import timedelta |
390 | |
391 | === modified file 'lib/lp/soyuz/browser/tests/test_breadcrumbs.py' |
392 | --- lib/lp/soyuz/browser/tests/test_breadcrumbs.py 2018-01-02 16:10:26 +0000 |
393 | +++ lib/lp/soyuz/browser/tests/test_breadcrumbs.py 2018-02-01 18:46:27 +0000 |
394 | @@ -1,6 +1,8 @@ |
395 | -# Copyright 2009-2010 Canonical Ltd. This software is licensed under the |
396 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
397 | # GNU Affero General Public License version 3 (see the file LICENSE). |
398 | |
399 | +from __future__ import absolute_import, print_function, unicode_literals |
400 | + |
401 | __metaclass__ = type |
402 | |
403 | from zope.component import getUtility |
404 | |
405 | === modified file 'lib/lp/soyuz/browser/tests/test_build_views.py' |
406 | --- lib/lp/soyuz/browser/tests/test_build_views.py 2018-01-02 16:10:26 +0000 |
407 | +++ lib/lp/soyuz/browser/tests/test_build_views.py 2018-02-01 18:46:27 +0000 |
408 | @@ -1,6 +1,8 @@ |
409 | -# Copyright 2011-2013 Canonical Ltd. This software is licensed under the |
410 | +# Copyright 2011-2018 Canonical Ltd. This software is licensed under the |
411 | # GNU Affero General Public License version 3 (see the file LICENSE). |
412 | |
413 | +from __future__ import absolute_import, print_function, unicode_literals |
414 | + |
415 | __metaclass__ = type |
416 | |
417 | import soupmatchers |
418 | @@ -168,7 +170,7 @@ |
419 | archive=archive, status=BuildStatus.FAILEDTOBUILD) |
420 | with person_logged_in(self.admin): |
421 | packageset = getUtility(IPackagesetSet).new( |
422 | - u'rebuild', u'test', team, |
423 | + 'rebuild', 'test', team, |
424 | distroseries=build.distro_arch_series.distroseries) |
425 | packageset.add((build.source_package_release.sourcepackagename,)) |
426 | # The team doesn't have permission until we grant it |
427 | @@ -427,7 +429,7 @@ |
428 | distroseries.distribution, name="+builds", |
429 | form={ |
430 | 'build_state': 'built', |
431 | - 'build_text': u'foo', |
432 | + 'build_text': 'foo', |
433 | 'start': 75, |
434 | 'memo': '["2012-01-01T01:01:01", 0]'}) |
435 | view.setupBuildList() |
436 | |
437 | === modified file 'lib/lp/soyuz/browser/tests/test_distributionsourcepackagerelease.py' |
438 | --- lib/lp/soyuz/browser/tests/test_distributionsourcepackagerelease.py 2018-01-02 10:54:31 +0000 |
439 | +++ lib/lp/soyuz/browser/tests/test_distributionsourcepackagerelease.py 2018-02-01 18:46:27 +0000 |
440 | @@ -1,8 +1,10 @@ |
441 | -# Copyright 2010 Canonical Ltd. This software is licensed under the |
442 | +# Copyright 2010-2018 Canonical Ltd. This software is licensed under the |
443 | # GNU Affero General Public License version 3 (see the file LICENSE). |
444 | |
445 | """Unit tests for TestSourcePackageReleaseFiles.""" |
446 | |
447 | +from __future__ import absolute_import, print_function, unicode_literals |
448 | + |
449 | __metaclass__ = type |
450 | __all__ = [ |
451 | 'TestDistributionSourcePackageReleaseFiles', |
452 | |
453 | === modified file 'lib/lp/soyuz/browser/tests/test_distroarchseries_view.py' |
454 | --- lib/lp/soyuz/browser/tests/test_distroarchseries_view.py 2012-01-01 02:58:52 +0000 |
455 | +++ lib/lp/soyuz/browser/tests/test_distroarchseries_view.py 2018-02-01 18:46:27 +0000 |
456 | @@ -1,6 +1,8 @@ |
457 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
458 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
459 | # GNU Affero General Public License version 3 (see the file LICENSE). |
460 | |
461 | +from __future__ import absolute_import, print_function, unicode_literals |
462 | + |
463 | __metaclass__ = type |
464 | |
465 | from lp.services.webapp.servers import LaunchpadTestRequest |
466 | |
467 | === modified file 'lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py' |
468 | --- lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py 2013-11-24 23:42:37 +0000 |
469 | +++ lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py 2018-02-01 18:46:27 +0000 |
470 | @@ -1,6 +1,8 @@ |
471 | -# Copyright 2010-2013 Canonical Ltd. This software is licensed under the |
472 | +# Copyright 2010-2018 Canonical Ltd. This software is licensed under the |
473 | # GNU Affero General Public License version 3 (see the file LICENSE). |
474 | |
475 | +from __future__ import absolute_import, print_function, unicode_literals |
476 | + |
477 | __metaclass__ = type |
478 | |
479 | import hashlib |
480 | |
481 | === modified file 'lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py' |
482 | --- lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py 2018-01-02 10:54:31 +0000 |
483 | +++ lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py 2018-02-01 18:46:27 +0000 |
484 | @@ -1,8 +1,10 @@ |
485 | -# Copyright 2010 Canonical Ltd. This software is licensed under the |
486 | +# Copyright 2010-2018 Canonical Ltd. This software is licensed under the |
487 | # GNU Affero General Public License version 3 (see the file LICENSE). |
488 | |
489 | """Unit tests for DistroSourcePackageRelease pages.""" |
490 | |
491 | +from __future__ import absolute_import, print_function, unicode_literals |
492 | + |
493 | __metaclass__ = type |
494 | |
495 | from zope.security.proxy import removeSecurityProxy |
496 | |
497 | === modified file 'lib/lp/soyuz/browser/tests/test_livefs.py' |
498 | --- lib/lp/soyuz/browser/tests/test_livefs.py 2015-11-26 15:46:38 +0000 |
499 | +++ lib/lp/soyuz/browser/tests/test_livefs.py 2018-02-01 18:46:27 +0000 |
500 | @@ -1,8 +1,10 @@ |
501 | -# Copyright 2014-2015 Canonical Ltd. This software is licensed under the |
502 | +# Copyright 2014-2018 Canonical Ltd. This software is licensed under the |
503 | # GNU Affero General Public License version 3 (see the file LICENSE). |
504 | |
505 | """Test live filesystem views.""" |
506 | |
507 | +from __future__ import absolute_import, print_function, unicode_literals |
508 | + |
509 | __metaclass__ = type |
510 | |
511 | from datetime import ( |
512 | @@ -67,7 +69,7 @@ |
513 | |
514 | def setUp(self): |
515 | super(TestLiveFSNavigation, self).setUp() |
516 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
517 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
518 | |
519 | def test_canonical_url(self): |
520 | owner = self.factory.makePerson(name="person") |
521 | @@ -77,7 +79,7 @@ |
522 | distribution=distribution, name="unstable") |
523 | livefs = self.factory.makeLiveFS( |
524 | registrant=owner, owner=owner, distroseries=distroseries, |
525 | - name=u"livefs") |
526 | + name="livefs") |
527 | self.assertEqual( |
528 | "http://launchpad.dev/~person/+livefs/distro/unstable/livefs", |
529 | canonical_url(livefs)) |
530 | @@ -109,7 +111,7 @@ |
531 | |
532 | def setUp(self): |
533 | super(TestLiveFSAddView, self).setUp() |
534 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
535 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
536 | self.useFixture(FakeLogger()) |
537 | self.person = self.factory.makePerson( |
538 | name="test-person", displayname="Test Person") |
539 | @@ -188,7 +190,7 @@ |
540 | |
541 | def setUp(self): |
542 | super(TestLiveFSAdminView, self).setUp() |
543 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
544 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
545 | self.useFixture(FakeLogger()) |
546 | self.person = self.factory.makePerson( |
547 | name="test-person", displayname="Test Person") |
548 | @@ -243,7 +245,7 @@ |
549 | |
550 | def setUp(self): |
551 | super(TestLiveFSEditView, self).setUp() |
552 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
553 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
554 | self.useFixture(FakeLogger()) |
555 | self.person = self.factory.makePerson( |
556 | name="test-person", displayname="Test Person") |
557 | @@ -290,7 +292,7 @@ |
558 | view.initialize() |
559 | view.request_action.success({ |
560 | "owner": livefs.owner, |
561 | - "name": u"changed", |
562 | + "name": "changed", |
563 | "distro_series": livefs.distro_series, |
564 | "metadata": "{}", |
565 | }) |
566 | @@ -303,10 +305,10 @@ |
567 | displayname="Grumpy") |
568 | livefs = self.factory.makeLiveFS( |
569 | registrant=self.person, owner=self.person, |
570 | - distroseries=distroseries, name=u"one") |
571 | + distroseries=distroseries, name="one") |
572 | self.factory.makeLiveFS( |
573 | registrant=self.person, owner=self.person, |
574 | - distroseries=distroseries, name=u"two") |
575 | + distroseries=distroseries, name="two") |
576 | browser = self.getViewBrowser(livefs, user=self.person) |
577 | browser.getLink("Edit live filesystem").click() |
578 | browser.getControl("Name").value = "two" |
579 | @@ -323,7 +325,7 @@ |
580 | |
581 | def setUp(self): |
582 | super(TestLiveFSDeleteView, self).setUp() |
583 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
584 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
585 | self.person = self.factory.makePerson( |
586 | name="test-person", displayname="Test Person") |
587 | |
588 | @@ -373,7 +375,7 @@ |
589 | |
590 | def setUp(self): |
591 | super(TestLiveFSView, self).setUp() |
592 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
593 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
594 | self.ubuntu = getUtility(ILaunchpadCelebrities).ubuntu |
595 | self.distroseries = self.factory.makeDistroSeries( |
596 | distribution=self.ubuntu, name="shiny", displayname="Shiny") |
597 | @@ -388,7 +390,7 @@ |
598 | def makeLiveFS(self): |
599 | return self.factory.makeLiveFS( |
600 | registrant=self.person, owner=self.person, |
601 | - distroseries=self.distroseries, name=u"livefs-name", |
602 | + distroseries=self.distroseries, name="livefs-name", |
603 | metadata={"project": "ubuntu-test"}) |
604 | |
605 | def makeBuild(self, livefs=None, archive=None, date_created=None, |
606 | |
607 | === modified file 'lib/lp/soyuz/browser/tests/test_livefsbuild.py' |
608 | --- lib/lp/soyuz/browser/tests/test_livefsbuild.py 2015-10-21 09:37:08 +0000 |
609 | +++ lib/lp/soyuz/browser/tests/test_livefsbuild.py 2018-02-01 18:46:27 +0000 |
610 | @@ -1,12 +1,15 @@ |
611 | -# Copyright 2014 Canonical Ltd. This software is licensed under the |
612 | +# Copyright 2014-2018 Canonical Ltd. This software is licensed under the |
613 | # GNU Affero General Public License version 3 (see the file LICENSE). |
614 | |
615 | """Test live filesystem build views.""" |
616 | |
617 | +from __future__ import absolute_import, print_function, unicode_literals |
618 | + |
619 | __metaclass__ = type |
620 | |
621 | from fixtures import FakeLogger |
622 | from mechanize import LinkNotFoundError |
623 | +import soupmatchers |
624 | from storm.locals import Store |
625 | from testtools.matchers import StartsWith |
626 | import transaction |
627 | @@ -46,7 +49,7 @@ |
628 | |
629 | def setUp(self): |
630 | super(TestCanonicalUrlForLiveFSBuild, self).setUp() |
631 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
632 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
633 | |
634 | def test_canonical_url(self): |
635 | owner = self.factory.makePerson(name="person") |
636 | @@ -56,7 +59,7 @@ |
637 | distribution=distribution, name="unstable") |
638 | livefs = self.factory.makeLiveFS( |
639 | registrant=owner, owner=owner, distroseries=distroseries, |
640 | - name=u"livefs") |
641 | + name="livefs") |
642 | build = self.factory.makeLiveFSBuild(requester=owner, livefs=livefs) |
643 | self.assertThat( |
644 | canonical_url(build), |
645 | @@ -71,7 +74,7 @@ |
646 | |
647 | def setUp(self): |
648 | super(TestLiveFSBuildView, self).setUp() |
649 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
650 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
651 | |
652 | def test_files(self): |
653 | # LiveFSBuildView.files returns all the associated files. |
654 | @@ -114,7 +117,7 @@ |
655 | |
656 | def setUp(self): |
657 | super(TestLiveFSBuildOperations, self).setUp() |
658 | - self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: u"on"})) |
659 | + self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"})) |
660 | self.useFixture(FakeLogger()) |
661 | self.build = self.factory.makeLiveFSBuild() |
662 | self.build_url = canonical_url(self.build) |
663 | @@ -204,9 +207,10 @@ |
664 | browser = self.getViewBrowser( |
665 | self.build, "+rescore", user=self.buildd_admin) |
666 | self.assertEqual(self.build_url, browser.url) |
667 | - self.assertIn( |
668 | - "Cannot rescore this build because it is not queued.", |
669 | - browser.contents) |
670 | + self.assertThat(browser.contents, soupmatchers.HTMLContains( |
671 | + soupmatchers.Tag( |
672 | + "notification", "div", attrs={"class": "warning message"}, |
673 | + text="Cannot rescore this build because it is not queued."))) |
674 | |
675 | def test_builder_history(self): |
676 | Store.of(self.build).flush() |
677 | |
678 | === modified file 'lib/lp/soyuz/browser/tests/test_package_copying_mixin.py' |
679 | --- lib/lp/soyuz/browser/tests/test_package_copying_mixin.py 2012-11-12 14:54:36 +0000 |
680 | +++ lib/lp/soyuz/browser/tests/test_package_copying_mixin.py 2018-02-01 18:46:27 +0000 |
681 | @@ -1,8 +1,10 @@ |
682 | -# Copyright 2011-2012 Canonical Ltd. This software is licensed under the |
683 | +# Copyright 2011-2018 Canonical Ltd. This software is licensed under the |
684 | # GNU Affero General Public License version 3 (see the file LICENSE). |
685 | |
686 | """Tests for `PackageCopyingMixin`.""" |
687 | |
688 | +from __future__ import absolute_import, print_function, unicode_literals |
689 | + |
690 | __metaclass__ = type |
691 | |
692 | from zope.component import getUtility |
693 | |
694 | === modified file 'lib/lp/soyuz/browser/tests/test_personal_archive_subscription.py' |
695 | --- lib/lp/soyuz/browser/tests/test_personal_archive_subscription.py 2012-04-18 18:51:11 +0000 |
696 | +++ lib/lp/soyuz/browser/tests/test_personal_archive_subscription.py 2018-02-01 18:46:27 +0000 |
697 | @@ -1,8 +1,10 @@ |
698 | -# Copyright 2012 Canonical Ltd. This software is licensed under the |
699 | +# Copyright 2012-2018 Canonical Ltd. This software is licensed under the |
700 | # GNU Affero General Public License version 3 (see the file LICENSE). |
701 | |
702 | """Tests for the PersonalArchiveSubscription components and view.""" |
703 | |
704 | +from __future__ import absolute_import, print_function, unicode_literals |
705 | + |
706 | __metaclass__ = type |
707 | |
708 | from lp.app.interfaces.launchpad import IPrivacy |
709 | |
710 | === modified file 'lib/lp/soyuz/browser/tests/test_publishing.py' |
711 | --- lib/lp/soyuz/browser/tests/test_publishing.py 2015-04-20 15:59:52 +0000 |
712 | +++ lib/lp/soyuz/browser/tests/test_publishing.py 2018-02-01 18:46:27 +0000 |
713 | @@ -1,8 +1,10 @@ |
714 | -# Copyright 2011 Canonical Ltd. This software is licensed under the |
715 | +# Copyright 2011-2018 Canonical Ltd. This software is licensed under the |
716 | # GNU Affero General Public License version 3 (see the file LICENSE). |
717 | |
718 | """Tests for source package publication listing.""" |
719 | |
720 | +from __future__ import absolute_import, print_function, unicode_literals |
721 | + |
722 | __metaclass__ = type |
723 | |
724 | import soupmatchers |
725 | |
726 | === modified file 'lib/lp/soyuz/browser/tests/test_publishing_webservice.py' |
727 | --- lib/lp/soyuz/browser/tests/test_publishing_webservice.py 2015-12-02 13:19:42 +0000 |
728 | +++ lib/lp/soyuz/browser/tests/test_publishing_webservice.py 2018-02-01 18:46:27 +0000 |
729 | @@ -1,8 +1,10 @@ |
730 | -# Copyright 2011-2015 Canonical Ltd. This software is licensed under the |
731 | +# Copyright 2011-2018 Canonical Ltd. This software is licensed under the |
732 | # GNU Affero General Public License version 3 (see the file LICENSE). |
733 | |
734 | """Test webservice methods related to the publisher.""" |
735 | |
736 | +from __future__ import absolute_import, print_function, unicode_literals |
737 | + |
738 | from functools import partial |
739 | |
740 | from lp.services.librarian.browser import ProxiedLibraryFileAlias |
741 | |
742 | === modified file 'lib/lp/soyuz/browser/tests/test_queue.py' |
743 | --- lib/lp/soyuz/browser/tests/test_queue.py 2018-01-02 16:10:26 +0000 |
744 | +++ lib/lp/soyuz/browser/tests/test_queue.py 2018-02-01 18:46:27 +0000 |
745 | @@ -1,8 +1,10 @@ |
746 | -# Copyright 2010-2017 Canonical Ltd. This software is licensed under the |
747 | +# Copyright 2010-2018 Canonical Ltd. This software is licensed under the |
748 | # GNU Affero General Public License version 3 (see the file LICENSE). |
749 | |
750 | """Unit tests for QueueItemsView.""" |
751 | |
752 | +from __future__ import absolute_import, print_function, unicode_literals |
753 | + |
754 | __metaclass__ = type |
755 | |
756 | from lxml import html |
757 | @@ -482,7 +484,7 @@ |
758 | distroseries = complete_upload.distroseries |
759 | complete_upload.package_sets = [ |
760 | self.factory.makePackageset(distroseries=distroseries, name=name) |
761 | - for name in [u'ccc', u'aaa', u'bbb']] |
762 | + for name in ['ccc', 'aaa', 'bbb']] |
763 | self.assertEqual("aaa bbb ccc", complete_upload.display_package_sets) |
764 | |
765 | def test_display_component_returns_source_upload_component_name(self): |
766 | |
767 | === modified file 'lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py' |
768 | --- lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py 2014-11-09 01:07:27 +0000 |
769 | +++ lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py 2018-02-01 18:46:27 +0000 |
770 | @@ -1,8 +1,10 @@ |
771 | -# Copyright 2010 Canonical Ltd. This software is licensed under the |
772 | +# Copyright 2010-2018 Canonical Ltd. This software is licensed under the |
773 | # GNU Affero General Public License version 3 (see the file LICENSE). |
774 | |
775 | """Unit tests for TestSourcePackageReleaseFiles.""" |
776 | |
777 | +from __future__ import absolute_import, print_function, unicode_literals |
778 | + |
779 | __metaclass__ = type |
780 | __all__ = [ |
781 | 'TestSourcePackageReleaseView', |
782 | |
783 | === modified file 'lib/lp/soyuz/browser/tests/test_sourceslistentries.py' |
784 | --- lib/lp/soyuz/browser/tests/test_sourceslistentries.py 2018-01-02 10:54:31 +0000 |
785 | +++ lib/lp/soyuz/browser/tests/test_sourceslistentries.py 2018-02-01 18:46:27 +0000 |
786 | @@ -1,8 +1,10 @@ |
787 | -# Copyright 2009-2011 Canonical Ltd. This software is licensed under the |
788 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
789 | # GNU Affero General Public License version 3 (see the file LICENSE). |
790 | |
791 | """Unit tests for SourceListEntriesView.""" |
792 | |
793 | +from __future__ import absolute_import, print_function, unicode_literals |
794 | + |
795 | __metaclass__ = type |
796 | __all__ = [ |
797 | 'TestDefaultSelectedSeries', |
798 | @@ -51,7 +53,7 @@ |
799 | 'Firefox/3.0.10')) |
800 | view.initialize() |
801 | |
802 | - self.assertEqual(u'getsy', view.default_series_name) |
803 | + self.assertEqual('getsy', view.default_series_name) |
804 | |
805 | # Ubuntu version 9.04 in the user-agent should display as feasty |
806 | view = SourcesListEntriesView( |
807 | @@ -63,7 +65,7 @@ |
808 | 'Firefox/3.0.10')) |
809 | view.initialize() |
810 | |
811 | - self.assertEqual(u'feasty', view.default_series_name) |
812 | + self.assertEqual('feasty', view.default_series_name) |
813 | |
814 | def testDefaultWithoutUserAgent(self): |
815 | # If there is no user-agent setting, then we force the user |
816 | |
817 | === modified file 'lib/lp/soyuz/browser/tests/test_views.py' |
818 | --- lib/lp/soyuz/browser/tests/test_views.py 2011-12-28 17:03:06 +0000 |
819 | +++ lib/lp/soyuz/browser/tests/test_views.py 2018-02-01 18:46:27 +0000 |
820 | @@ -1,9 +1,9 @@ |
821 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
822 | +# Copyright 2009-2018 Canonical Ltd. This software is licensed under the |
823 | # GNU Affero General Public License version 3 (see the file LICENSE). |
824 | |
825 | -""" |
826 | -Run the view tests. |
827 | -""" |
828 | +"""Run the view tests.""" |
829 | + |
830 | +from __future__ import absolute_import, print_function, unicode_literals |
831 | |
832 | import logging |
833 | import os |