Merge lp:~alecu/ubuntu-sso-client/refactor-errdict-tests into lp:ubuntu-sso-client
- refactor-errdict-tests
- Merge into trunk
Proposed by
Alejandro J. Cura
Status: | Merged |
---|---|
Approved by: | Alejandro J. Cura |
Approved revision: | 781 |
Merged at revision: | 781 |
Proposed branch: | lp:~alecu/ubuntu-sso-client/refactor-errdict-tests |
Merge into: | lp:ubuntu-sso-client |
Diff against target: |
1380 lines (+384/-703) 1 file modified
ubuntu_sso/main/tests/test_windows.py (+384/-703) |
To merge this branch: | bzr merge lp:~alecu/ubuntu-sso-client/refactor-errdict-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Roberto Alsina (community) | Approve | ||
Natalia Bidart (community) | Approve | ||
Review via email: mp+74427@code.launchpad.net |
Commit message
Refactor and simplify errdict tests, so they use inlineCallbacks.
Description of the change
Refactor and simplify errdict tests, so they use inlineCallbacks.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ubuntu_sso/main/tests/test_windows.py' |
2 | --- ubuntu_sso/main/tests/test_windows.py 2011-08-26 00:03:22 +0000 |
3 | +++ ubuntu_sso/main/tests/test_windows.py 2011-09-07 18:36:29 +0000 |
4 | @@ -1,5 +1,6 @@ |
5 | # -*- coding: utf-8 -*- |
6 | -# Author: Manuel de la Pena <manuel@canonical.com> |
7 | +# Authors: Manuel de la Pena <manuel@canonical.com> |
8 | +# Alejandro J. Cura <alecu@canonical.com> |
9 | # |
10 | # Copyright 2011 Canonical Ltd. |
11 | # |
12 | @@ -201,9 +202,10 @@ |
13 | class SSOLoginTestCase(TestCase): |
14 | """Test the login class.""" |
15 | |
16 | + @defer.inlineCallbacks |
17 | def setUp(self): |
18 | """Setup tests.""" |
19 | - super(SSOLoginTestCase, self).setUp() |
20 | + yield super(SSOLoginTestCase, self).setUp() |
21 | self.mocker = Mocker() |
22 | self.root = self.mocker.mock() |
23 | self.except_to_errdict = self.mocker.replace( |
24 | @@ -219,6 +221,8 @@ |
25 | self.client_factory = PBClientFactory() |
26 | self.connector = reactor.connectTCP(LOCALHOST, port, |
27 | self.client_factory) |
28 | + |
29 | + self.client = yield self._get_client() |
30 | # pylint: enable=E1101 |
31 | |
32 | def tearDown(self): |
33 | @@ -262,118 +266,79 @@ |
34 | setattr(client, signal_name, self.mocker.mock()) |
35 | defer.returnValue(client) |
36 | |
37 | + @defer.inlineCallbacks |
38 | def test_emit_captcha_generated(self): |
39 | """Test that the cb was called.""" |
40 | app_name = 'app' |
41 | result = 'result' |
42 | |
43 | - @defer.inlineCallbacks |
44 | - def test_emit(client): |
45 | - """Actual test.""" |
46 | - client.on_captcha_generated_cb(app_name, result) |
47 | - self.mocker.replay() |
48 | - self.login.emit_captcha_generated(app_name, result) |
49 | - yield client.unregister_to_signals() |
50 | - self.mocker.verify() |
51 | - |
52 | - d = self._get_client() |
53 | - # pylint: disable=E1101 |
54 | - d.addCallback(test_emit) |
55 | - # pylint: enable=E1101 |
56 | - return d |
57 | - |
58 | + self.client.on_captcha_generated_cb(app_name, result) |
59 | + self.mocker.replay() |
60 | + self.login.emit_captcha_generated(app_name, result) |
61 | + yield self.client.unregister_to_signals() |
62 | + self.mocker.verify() |
63 | + |
64 | + @defer.inlineCallbacks |
65 | def test_emit_captcha_generation_error(self): |
66 | """Test that the cb was called.""" |
67 | app_name = 'app' |
68 | error_value = 'error' |
69 | raised_error = self.mocker.mock() |
70 | |
71 | - @defer.inlineCallbacks |
72 | - def test_emit(client): |
73 | - """Actual test.""" |
74 | - raised_error.value |
75 | - self.mocker.result(error_value) |
76 | - self.except_to_errdict(error_value) |
77 | - self.mocker.result(error_value) |
78 | - client.on_captcha_generation_error_cb(app_name, error_value) |
79 | - self.mocker.replay() |
80 | - self.login.emit_captcha_generation_error(app_name, raised_error) |
81 | - yield client.unregister_to_signals() |
82 | - self.mocker.verify() |
83 | - |
84 | - d = self._get_client() |
85 | - # pylint: disable=E1101 |
86 | - d.addCallback(test_emit) |
87 | - # pylint: enable=E1101 |
88 | - return d |
89 | - |
90 | + raised_error.value |
91 | + self.mocker.result(error_value) |
92 | + self.except_to_errdict(error_value) |
93 | + self.mocker.result(error_value) |
94 | + self.client.on_captcha_generation_error_cb(app_name, error_value) |
95 | + self.mocker.replay() |
96 | + self.login.emit_captcha_generation_error(app_name, raised_error) |
97 | + yield self.client.unregister_to_signals() |
98 | + self.mocker.verify() |
99 | + |
100 | + @defer.inlineCallbacks |
101 | def test_generate_captcha(self): |
102 | """Test the call from the client.""" |
103 | app_name = 'app' |
104 | filename = 'file' |
105 | |
106 | - @defer.inlineCallbacks |
107 | - def test_execution(client): |
108 | - """Actual test.""" |
109 | - self.root.generate_captcha(app_name, filename, |
110 | - self.login.emit_captcha_generated, |
111 | - self.login.emit_captcha_generation_error) |
112 | - self.mocker.replay() |
113 | - yield client.generate_captcha(app_name, filename) |
114 | - yield client.unregister_to_signals() |
115 | - self.mocker.verify() |
116 | - |
117 | - d = self._get_client() |
118 | - # pylint: disable=E1101 |
119 | - d.addCallback(test_execution) |
120 | - # pylint: enable=E1101 |
121 | - return d |
122 | - |
123 | + self.root.generate_captcha(app_name, filename, |
124 | + self.login.emit_captcha_generated, |
125 | + self.login.emit_captcha_generation_error) |
126 | + self.mocker.replay() |
127 | + yield self.client.generate_captcha(app_name, filename) |
128 | + yield self.client.unregister_to_signals() |
129 | + self.mocker.verify() |
130 | + |
131 | + @defer.inlineCallbacks |
132 | def test_emit_user_registered(self): |
133 | """Test that the cb was called.""" |
134 | app_name = 'app' |
135 | result = 'result' |
136 | |
137 | - @defer.inlineCallbacks |
138 | - def test_emit(client): |
139 | - """Actual test.""" |
140 | - client.on_user_registered_cb(app_name, result) |
141 | - self.mocker.replay() |
142 | - self.login.emit_user_registered(app_name, result) |
143 | - yield client.unregister_to_signals() |
144 | - self.mocker.verify() |
145 | - |
146 | - d = self._get_client() |
147 | - # pylint: disable=E1101 |
148 | - d.addCallback(test_emit) |
149 | - # pylint: enable=E1101 |
150 | - return d |
151 | - |
152 | + self.client.on_user_registered_cb(app_name, result) |
153 | + self.mocker.replay() |
154 | + self.login.emit_user_registered(app_name, result) |
155 | + yield self.client.unregister_to_signals() |
156 | + self.mocker.verify() |
157 | + |
158 | + @defer.inlineCallbacks |
159 | def test_emit_user_registration_error(self): |
160 | """Test that the cb was called.""" |
161 | app_name = 'app' |
162 | error_value = 'error' |
163 | raised_error = self.mocker.mock() |
164 | |
165 | - @defer.inlineCallbacks |
166 | - def test_emit(client): |
167 | - """Actual test.""" |
168 | - raised_error.value |
169 | - self.mocker.result(error_value) |
170 | - self.except_to_errdict(error_value) |
171 | - self.mocker.result(error_value) |
172 | - client.on_user_registration_error_cb(app_name, error_value) |
173 | - self.mocker.replay() |
174 | - self.login.emit_user_registration_error(app_name, raised_error) |
175 | - yield client.unregister_to_signals() |
176 | - self.mocker.verify() |
177 | - |
178 | - d = self._get_client() |
179 | - # pylint: disable=E1101 |
180 | - d.addCallback(test_emit) |
181 | - # pylint: enable=E1101 |
182 | - return d |
183 | - |
184 | + raised_error.value |
185 | + self.mocker.result(error_value) |
186 | + self.except_to_errdict(error_value) |
187 | + self.mocker.result(error_value) |
188 | + self.client.on_user_registration_error_cb(app_name, error_value) |
189 | + self.mocker.replay() |
190 | + self.login.emit_user_registration_error(app_name, raised_error) |
191 | + yield self.client.unregister_to_signals() |
192 | + self.mocker.verify() |
193 | + |
194 | + @defer.inlineCallbacks |
195 | def test_register_user(self): |
196 | """Test the call from the client.""" |
197 | app_name = 'app' |
198 | @@ -383,159 +348,103 @@ |
199 | captcha_id = 'captcha_id' |
200 | captcha_solution = 'captcha_solution' |
201 | |
202 | - @defer.inlineCallbacks |
203 | - def test_execution(client): |
204 | - """Actual test.""" |
205 | - self.root.register_user(app_name, email, password, displayname, |
206 | - captcha_id, captcha_solution, |
207 | - self.login.emit_user_registered, |
208 | - self.login.emit_user_registration_error) |
209 | - self.mocker.replay() |
210 | - yield client.register_user(app_name, email, password, displayname, |
211 | - captcha_id, captcha_solution) |
212 | - yield client.unregister_to_signals() |
213 | - self.mocker.verify() |
214 | - |
215 | - d = self._get_client() |
216 | - # pylint: disable=E1101 |
217 | - d.addCallback(test_execution) |
218 | - # pylint: enable=E1101 |
219 | - return d |
220 | - |
221 | + self.root.register_user(app_name, email, password, displayname, |
222 | + captcha_id, captcha_solution, |
223 | + self.login.emit_user_registered, |
224 | + self.login.emit_user_registration_error) |
225 | + self.mocker.replay() |
226 | + yield self.client.register_user(app_name, email, password, displayname, |
227 | + captcha_id, captcha_solution) |
228 | + yield self.client.unregister_to_signals() |
229 | + self.mocker.verify() |
230 | + |
231 | + @defer.inlineCallbacks |
232 | def test_emit_logged_in(self): |
233 | """Test that the cb was called.""" |
234 | app_name = 'app' |
235 | result = 'result' |
236 | |
237 | - @defer.inlineCallbacks |
238 | - def test_emit(client): |
239 | - """Actual test.""" |
240 | - client.on_logged_in_cb(app_name, result) |
241 | - self.mocker.replay() |
242 | - self.login.emit_logged_in(app_name, result) |
243 | - yield client.unregister_to_signals() |
244 | - self.mocker.verify() |
245 | - |
246 | - d = self._get_client() |
247 | - # pylint: disable=E1101 |
248 | - d.addCallback(test_emit) |
249 | - # pylint: enable=E1101 |
250 | - return d |
251 | - |
252 | + self.client.on_logged_in_cb(app_name, result) |
253 | + self.mocker.replay() |
254 | + self.login.emit_logged_in(app_name, result) |
255 | + yield self.client.unregister_to_signals() |
256 | + self.mocker.verify() |
257 | + |
258 | + @defer.inlineCallbacks |
259 | def test_emit_login_error(self): |
260 | """Test that the db was called.""" |
261 | app_name = 'app' |
262 | error_value = 'error' |
263 | raised_error = self.mocker.mock() |
264 | |
265 | - @defer.inlineCallbacks |
266 | - def test_emit(client): |
267 | - """Actual test.""" |
268 | - raised_error.value |
269 | - self.mocker.result(error_value) |
270 | - self.except_to_errdict(error_value) |
271 | - self.mocker.result(error_value) |
272 | - client.on_login_error_cb(app_name, error_value) |
273 | - self.mocker.replay() |
274 | - self.login.emit_login_error(app_name, raised_error) |
275 | - yield client.unregister_to_signals() |
276 | - self.mocker.verify() |
277 | - |
278 | - d = self._get_client() |
279 | - # pylint: disable=E1101 |
280 | - d.addCallback(test_emit) |
281 | - # pylint: enable=E1101 |
282 | - return d |
283 | - |
284 | + raised_error.value |
285 | + self.mocker.result(error_value) |
286 | + self.except_to_errdict(error_value) |
287 | + self.mocker.result(error_value) |
288 | + self.client.on_login_error_cb(app_name, error_value) |
289 | + self.mocker.replay() |
290 | + self.login.emit_login_error(app_name, raised_error) |
291 | + yield self.client.unregister_to_signals() |
292 | + self.mocker.verify() |
293 | + |
294 | + @defer.inlineCallbacks |
295 | def test_emit_user_not_validated(self): |
296 | """Test that the cb was called.""" |
297 | app_name = 'app' |
298 | result = 'result' |
299 | |
300 | - @defer.inlineCallbacks |
301 | - def test_emit(client): |
302 | - """Actual test.""" |
303 | - client.on_user_not_validated_cb(app_name, result) |
304 | - self.mocker.replay() |
305 | - self.login.emit_user_not_validated(app_name, result) |
306 | - yield client.unregister_to_signals() |
307 | - self.mocker.verify() |
308 | - |
309 | - d = self._get_client() |
310 | - # pylint: disable=E1101 |
311 | - d.addCallback(test_emit) |
312 | - # pylint: enable=E1101 |
313 | - return d |
314 | - |
315 | + self.client.on_user_not_validated_cb(app_name, result) |
316 | + self.mocker.replay() |
317 | + self.login.emit_user_not_validated(app_name, result) |
318 | + yield self.client.unregister_to_signals() |
319 | + self.mocker.verify() |
320 | + |
321 | + @defer.inlineCallbacks |
322 | def test_login(self): |
323 | """Test the call from the client.""" |
324 | app_name = 'app' |
325 | email = 'email' |
326 | password = 'password' |
327 | |
328 | - @defer.inlineCallbacks |
329 | - def test_execution(client): |
330 | - """Actual test.""" |
331 | - self.root.login(app_name, email, password, |
332 | - self.login.emit_logged_in, |
333 | - self.login.emit_login_error, |
334 | - self.login.emit_user_not_validated) |
335 | - self.mocker.replay() |
336 | - yield client.login(app_name, email, password) |
337 | - yield client.unregister_to_signals() |
338 | - self.mocker.verify() |
339 | - |
340 | - d = self._get_client() |
341 | - # pylint: disable=E1101 |
342 | - d.addCallback(test_execution) |
343 | - # pylint: enable=E1101 |
344 | - return d |
345 | - |
346 | + self.root.login(app_name, email, password, |
347 | + self.login.emit_logged_in, |
348 | + self.login.emit_login_error, |
349 | + self.login.emit_user_not_validated) |
350 | + self.mocker.replay() |
351 | + yield self.client.login(app_name, email, password) |
352 | + yield self.client.unregister_to_signals() |
353 | + self.mocker.verify() |
354 | + |
355 | + @defer.inlineCallbacks |
356 | def test_emit_email_validated(self): |
357 | """Test the cb was called.""" |
358 | app_name = 'app' |
359 | result = 'result' |
360 | |
361 | - @defer.inlineCallbacks |
362 | - def test_emit(client): |
363 | - """Actual test.""" |
364 | - client.on_email_validated_cb(app_name, result) |
365 | - self.mocker.replay() |
366 | - self.login.emit_email_validated(app_name, result) |
367 | - yield client.unregister_to_signals() |
368 | - self.mocker.verify() |
369 | - |
370 | - d = self._get_client() |
371 | - # pylint: disable=E1101 |
372 | - d.addCallback(test_emit) |
373 | - # pylint: enable=E1101 |
374 | - return d |
375 | - |
376 | + self.client.on_email_validated_cb(app_name, result) |
377 | + self.mocker.replay() |
378 | + self.login.emit_email_validated(app_name, result) |
379 | + yield self.client.unregister_to_signals() |
380 | + self.mocker.verify() |
381 | + |
382 | + @defer.inlineCallbacks |
383 | def test_emit_email_validation_error(self): |
384 | """Test the cb was called.""" |
385 | app_name = 'app' |
386 | error_value = 'error' |
387 | raised_error = self.mocker.mock() |
388 | |
389 | - @defer.inlineCallbacks |
390 | - def test_emit(client): |
391 | - """Actual test.""" |
392 | - raised_error.value |
393 | - self.mocker.result(error_value) |
394 | - self.except_to_errdict(error_value) |
395 | - self.mocker.result(error_value) |
396 | - client.on_email_validation_error_cb(app_name, error_value) |
397 | - self.mocker.replay() |
398 | - self.login.emit_email_validation_error(app_name, raised_error) |
399 | - yield client.unregister_to_signals() |
400 | - self.mocker.verify() |
401 | - |
402 | - d = self._get_client() |
403 | - # pylint: disable=E1101 |
404 | - d.addCallback(test_emit) |
405 | - # pylint: enable=E1101 |
406 | - return d |
407 | - |
408 | + raised_error.value |
409 | + self.mocker.result(error_value) |
410 | + self.except_to_errdict(error_value) |
411 | + self.mocker.result(error_value) |
412 | + self.client.on_email_validation_error_cb(app_name, error_value) |
413 | + self.mocker.replay() |
414 | + self.login.emit_email_validation_error(app_name, raised_error) |
415 | + yield self.client.unregister_to_signals() |
416 | + self.mocker.verify() |
417 | + |
418 | + @defer.inlineCallbacks |
419 | def test_validate_email(self): |
420 | """Test the client calll.""" |
421 | app_name = 'app' |
422 | @@ -543,135 +452,88 @@ |
423 | password = 'password' |
424 | email_token = 'token' |
425 | |
426 | - @defer.inlineCallbacks |
427 | - def test_execution(client): |
428 | - """Actual test.""" |
429 | - self.root.validate_email(app_name, email, password, email_token, |
430 | + self.root.validate_email(app_name, email, password, email_token, |
431 | self.login.emit_email_validated, |
432 | self.login.emit_email_validation_error) |
433 | - self.mocker.replay() |
434 | - yield client.validate_email(app_name, email, password, email_token) |
435 | - yield client.unregister_to_signals() |
436 | - self.mocker.verify() |
437 | - |
438 | - d = self._get_client() |
439 | - # pylint: disable=E1101 |
440 | - d.addCallback(test_execution) |
441 | - # pylint: enable=E1101 |
442 | - return d |
443 | - |
444 | + self.mocker.replay() |
445 | + yield self.client.validate_email(app_name, email, password, |
446 | + email_token) |
447 | + yield self.client.unregister_to_signals() |
448 | + self.mocker.verify() |
449 | + |
450 | + @defer.inlineCallbacks |
451 | def test_emit_password_reset_token_sent(self): |
452 | """Test the cb was called.""" |
453 | app_name = 'app' |
454 | result = 'result' |
455 | |
456 | - @defer.inlineCallbacks |
457 | - def test_emit(client): |
458 | - """Actual test.""" |
459 | - client.on_password_reset_token_sent_cb(app_name, result) |
460 | - self.mocker.replay() |
461 | - self.login.emit_password_reset_token_sent(app_name, result) |
462 | - yield client.unregister_to_signals() |
463 | - self.mocker.verify() |
464 | - |
465 | - d = self._get_client() |
466 | - # pylint: disable=E1101 |
467 | - d.addCallback(test_emit) |
468 | - # pylint: enable=E1101 |
469 | - return d |
470 | - |
471 | + self.client.on_password_reset_token_sent_cb(app_name, result) |
472 | + self.mocker.replay() |
473 | + self.login.emit_password_reset_token_sent(app_name, result) |
474 | + yield self.client.unregister_to_signals() |
475 | + self.mocker.verify() |
476 | + |
477 | + @defer.inlineCallbacks |
478 | def test_emit_password_reset_error(self): |
479 | """Test the cb was called.""" |
480 | app_name = 'app' |
481 | error_value = 'error' |
482 | raised_error = self.mocker.mock() |
483 | |
484 | - @defer.inlineCallbacks |
485 | - def test_emit(client): |
486 | - """Actual test.""" |
487 | - raised_error.value |
488 | - self.mocker.result(error_value) |
489 | - self.except_to_errdict(error_value) |
490 | - self.mocker.result(error_value) |
491 | - client.on_password_reset_error_cb(app_name, error_value) |
492 | - self.mocker.replay() |
493 | - self.login.emit_password_reset_error(app_name, raised_error) |
494 | - yield client.unregister_to_signals() |
495 | - self.mocker.verify() |
496 | - |
497 | - d = self._get_client() |
498 | - # pylint: disable=E1101 |
499 | - d.addCallback(test_emit) |
500 | - # pylint: enable=E1101 |
501 | - return d |
502 | - |
503 | + raised_error.value |
504 | + self.mocker.result(error_value) |
505 | + self.except_to_errdict(error_value) |
506 | + self.mocker.result(error_value) |
507 | + self.client.on_password_reset_error_cb(app_name, error_value) |
508 | + self.mocker.replay() |
509 | + self.login.emit_password_reset_error(app_name, raised_error) |
510 | + yield self.client.unregister_to_signals() |
511 | + self.mocker.verify() |
512 | + |
513 | + @defer.inlineCallbacks |
514 | def test_request_password_reset_token(self): |
515 | """Test the client call.""" |
516 | app_name = 'app' |
517 | email = 'email' |
518 | |
519 | - @defer.inlineCallbacks |
520 | - def test_execution(client): |
521 | - """Actual test.""" |
522 | - self.root.request_password_reset_token(app_name, email, |
523 | - self.login.emit_password_reset_token_sent, |
524 | - self.login.emit_password_reset_error) |
525 | - self.mocker.replay() |
526 | - client.request_password_reset_token(app_name, email) |
527 | - yield client.unregister_to_signals() |
528 | - self.mocker.verify() |
529 | - |
530 | - d = self._get_client() |
531 | - # pylint: disable=E1101 |
532 | - d.addCallback(test_execution) |
533 | - # pylint: enable=E1101 |
534 | - return d |
535 | - |
536 | + self.root.request_password_reset_token(app_name, email, |
537 | + self.login.emit_password_reset_token_sent, |
538 | + self.login.emit_password_reset_error) |
539 | + self.mocker.replay() |
540 | + self.client.request_password_reset_token(app_name, email) |
541 | + yield self.client.unregister_to_signals() |
542 | + self.mocker.verify() |
543 | + |
544 | + @defer.inlineCallbacks |
545 | def test_emit_password_changed(self): |
546 | """Test the cb was called.""" |
547 | app_name = 'app' |
548 | result = 'result' |
549 | |
550 | - @defer.inlineCallbacks |
551 | - def test_emit(client): |
552 | - """Actual test.""" |
553 | - client.on_password_changed_cb(app_name, result) |
554 | - self.mocker.replay() |
555 | - self.login.emit_password_changed(app_name, result) |
556 | - yield client.unregister_to_signals() |
557 | - self.mocker.verify() |
558 | - |
559 | - d = self._get_client() |
560 | - # pylint: disable=E1101 |
561 | - d.addCallback(test_emit) |
562 | - # pylint: enable=E1101 |
563 | - return d |
564 | - |
565 | + self.client.on_password_changed_cb(app_name, result) |
566 | + self.mocker.replay() |
567 | + self.login.emit_password_changed(app_name, result) |
568 | + yield self.client.unregister_to_signals() |
569 | + self.mocker.verify() |
570 | + |
571 | + @defer.inlineCallbacks |
572 | def test_emit_password_change_error(self): |
573 | """Test the cb was called.""" |
574 | app_name = 'app' |
575 | error_value = 'error' |
576 | raised_error = self.mocker.mock() |
577 | |
578 | - @defer.inlineCallbacks |
579 | - def test_emit(client): |
580 | - """Actual test.""" |
581 | - raised_error.value |
582 | - self.mocker.result(error_value) |
583 | - self.except_to_errdict(error_value) |
584 | - self.mocker.result(error_value) |
585 | - client.on_password_change_error(app_name, error_value) |
586 | - self.mocker.replay() |
587 | - self.login.emit_password_change_error(app_name, raised_error) |
588 | - yield client.unregister_to_signals() |
589 | - self.mocker.verify() |
590 | - |
591 | - d = self._get_client() |
592 | - # pylint: disable=E1101 |
593 | - d.addCallback(test_emit) |
594 | - # pylint: enable=E1101 |
595 | - return d |
596 | - |
597 | + raised_error.value |
598 | + self.mocker.result(error_value) |
599 | + self.except_to_errdict(error_value) |
600 | + self.mocker.result(error_value) |
601 | + self.client.on_password_change_error(app_name, error_value) |
602 | + self.mocker.replay() |
603 | + self.login.emit_password_change_error(app_name, raised_error) |
604 | + yield self.client.unregister_to_signals() |
605 | + self.mocker.verify() |
606 | + |
607 | + @defer.inlineCallbacks |
608 | def test_set_new_password(self): |
609 | """Test the client call.""" |
610 | app_name = 'app' |
611 | @@ -679,30 +541,23 @@ |
612 | token = 'token' |
613 | new_password = 'password' |
614 | |
615 | - @defer.inlineCallbacks |
616 | - def test_execution(client): |
617 | - """Actual test.""" |
618 | - self.root.set_new_password(app_name, email, token, new_password, |
619 | - self.login.emit_password_changed, |
620 | - self.login.emit_password_change_error) |
621 | - self.mocker.replay() |
622 | - yield client.set_new_password(app_name, email, token, new_password) |
623 | - yield client.unregister_to_signals() |
624 | - self.mocker.verify() |
625 | - |
626 | - d = self._get_client() |
627 | - # pylint: disable=E1101 |
628 | - d.addCallback(test_execution) |
629 | - # pylint: enable=E1101 |
630 | - return d |
631 | + self.root.set_new_password(app_name, email, token, new_password, |
632 | + self.login.emit_password_changed, |
633 | + self.login.emit_password_change_error) |
634 | + self.mocker.replay() |
635 | + yield self.client.set_new_password(app_name, email, token, |
636 | + new_password) |
637 | + yield self.client.unregister_to_signals() |
638 | + self.mocker.verify() |
639 | |
640 | |
641 | class SSOCredentialsTestCase(TestCase): |
642 | """Test the credentials class.""" |
643 | |
644 | + @defer.inlineCallbacks |
645 | def setUp(self): |
646 | """Set up tests.""" |
647 | - super(SSOCredentialsTestCase, self).setUp() |
648 | + yield super(SSOCredentialsTestCase, self).setUp() |
649 | self.mocker = Mocker() |
650 | self.root = self.mocker.mock() |
651 | self.except_to_errdict = self.mocker.replace( |
652 | @@ -718,6 +573,7 @@ |
653 | self.client_factory = PBClientFactory() |
654 | self.connector = reactor.connectTCP(LOCALHOST, port, |
655 | self.client_factory) |
656 | + self.client = yield self._get_client() |
657 | # pylint: enable=E1101 |
658 | |
659 | def tearDown(self): |
660 | @@ -751,109 +607,70 @@ |
661 | setattr(client, signal_name, self.mocker.mock()) |
662 | defer.returnValue(client) |
663 | |
664 | + @defer.inlineCallbacks |
665 | def test_emit_authorization_denied(self): |
666 | """Test that the cb is executed.""" |
667 | app_name = 'app' |
668 | |
669 | - @defer.inlineCallbacks |
670 | - def test_emit(client): |
671 | - """Actual test.""" |
672 | - client.on_authorization_denied_cb(app_name) |
673 | - self.mocker.replay() |
674 | - self.creds.emit_authorization_denied(app_name) |
675 | - yield client.unregister_to_signals() |
676 | - self.mocker.verify() |
677 | - |
678 | - d = self._get_client() |
679 | - # pylint: disable=E1101 |
680 | - d.addCallback(test_emit) |
681 | - # pylint: enable=E1101 |
682 | - return d |
683 | - |
684 | + self.client.on_authorization_denied_cb(app_name) |
685 | + self.mocker.replay() |
686 | + self.creds.emit_authorization_denied(app_name) |
687 | + yield self.client.unregister_to_signals() |
688 | + self.mocker.verify() |
689 | + |
690 | + @defer.inlineCallbacks |
691 | def test_emit_credentials_found(self): |
692 | """Test that the cb was executed.""" |
693 | app_name = 'app' |
694 | credentials = 'cred' |
695 | |
696 | - @defer.inlineCallbacks |
697 | - def test_emit(client): |
698 | - """Actual test.""" |
699 | - client.on_credentials_found_cb(app_name, credentials) |
700 | - self.mocker.replay() |
701 | - self.creds.emit_credentials_found(app_name, credentials) |
702 | - yield client.unregister_to_signals() |
703 | - self.mocker.verify() |
704 | - |
705 | - d = self._get_client() |
706 | - # pylint: disable=E1101 |
707 | - d.addCallback(test_emit) |
708 | - # pylint: enable=E1101 |
709 | - return d |
710 | - |
711 | + self.client.on_credentials_found_cb(app_name, credentials) |
712 | + self.mocker.replay() |
713 | + self.creds.emit_credentials_found(app_name, credentials) |
714 | + yield self.client.unregister_to_signals() |
715 | + self.mocker.verify() |
716 | + |
717 | + @defer.inlineCallbacks |
718 | def test_emit_credentials_error(self): |
719 | """Test that the cb was executed.""" |
720 | app_name = 'app' |
721 | raised_error = 'error' |
722 | detail = 'detail' |
723 | |
724 | - @defer.inlineCallbacks |
725 | - def test_emit(client): |
726 | - """Actual test.""" |
727 | - client.on_credentials_error_cb(app_name, raised_error, detail) |
728 | - self.mocker.replay() |
729 | - self.creds.emit_credentials_error(app_name, raised_error, detail) |
730 | - yield client.unregister_to_signals() |
731 | - self.mocker.verify() |
732 | - |
733 | - d = self._get_client() |
734 | - # pylint: disable=E1101 |
735 | - d.addCallback(test_emit) |
736 | - # pylint: enable=E1101 |
737 | - return d |
738 | - |
739 | + self.client.on_credentials_error_cb(app_name, raised_error, detail) |
740 | + self.mocker.replay() |
741 | + self.creds.emit_credentials_error(app_name, raised_error, detail) |
742 | + yield self.client.unregister_to_signals() |
743 | + self.mocker.verify() |
744 | + |
745 | + @defer.inlineCallbacks |
746 | def test_find_credentials_no_kword(self): |
747 | """Ensure that the root is called.""" |
748 | app_name = 'app' |
749 | callback = lambda: None |
750 | errback = lambda: None |
751 | |
752 | - @defer.inlineCallbacks |
753 | - def test_execution(client): |
754 | - """Actual test.""" |
755 | - self.root.find_credentials(app_name, MATCH(callable), |
756 | - MATCH(callable)) |
757 | - self.mocker.replay() |
758 | - yield client.find_credentials(app_name, callback, errback) |
759 | - yield client.unregister_to_signals() |
760 | - |
761 | - d = self._get_client() |
762 | - # pylint: disable=E1101 |
763 | - d.addCallback(test_execution) |
764 | - # pylint: enable=E1101 |
765 | - return d |
766 | - |
767 | + self.root.find_credentials(app_name, MATCH(callable), |
768 | + MATCH(callable)) |
769 | + self.mocker.replay() |
770 | + yield self.client.find_credentials(app_name, callback, errback) |
771 | + yield self.client.unregister_to_signals() |
772 | + |
773 | + @defer.inlineCallbacks |
774 | def test_find_credentials_(self): |
775 | """Ensure that the root is called.""" |
776 | app_name = 'app' |
777 | callback = lambda: None |
778 | errback = lambda: None |
779 | |
780 | - @defer.inlineCallbacks |
781 | - def test_execution(client): |
782 | - """Actual test.""" |
783 | - self.root.find_credentials(app_name, MATCH(callable), |
784 | - MATCH(callable)) |
785 | - self.mocker.replay() |
786 | - yield client.find_credentials(app_name, callback=callback, |
787 | - errback=errback) |
788 | - yield client.unregister_to_signals() |
789 | - |
790 | - d = self._get_client() |
791 | - # pylint: disable=E1101 |
792 | - d.addCallback(test_execution) |
793 | - # pylint: enable=E1101 |
794 | - return d |
795 | - |
796 | + self.root.find_credentials(app_name, MATCH(callable), |
797 | + MATCH(callable)) |
798 | + self.mocker.replay() |
799 | + yield self.client.find_credentials(app_name, callback=callback, |
800 | + errback=errback) |
801 | + yield self.client.unregister_to_signals() |
802 | + |
803 | + @defer.inlineCallbacks |
804 | def test_login_or_register_to_get_credentials(self): |
805 | """Ensure that the root is called.""" |
806 | app_name = 'app' |
807 | @@ -861,103 +678,71 @@ |
808 | help_txt = 'help' |
809 | window_id = 'window_id' |
810 | |
811 | - @defer.inlineCallbacks |
812 | - def test_execution(client): |
813 | - """Actual test.""" |
814 | - # pylint: disable=W0212 |
815 | - self.root.login_or_register_to_get_credentials(app_name, terms, |
816 | - help_txt, window_id, |
817 | - self.creds.emit_credentials_found, |
818 | - self.creds._process_error, |
819 | - self.creds.emit_authorization_denied, |
820 | - ui_module='ubuntu_sso.qt.gui') |
821 | - # pylint: enable=W0212 |
822 | - self.mocker.replay() |
823 | - yield client.login_or_register_to_get_credentials(app_name, terms, |
824 | - help_txt, window_id) |
825 | - yield client.unregister_to_signals() |
826 | - |
827 | - d = self._get_client() |
828 | - # pylint: disable=E1101 |
829 | - d.addCallback(test_execution) |
830 | - # pylint: enable=E1101 |
831 | - return d |
832 | - |
833 | + # pylint: disable=W0212 |
834 | + self.root.login_or_register_to_get_credentials(app_name, terms, |
835 | + help_txt, window_id, |
836 | + self.creds.emit_credentials_found, |
837 | + self.creds._process_error, |
838 | + self.creds.emit_authorization_denied, |
839 | + ui_module='ubuntu_sso.qt.gui') |
840 | + # pylint: enable=W0212 |
841 | + self.mocker.replay() |
842 | + yield self.client.login_or_register_to_get_credentials(app_name, terms, |
843 | + help_txt, window_id) |
844 | + yield self.client.unregister_to_signals() |
845 | + |
846 | + @defer.inlineCallbacks |
847 | def test_login_to_get_credentials(self): |
848 | """Ensure that the root is called.""" |
849 | app_name = 'app' |
850 | help_txt = 'help' |
851 | window_id = 'window_id' |
852 | |
853 | - @defer.inlineCallbacks |
854 | - def test_execution(client): |
855 | - """Actual test.""" |
856 | - # pylint: disable=W0212 |
857 | - self.root.login_to_get_credentials(app_name, help_txt, window_id, |
858 | - self.creds.emit_credentials_found, |
859 | - self.creds._process_error, |
860 | - self.creds.emit_authorization_denied, |
861 | - ui_module='ubuntu_sso.qt.gui') |
862 | - # pylint: enable=W0212 |
863 | - self.mocker.replay() |
864 | - yield client.login_to_get_credentials(app_name, help_txt, |
865 | - window_id) |
866 | - yield client.unregister_to_signals() |
867 | - |
868 | - d = self._get_client() |
869 | - # pylint: disable=E1101 |
870 | - d.addCallback(test_execution) |
871 | - # pylint: enable=E1101 |
872 | - return d |
873 | - |
874 | + # pylint: disable=W0212 |
875 | + self.root.login_to_get_credentials(app_name, help_txt, window_id, |
876 | + self.creds.emit_credentials_found, |
877 | + self.creds._process_error, |
878 | + self.creds.emit_authorization_denied, |
879 | + ui_module='ubuntu_sso.qt.gui') |
880 | + # pylint: enable=W0212 |
881 | + self.mocker.replay() |
882 | + yield self.client.login_to_get_credentials(app_name, help_txt, |
883 | + window_id) |
884 | + yield self.client.unregister_to_signals() |
885 | + |
886 | + @defer.inlineCallbacks |
887 | def test_clear_token_no_kword(self): |
888 | """Ensure that the root is called.""" |
889 | app_name = 'app' |
890 | callback = lambda: None |
891 | errback = lambda: None |
892 | |
893 | - @defer.inlineCallbacks |
894 | - def test_execution(client): |
895 | - """Actual test.""" |
896 | - self.root.clear_token(app_name, MATCH(callable), MATCH(callable)) |
897 | - self.mocker.replay() |
898 | - yield client.clear_token(app_name, callback, errback) |
899 | - yield client.unregister_to_signals() |
900 | - |
901 | - d = self._get_client() |
902 | - # pylint: disable=E1101 |
903 | - d.addCallback(test_execution) |
904 | - # pylint: enable=E1101 |
905 | - return d |
906 | - |
907 | + self.root.clear_token(app_name, MATCH(callable), MATCH(callable)) |
908 | + self.mocker.replay() |
909 | + yield self.client.clear_token(app_name, callback, errback) |
910 | + yield self.client.unregister_to_signals() |
911 | + |
912 | + @defer.inlineCallbacks |
913 | def test_clear_token(self): |
914 | """Ensure that the root is called.""" |
915 | app_name = 'app' |
916 | callback = lambda: None |
917 | errback = lambda: None |
918 | |
919 | - @defer.inlineCallbacks |
920 | - def test_execution(client): |
921 | - """Actual test.""" |
922 | - self.root.clear_token(app_name, MATCH(callable), MATCH(callable)) |
923 | - self.mocker.replay() |
924 | - yield client.clear_token(app_name, callback=callback, |
925 | - errback=errback) |
926 | - yield client.unregister_to_signals() |
927 | - |
928 | - d = self._get_client() |
929 | - # pylint: disable=E1101 |
930 | - d.addCallback(test_execution) |
931 | - # pylint: enable=E1101 |
932 | - return d |
933 | + self.root.clear_token(app_name, MATCH(callable), MATCH(callable)) |
934 | + self.mocker.replay() |
935 | + yield self.client.clear_token(app_name, callback=callback, |
936 | + errback=errback) |
937 | + yield self.client.unregister_to_signals() |
938 | |
939 | |
940 | class CredentialsManagementTestCase(TestCase): |
941 | """Test the management class.""" |
942 | |
943 | + @defer.inlineCallbacks |
944 | def setUp(self): |
945 | """Set up tests.""" |
946 | - super(CredentialsManagementTestCase, self).setUp() |
947 | + yield super(CredentialsManagementTestCase, self).setUp() |
948 | self.mocker = Mocker() |
949 | self.root = self.mocker.mock() |
950 | self.except_to_errdict = self.mocker.replace( |
951 | @@ -973,6 +758,7 @@ |
952 | self.client_factory = PBClientFactory() |
953 | self.connector = reactor.connectTCP(LOCALHOST, port, |
954 | self.client_factory) |
955 | + self.client = yield self._get_client() |
956 | # pylint: enable=E1101 |
957 | |
958 | def tearDown(self): |
959 | @@ -1009,295 +795,190 @@ |
960 | setattr(client, signal_name, self.mocker.mock()) |
961 | defer.returnValue(client) |
962 | |
963 | + @defer.inlineCallbacks |
964 | def test_shutdown(self): |
965 | """Test that root is called.""" |
966 | - |
967 | - @defer.inlineCallbacks |
968 | - def test_execution(client): |
969 | - """Actual test.""" |
970 | - # pylint: disable=W0104 |
971 | - self.root.ref_count |
972 | - # pylint: enable=W0104 |
973 | - self.mocker.result(1) |
974 | - self.root.shutdown() |
975 | - self.mocker.replay() |
976 | - yield client.shutdown() |
977 | - yield client.unregister_to_signals() |
978 | - |
979 | - d = self._get_client() |
980 | - # pylint: disable=E1101 |
981 | - d.addCallback(test_execution) |
982 | - # pylint: enable=E1101 |
983 | - return d |
984 | - |
985 | + # pylint: disable=W0104 |
986 | + self.root.ref_count |
987 | + # pylint: enable=W0104 |
988 | + self.mocker.result(1) |
989 | + self.root.shutdown() |
990 | + self.mocker.replay() |
991 | + yield self.client.shutdown() |
992 | + yield self.client.unregister_to_signals() |
993 | + |
994 | + @defer.inlineCallbacks |
995 | def test_emit_authorization_denied(self): |
996 | """Test the callback is called.""" |
997 | app_name = 'app' |
998 | |
999 | - @defer.inlineCallbacks |
1000 | - def test_emit(client): |
1001 | - """Actual test.""" |
1002 | - # pylint: disable=W0104 |
1003 | - self.root.ref_count |
1004 | - # pylint: enable=W0104 |
1005 | - self.mocker.result(1) |
1006 | - self.root.ref_count = 0 |
1007 | - client.on_authorization_denied_cb(app_name) |
1008 | - self.mocker.replay() |
1009 | - self.creds.emit_authorization_denied(app_name) |
1010 | - yield client.unregister_to_signals() |
1011 | - self.mocker.verify() |
1012 | - |
1013 | - d = self._get_client() |
1014 | - # pylint: disable=E1101 |
1015 | - d.addCallback(test_emit) |
1016 | - # pylint: enable=E1101 |
1017 | - return d |
1018 | - |
1019 | + # pylint: disable=W0104 |
1020 | + self.root.ref_count |
1021 | + # pylint: enable=W0104 |
1022 | + self.mocker.result(1) |
1023 | + self.root.ref_count = 0 |
1024 | + self.client.on_authorization_denied_cb(app_name) |
1025 | + self.mocker.replay() |
1026 | + self.creds.emit_authorization_denied(app_name) |
1027 | + yield self.client.unregister_to_signals() |
1028 | + self.mocker.verify() |
1029 | + |
1030 | + @defer.inlineCallbacks |
1031 | def test_emit_credentials_found(self): |
1032 | """Test the callback is called.""" |
1033 | app_name = 'app' |
1034 | creds = 'creds' |
1035 | |
1036 | - @defer.inlineCallbacks |
1037 | - def test_emit(client): |
1038 | - """Actual test.""" |
1039 | - # pylint: disable=W0104 |
1040 | - self.root.ref_count |
1041 | - # pylint: enable=W0104 |
1042 | - self.mocker.result(1) |
1043 | - self.root.ref_count = 0 |
1044 | - client.on_credentials_found_cb(app_name, creds) |
1045 | - self.mocker.replay() |
1046 | - self.creds.emit_credentials_found(app_name, creds) |
1047 | - yield client.unregister_to_signals() |
1048 | - self.mocker.verify() |
1049 | - |
1050 | - d = self._get_client() |
1051 | - # pylint: disable=E1101 |
1052 | - d.addCallback(test_emit) |
1053 | - # pylint: enable=E1101 |
1054 | - return d |
1055 | - |
1056 | + # pylint: disable=W0104 |
1057 | + self.root.ref_count |
1058 | + # pylint: enable=W0104 |
1059 | + self.mocker.result(1) |
1060 | + self.root.ref_count = 0 |
1061 | + self.client.on_credentials_found_cb(app_name, creds) |
1062 | + self.mocker.replay() |
1063 | + self.creds.emit_credentials_found(app_name, creds) |
1064 | + yield self.client.unregister_to_signals() |
1065 | + self.mocker.verify() |
1066 | + |
1067 | + @defer.inlineCallbacks |
1068 | def test_emit_credentials_not_found(self): |
1069 | """Test the callback is called.""" |
1070 | app_name = 'app' |
1071 | |
1072 | - @defer.inlineCallbacks |
1073 | - def test_emit(client): |
1074 | - """Actual test.""" |
1075 | - # pylint: disable=W0104 |
1076 | - self.root.ref_count |
1077 | - # pylint: enable=W0104 |
1078 | - self.mocker.result(1) |
1079 | - self.root.ref_count = 0 |
1080 | - client.on_credentials_not_found_cb(app_name) |
1081 | - self.mocker.replay() |
1082 | - self.creds.emit_credentials_not_found(app_name) |
1083 | - yield client.unregister_to_signals() |
1084 | - self.mocker.verify() |
1085 | - |
1086 | - d = self._get_client() |
1087 | - # pylint: disable=E1101 |
1088 | - d.addCallback(test_emit) |
1089 | - # pylint: enable=E1101 |
1090 | - return d |
1091 | - |
1092 | + # pylint: disable=W0104 |
1093 | + self.root.ref_count |
1094 | + # pylint: enable=W0104 |
1095 | + self.mocker.result(1) |
1096 | + self.root.ref_count = 0 |
1097 | + self.client.on_credentials_not_found_cb(app_name) |
1098 | + self.mocker.replay() |
1099 | + self.creds.emit_credentials_not_found(app_name) |
1100 | + yield self.client.unregister_to_signals() |
1101 | + self.mocker.verify() |
1102 | + |
1103 | + @defer.inlineCallbacks |
1104 | def test_emit_credentials_cleared(self): |
1105 | """Test the callback is called.""" |
1106 | app_name = 'app' |
1107 | |
1108 | - @defer.inlineCallbacks |
1109 | - def test_emit(client): |
1110 | - """Actual test.""" |
1111 | - # pylint: disable=W0104 |
1112 | - self.root.ref_count |
1113 | - # pylint: enable=W0104 |
1114 | - self.mocker.result(1) |
1115 | - self.root.ref_count = 0 |
1116 | - client.on_credentials_cleared_cb(app_name) |
1117 | - self.mocker.replay() |
1118 | - self.creds.emit_credentials_cleared(app_name) |
1119 | - yield client.unregister_to_signals() |
1120 | - self.mocker.verify() |
1121 | - |
1122 | - d = self._get_client() |
1123 | - # pylint: disable=E1101 |
1124 | - d.addCallback(test_emit) |
1125 | - # pylint: enable=E1101 |
1126 | - return d |
1127 | - |
1128 | + # pylint: disable=W0104 |
1129 | + self.root.ref_count |
1130 | + # pylint: enable=W0104 |
1131 | + self.mocker.result(1) |
1132 | + self.root.ref_count = 0 |
1133 | + self.client.on_credentials_cleared_cb(app_name) |
1134 | + self.mocker.replay() |
1135 | + self.creds.emit_credentials_cleared(app_name) |
1136 | + yield self.client.unregister_to_signals() |
1137 | + self.mocker.verify() |
1138 | + |
1139 | + @defer.inlineCallbacks |
1140 | def test_emit_credentials_stored(self): |
1141 | """Test the callback is called.""" |
1142 | app_name = 'app' |
1143 | |
1144 | - @defer.inlineCallbacks |
1145 | - def test_emit(client): |
1146 | - """Actual test.""" |
1147 | - # pylint: disable=W0104 |
1148 | - self.root.ref_count |
1149 | - # pylint: enable=W0104 |
1150 | - self.mocker.result(1) |
1151 | - self.root.ref_count = 0 |
1152 | - client.on_credentials_stored_cb(app_name) |
1153 | - self.mocker.replay() |
1154 | - self.creds.emit_credentials_stored(app_name) |
1155 | - yield client.unregister_to_signals() |
1156 | - self.mocker.verify() |
1157 | - |
1158 | - d = self._get_client() |
1159 | - # pylint: disable=E1101 |
1160 | - d.addCallback(test_emit) |
1161 | - # pylint: enable=E1101 |
1162 | - return d |
1163 | - |
1164 | + # pylint: disable=W0104 |
1165 | + self.root.ref_count |
1166 | + # pylint: enable=W0104 |
1167 | + self.mocker.result(1) |
1168 | + self.root.ref_count = 0 |
1169 | + self.client.on_credentials_stored_cb(app_name) |
1170 | + self.mocker.replay() |
1171 | + self.creds.emit_credentials_stored(app_name) |
1172 | + yield self.client.unregister_to_signals() |
1173 | + self.mocker.verify() |
1174 | + |
1175 | + @defer.inlineCallbacks |
1176 | def test_emit_credentials_error(self): |
1177 | """Test the callback is called.""" |
1178 | app_name = 'app' |
1179 | raised_error = 'error' |
1180 | |
1181 | - @defer.inlineCallbacks |
1182 | - def test_emit(client): |
1183 | - """Actual test.""" |
1184 | - # pylint: disable=W0104 |
1185 | - self.root.ref_count |
1186 | - # pylint: enable=W0104 |
1187 | - self.mocker.result(1) |
1188 | - self.root.ref_count = 0 |
1189 | - client.on_credentials_error_cb(app_name, raised_error) |
1190 | - self.mocker.replay() |
1191 | - self.creds.emit_credentials_error(app_name, raised_error) |
1192 | - yield client.unregister_to_signals() |
1193 | - self.mocker.verify() |
1194 | - |
1195 | - d = self._get_client() |
1196 | - # pylint: disable=E1101 |
1197 | - d.addCallback(test_emit) |
1198 | - # pylint: enable=E1101 |
1199 | - return d |
1200 | - |
1201 | + # pylint: disable=W0104 |
1202 | + self.root.ref_count |
1203 | + # pylint: enable=W0104 |
1204 | + self.mocker.result(1) |
1205 | + self.root.ref_count = 0 |
1206 | + self.client.on_credentials_error_cb(app_name, raised_error) |
1207 | + self.mocker.replay() |
1208 | + self.creds.emit_credentials_error(app_name, raised_error) |
1209 | + yield self.client.unregister_to_signals() |
1210 | + self.mocker.verify() |
1211 | + |
1212 | + @defer.inlineCallbacks |
1213 | def test_find_credentials(self): |
1214 | """Test that root is called.""" |
1215 | app_name = 'app' |
1216 | args = 'args' |
1217 | |
1218 | - @defer.inlineCallbacks |
1219 | - def test_execution(client): |
1220 | - """Actual test.""" |
1221 | - # pylint: disable=W0212 |
1222 | - self.root.find_credentials(app_name, args, MATCH(callable), |
1223 | - self.creds._process_failure) |
1224 | - # pylint: enable=W0212 |
1225 | - self.root.shutdown() |
1226 | - yield client.find_credentials(app_name, args) |
1227 | - yield client.unregister_to_signals() |
1228 | - |
1229 | - d = self._get_client() |
1230 | - # pylint: disable=E1101 |
1231 | - d.addCallback(test_execution) |
1232 | - # pylint: enable=E1101 |
1233 | - return d |
1234 | - |
1235 | + # pylint: disable=W0212 |
1236 | + self.root.find_credentials(app_name, args, MATCH(callable), |
1237 | + self.creds._process_failure) |
1238 | + # pylint: enable=W0212 |
1239 | + self.root.shutdown() |
1240 | + yield self.client.find_credentials(app_name, args) |
1241 | + yield self.client.unregister_to_signals() |
1242 | + |
1243 | + @defer.inlineCallbacks |
1244 | def test_clear_credentials(self): |
1245 | """Test that root is called.""" |
1246 | app_name = 'app' |
1247 | args = 'args' |
1248 | |
1249 | - @defer.inlineCallbacks |
1250 | - def test_execution(client): |
1251 | - """Actual test.""" |
1252 | - # pylint: disable=W0212 |
1253 | - self.root.clear_credentials(app_name, args, MATCH(callable), |
1254 | - self.creds._process_failure) |
1255 | - # pylint: enable=W0212 |
1256 | - self.mocker.replay() |
1257 | - yield client.clear_credentials(app_name, args) |
1258 | - yield client.unregister_to_signals() |
1259 | - |
1260 | - d = self._get_client() |
1261 | - # pylint: disable=E1101 |
1262 | - d.addCallback(test_execution) |
1263 | - # pylint: enable=E1101 |
1264 | - return d |
1265 | - |
1266 | + # pylint: disable=W0212 |
1267 | + self.root.clear_credentials(app_name, args, MATCH(callable), |
1268 | + self.creds._process_failure) |
1269 | + # pylint: enable=W0212 |
1270 | + self.mocker.replay() |
1271 | + yield self.client.clear_credentials(app_name, args) |
1272 | + yield self.client.unregister_to_signals() |
1273 | + |
1274 | + @defer.inlineCallbacks |
1275 | def test_store_credentials(self): |
1276 | """Test that root is called.""" |
1277 | app_name = 'app' |
1278 | args = 'args' |
1279 | |
1280 | - @defer.inlineCallbacks |
1281 | - def test_execution(client): |
1282 | - """Actual test.""" |
1283 | - # pylint: disable=W0212 |
1284 | - self.root.store_credentials(app_name, args, MATCH(callable), |
1285 | - self.creds._process_failure) |
1286 | - # pylint: enable=W0212 |
1287 | - self.mocker.replay() |
1288 | - yield client.store_credentials(app_name, args) |
1289 | - yield client.unregister_to_signals() |
1290 | - |
1291 | - d = self._get_client() |
1292 | - # pylint: disable=E1101 |
1293 | - d.addCallback(test_execution) |
1294 | - # pylint: enable=E1101 |
1295 | - return d |
1296 | - |
1297 | + # pylint: disable=W0212 |
1298 | + self.root.store_credentials(app_name, args, MATCH(callable), |
1299 | + self.creds._process_failure) |
1300 | + # pylint: enable=W0212 |
1301 | + self.mocker.replay() |
1302 | + yield self.client.store_credentials(app_name, args) |
1303 | + yield self.client.unregister_to_signals() |
1304 | + |
1305 | + @defer.inlineCallbacks |
1306 | def test_register(self): |
1307 | """Test that root is called.""" |
1308 | app_name = 'app' |
1309 | args = 'args' |
1310 | |
1311 | - @defer.inlineCallbacks |
1312 | - def test_execution(client): |
1313 | - """Actual test.""" |
1314 | - self.root.register(app_name, args) |
1315 | - self.mocker.replay() |
1316 | - yield client.register(app_name, args) |
1317 | - yield client.unregister_to_signals() |
1318 | - |
1319 | - d = self._get_client() |
1320 | - # pylint: disable=E1101 |
1321 | - d.addCallback(test_execution) |
1322 | - # pylint: enable=E1101 |
1323 | - return d |
1324 | - |
1325 | + self.root.register(app_name, args) |
1326 | + self.mocker.replay() |
1327 | + yield self.client.register(app_name, args) |
1328 | + yield self.client.unregister_to_signals() |
1329 | + |
1330 | + @defer.inlineCallbacks |
1331 | def test_login(self): |
1332 | """Test that root is called.""" |
1333 | app_name = 'app' |
1334 | args = 'args' |
1335 | |
1336 | - @defer.inlineCallbacks |
1337 | - def test_execution(client): |
1338 | - """Actual test.""" |
1339 | - self.root.login(app_name, args) |
1340 | - self.mocker.replay() |
1341 | - yield client.login(app_name, args) |
1342 | - yield client.unregister_to_signals() |
1343 | - |
1344 | - d = self._get_client() |
1345 | - # pylint: disable=E1101 |
1346 | - d.addCallback(test_execution) |
1347 | - # pylint: enable=E1101 |
1348 | - return d |
1349 | - |
1350 | + self.root.login(app_name, args) |
1351 | + self.mocker.replay() |
1352 | + yield self.client.login(app_name, args) |
1353 | + yield self.client.unregister_to_signals() |
1354 | + |
1355 | + @defer.inlineCallbacks |
1356 | def test_login_email_password(self): |
1357 | """Test that root is called.""" |
1358 | app_name = 'app' |
1359 | args = 'args' |
1360 | |
1361 | - @defer.inlineCallbacks |
1362 | - def test_execution(client): |
1363 | - """Actual test.""" |
1364 | - self.root.login_email_password(app_name, args) |
1365 | - self.mocker.replay() |
1366 | - yield client.login_email_password(app_name, args) |
1367 | - yield client.unregister_to_signals() |
1368 | - |
1369 | - d = self._get_client() |
1370 | - # pylint: disable=E1101 |
1371 | - d.addCallback(test_execution) |
1372 | - # pylint: enable=E1101 |
1373 | - return d |
1374 | + self.root.login_email_password(app_name, args) |
1375 | + self.mocker.replay() |
1376 | + yield self.client.login_email_password(app_name, args) |
1377 | + yield self.client.unregister_to_signals() |
1378 | |
1379 | |
1380 | class MockRemoteObject(object): |
Looks great!
Can you please add yield to the super() calls in each setUp definition? Thanks!