Merge lp:~dobey/ubuntu-sso-client/fix-supers into lp:ubuntu-sso-client/stable-1-4
- fix-supers
- Merge into stable-1-4
Proposed by
dobey
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||
Approved revision: | 773 | ||||
Merged at revision: | 771 | ||||
Proposed branch: | lp:~dobey/ubuntu-sso-client/fix-supers | ||||
Merge into: | lp:ubuntu-sso-client/stable-1-4 | ||||
Diff against target: |
891 lines (+141/-73) 11 files modified
ubuntu_sso/gtk/tests/test_gui.py (+35/-26) ubuntu_sso/keyring/tests/test_linux.py (+2/-0) ubuntu_sso/keyring/tests/test_windows.py (+3/-2) ubuntu_sso/main/tests/test_linux.py (+21/-8) ubuntu_sso/main/tests/test_windows.py (+11/-5) ubuntu_sso/qt/tests/test_windows.py (+38/-21) ubuntu_sso/tests/__init__.py (+3/-1) ubuntu_sso/tests/test_account.py (+6/-1) ubuntu_sso/tests/test_credentials.py (+10/-8) ubuntu_sso/utils/tests/test_tcpactivation.py (+10/-0) ubuntu_sso/utils/tests/test_txsecrets.py (+2/-1) |
||||
To merge this branch: | bzr merge lp:~dobey/ubuntu-sso-client/fix-supers | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart (community) | Approve | ||
Tim Cole (community) | Approve | ||
Review via email: mp+84997@code.launchpad.net |
Commit message
Backport testcase setup/teardown parent chaining fixes
Description of the change
To post a comment you must log in.
Revision history for this message
Tim Cole (tcole) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ubuntu_sso/gtk/tests/test_gui.py' |
2 | --- ubuntu_sso/gtk/tests/test_gui.py 2011-04-26 20:35:10 +0000 |
3 | +++ ubuntu_sso/gtk/tests/test_gui.py 2011-12-08 18:12:31 +0000 |
4 | @@ -29,6 +29,7 @@ |
5 | import gtk |
6 | import webkit |
7 | |
8 | +from twisted.internet import defer |
9 | from twisted.trial.unittest import TestCase |
10 | from ubuntuone.devtools.handlers import MementoHandler |
11 | |
12 | @@ -157,18 +158,16 @@ |
13 | class BasicTestCase(TestCase): |
14 | """Test case with a helper tracker.""" |
15 | |
16 | + @defer.inlineCallbacks |
17 | def setUp(self): |
18 | """Init.""" |
19 | + yield super(BasicTestCase, self).setUp() |
20 | self._called = False # helper |
21 | |
22 | self.memento = MementoHandler() |
23 | self.memento.setLevel(logging.DEBUG) |
24 | gui.logger.addHandler(self.memento) |
25 | |
26 | - def tearDown(self): |
27 | - """Clean up.""" |
28 | - self._called = False |
29 | - |
30 | def _set_called(self, *args, **kwargs): |
31 | """Set _called to True.""" |
32 | self._called = (args, kwargs) |
33 | @@ -177,9 +176,10 @@ |
34 | class LabeledEntryTestCase(BasicTestCase): |
35 | """Test suite for the labeled entry.""" |
36 | |
37 | + @defer.inlineCallbacks |
38 | def setUp(self): |
39 | """Init.""" |
40 | - super(LabeledEntryTestCase, self).setUp() |
41 | + yield super(LabeledEntryTestCase, self).setUp() |
42 | self.label = 'Test me please' |
43 | self.entry = gui.LabeledEntry(label=self.label) |
44 | |
45 | @@ -188,11 +188,6 @@ |
46 | window.add(self.entry) |
47 | window.show_all() |
48 | |
49 | - def tearDown(self): |
50 | - """Clean up.""" |
51 | - self.entry = None |
52 | - super(LabeledEntryTestCase, self).tearDown() |
53 | - |
54 | def grab_focus(self, focus_in=True): |
55 | """Grab focus on widget, if None use self.entry.""" |
56 | direction = 'in' if focus_in else 'out' |
57 | @@ -351,9 +346,10 @@ |
58 | class PasswordLabeledEntryTestCase(LabeledEntryTestCase): |
59 | """Test suite for the labeled entry when is_password is True.""" |
60 | |
61 | + @defer.inlineCallbacks |
62 | def setUp(self): |
63 | """Init.""" |
64 | - super(PasswordLabeledEntryTestCase, self).setUp() |
65 | + yield super(PasswordLabeledEntryTestCase, self).setUp() |
66 | self.entry.is_password = True |
67 | |
68 | def test_password_fields_are_visible_at_startup(self): |
69 | @@ -381,9 +377,10 @@ |
70 | gui_class = gui.UbuntuSSOClientGUI |
71 | kwargs = dict(app_name=APP_NAME, tc_url=TC_URL, help_text=HELP_TEXT) |
72 | |
73 | + @defer.inlineCallbacks |
74 | def setUp(self): |
75 | """Init.""" |
76 | - super(UbuntuSSOClientTestCase, self).setUp() |
77 | + yield super(UbuntuSSOClientTestCase, self).setUp() |
78 | self.patch(dbus, 'SessionBus', FakedSessionBus) |
79 | self.patch(dbus, 'Interface', FakedSSOBackend) |
80 | self.pages = ('enter_details', 'processing', 'verify_email', 'finish', |
81 | @@ -392,11 +389,11 @@ |
82 | self.ui = self.gui_class(**self.kwargs) |
83 | self.error = {'message': self.ui.UNKNOWN_ERROR} |
84 | |
85 | + @defer.inlineCallbacks |
86 | def tearDown(self): |
87 | - """Clean up.""" |
88 | self.ui.bus.callbacks = {} |
89 | self.ui = None |
90 | - super(UbuntuSSOClientTestCase, self).tearDown() |
91 | + yield super(UbuntuSSOClientTestCase, self).tearDown() |
92 | |
93 | def assert_entries_are_packed_to_ui(self, container_name, entries): |
94 | """Every entry is properly packed in the ui 'container_name'.""" |
95 | @@ -909,8 +906,9 @@ |
96 | class TermsAndConditionsBrowserTestCase(UbuntuSSOClientTestCase): |
97 | """Test suite for the terms & conditions browser.""" |
98 | |
99 | + @defer.inlineCallbacks |
100 | def setUp(self): |
101 | - super(TermsAndConditionsBrowserTestCase, self).setUp() |
102 | + yield super(TermsAndConditionsBrowserTestCase, self).setUp() |
103 | self.patch(webkit, 'WebView', FakedEmbeddedBrowser) |
104 | |
105 | self.ui.tc_button.clicked() |
106 | @@ -918,9 +916,10 @@ |
107 | assert len(children) == 1 |
108 | self.browser = children[0] |
109 | |
110 | + @defer.inlineCallbacks |
111 | def tearDown(self): |
112 | self.ui.tc_browser_vbox.hide() |
113 | - super(TermsAndConditionsBrowserTestCase, self).tearDown() |
114 | + yield super(TermsAndConditionsBrowserTestCase, self).tearDown() |
115 | |
116 | def test_tc_browser_is_created_when_tc_page_is_shown(self): |
117 | """The browser is created when the TC button is clicked.""" |
118 | @@ -1066,9 +1065,10 @@ |
119 | class RegistrationErrorTestCase(UbuntuSSOClientTestCase): |
120 | """Test suite for the user registration error handling.""" |
121 | |
122 | + @defer.inlineCallbacks |
123 | def setUp(self): |
124 | """Init.""" |
125 | - super(RegistrationErrorTestCase, self).setUp() |
126 | + yield super(RegistrationErrorTestCase, self).setUp() |
127 | self.click_join_with_valid_data() |
128 | |
129 | def test_previous_page_is_shown(self): |
130 | @@ -1113,9 +1113,10 @@ |
131 | class VerifyEmailTestCase(UbuntuSSOClientTestCase): |
132 | """Test suite for the user registration (verify email page).""" |
133 | |
134 | + @defer.inlineCallbacks |
135 | def setUp(self): |
136 | """Init.""" |
137 | - super(VerifyEmailTestCase, self).setUp() |
138 | + yield super(VerifyEmailTestCase, self).setUp() |
139 | self.ui.on_user_registered(app_name=APP_NAME, email=EMAIL) |
140 | self.click_verify_email_with_valid_data() |
141 | |
142 | @@ -1257,9 +1258,10 @@ |
143 | class VerifyEmailValidationTestCase(UbuntuSSOClientTestCase): |
144 | """Test suite for the user registration validation (verify email page).""" |
145 | |
146 | + @defer.inlineCallbacks |
147 | def setUp(self): |
148 | """Init.""" |
149 | - super(VerifyEmailValidationTestCase, self).setUp() |
150 | + yield super(VerifyEmailValidationTestCase, self).setUp() |
151 | self.ui.on_user_registered(app_name=APP_NAME, email=EMAIL) |
152 | |
153 | def test_warning_is_shown_if_empty_email_token(self): |
154 | @@ -1307,9 +1309,10 @@ |
155 | class RegistrationValidationTestCase(UbuntuSSOClientTestCase): |
156 | """Test suite for the user registration validations.""" |
157 | |
158 | + @defer.inlineCallbacks |
159 | def setUp(self): |
160 | """Init.""" |
161 | - super(RegistrationValidationTestCase, self).setUp() |
162 | + yield super(RegistrationValidationTestCase, self).setUp() |
163 | self.ui.join_ok_button.set_sensitive(True) |
164 | |
165 | def test_warning_is_shown_if_name_empty(self): |
166 | @@ -1440,9 +1443,10 @@ |
167 | class LoginTestCase(UbuntuSSOClientTestCase): |
168 | """Test suite for the user login pages.""" |
169 | |
170 | + @defer.inlineCallbacks |
171 | def setUp(self): |
172 | """Init.""" |
173 | - super(LoginTestCase, self).setUp() |
174 | + yield super(LoginTestCase, self).setUp() |
175 | self.ui.login_button.clicked() |
176 | |
177 | def test_login_button_clicked_morphs_to_login_page(self): |
178 | @@ -1592,9 +1596,10 @@ |
179 | class LoginValidationTestCase(UbuntuSSOClientTestCase): |
180 | """Test suite for the user login validation.""" |
181 | |
182 | + @defer.inlineCallbacks |
183 | def setUp(self): |
184 | """Init.""" |
185 | - super(LoginValidationTestCase, self).setUp() |
186 | + yield super(LoginValidationTestCase, self).setUp() |
187 | self.ui.login_button.clicked() |
188 | |
189 | def test_warning_is_shown_if_empty_email(self): |
190 | @@ -1648,9 +1653,10 @@ |
191 | class ResetPasswordTestCase(UbuntuSSOClientTestCase): |
192 | """Test suite for the reset password functionality.""" |
193 | |
194 | + @defer.inlineCallbacks |
195 | def setUp(self): |
196 | """Init.""" |
197 | - super(ResetPasswordTestCase, self).setUp() |
198 | + yield super(ResetPasswordTestCase, self).setUp() |
199 | self.ui.login_button.clicked() |
200 | self.ui.forgotten_password_button.clicked() |
201 | |
202 | @@ -1812,9 +1818,10 @@ |
203 | class SetNewPasswordTestCase(UbuntuSSOClientTestCase): |
204 | """Test suite for setting a new password functionality.""" |
205 | |
206 | + @defer.inlineCallbacks |
207 | def setUp(self): |
208 | """Init.""" |
209 | - super(SetNewPasswordTestCase, self).setUp() |
210 | + yield super(SetNewPasswordTestCase, self).setUp() |
211 | self.click_request_password_token_with_valid_data() |
212 | self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL) |
213 | |
214 | @@ -2114,9 +2121,10 @@ |
215 | REGISTRATION_SUCCESS = 'registration_success_callback' |
216 | USER_CANCELLATION = 'user_cancellation_callback' |
217 | |
218 | + @defer.inlineCallbacks |
219 | def setUp(self): |
220 | """Init.""" |
221 | - super(CallbacksTestCase, self).setUp() |
222 | + yield super(CallbacksTestCase, self).setUp() |
223 | self._called = {} |
224 | for name in (self.LOGIN_SUCCESSFULL, |
225 | self.REGISTRATION_SUCCESS, |
226 | @@ -2250,9 +2258,10 @@ |
227 | class DefaultButtonsTestCase(UbuntuSSOClientTestCase): |
228 | """Each UI page has a default button when visible.""" |
229 | |
230 | + @defer.inlineCallbacks |
231 | def setUp(self): |
232 | """Init.""" |
233 | - super(DefaultButtonsTestCase, self).setUp() |
234 | + yield super(DefaultButtonsTestCase, self).setUp() |
235 | self.mapping = ( |
236 | ('enter_details_vbox', 'join_ok_button'), |
237 | ('tc_browser_vbox', 'tc_back_button'), |
238 | |
239 | === modified file 'ubuntu_sso/keyring/tests/test_linux.py' |
240 | --- ubuntu_sso/keyring/tests/test_linux.py 2011-03-18 09:30:20 +0000 |
241 | +++ ubuntu_sso/keyring/tests/test_linux.py 2011-12-08 18:12:31 +0000 |
242 | @@ -158,8 +158,10 @@ |
243 | |
244 | timeout = 5 |
245 | |
246 | + @defer.inlineCallbacks |
247 | def setUp(self): |
248 | """Initialize the mock used in these tests.""" |
249 | + yield super(TestKeyring, self).setUp() |
250 | self.mock_service = None |
251 | self.service = self.patch(keyring, "SecretService", |
252 | self.get_mock_service) |
253 | |
254 | === modified file 'ubuntu_sso/keyring/tests/test_windows.py' |
255 | --- ubuntu_sso/keyring/tests/test_windows.py 2011-04-01 08:12:51 +0000 |
256 | +++ ubuntu_sso/keyring/tests/test_windows.py 2011-12-08 18:12:31 +0000 |
257 | @@ -24,12 +24,13 @@ |
258 | from ubuntu_sso.keyring.windows import Keyring, USERNAME |
259 | |
260 | |
261 | -class TestWindowsKeyring(MockerTestCase, TestCase): |
262 | +class TestWindowsKeyring(TestCase, MockerTestCase): |
263 | """Test the windows keyring implementation.""" |
264 | |
265 | + @inlineCallbacks |
266 | def setUp(self): |
267 | """Setup tests.""" |
268 | - super(TestWindowsKeyring, self).setUp() |
269 | + yield super(TestWindowsKeyring, self).setUp() |
270 | self.keyring_lib = self.mocker.mock() |
271 | self.keyring = Keyring(self.keyring_lib) |
272 | |
273 | |
274 | === modified file 'ubuntu_sso/main/tests/test_linux.py' |
275 | --- ubuntu_sso/main/tests/test_linux.py 2011-08-22 16:21:36 +0000 |
276 | +++ ubuntu_sso/main/tests/test_linux.py 2011-12-08 18:12:31 +0000 |
277 | @@ -26,7 +26,6 @@ |
278 | from mocker import Mocker, MockerTestCase, ARGS, KWARGS, MATCH |
279 | from twisted.internet import defer |
280 | from twisted.internet.defer import Deferred, inlineCallbacks |
281 | -from twisted.trial.unittest import TestCase |
282 | from ubuntuone.devtools.handlers import MementoHandler |
283 | |
284 | import ubuntu_sso.keyring |
285 | @@ -74,8 +73,10 @@ |
286 | |
287 | timeout = 2 |
288 | |
289 | + @defer.inlineCallbacks |
290 | def setUp(self): |
291 | """Create the mocking bus.""" |
292 | + yield super(SsoDbusTestCase, self).setUp() |
293 | self.mocker = Mocker() |
294 | self.mockbusname = self.mocker.mock() |
295 | mockbus = self.mocker.mock() |
296 | @@ -96,10 +97,12 @@ |
297 | self.keyring_was_set = False |
298 | self.keyring_values = None |
299 | |
300 | + @defer.inlineCallbacks |
301 | def tearDown(self): |
302 | """Verify the mocking bus and shut it down.""" |
303 | self.mocker.verify() |
304 | self.mocker.restore() |
305 | + yield super(SsoDbusTestCase, self).tearDown() |
306 | |
307 | def test_creation(self): |
308 | """Test that the object creation is successful.""" |
309 | @@ -568,8 +571,9 @@ |
310 | |
311 | timeout = 5 |
312 | |
313 | + @inlineCallbacks |
314 | def setUp(self): |
315 | - MockerTestCase.setUp(self) |
316 | + yield super(ApplicationCredentialsTestCase, self).setUp() |
317 | |
318 | self.client = SSOCredentials(self.mocker.mock()) |
319 | |
320 | @@ -611,8 +615,9 @@ |
321 | app_name = APP_NAME |
322 | ping_url = None |
323 | |
324 | + @inlineCallbacks |
325 | def setUp(self): |
326 | - MockerTestCase.setUp(self) |
327 | + yield super(ApplicationCredentialsGUITestCase, self).setUp() |
328 | self.client = SSOCredentials(self.mocker.mock()) |
329 | self.args = {PING_URL_KEY: self.ping_url, |
330 | TC_URL_KEY: TC_URL, HELP_TEXT_KEY: HELP_TEXT, |
331 | @@ -712,8 +717,9 @@ |
332 | UI_CLASS_KEY: 'SuperUI', UI_MODULE_KEY: 'foo.bar.baz', |
333 | } |
334 | |
335 | + @defer.inlineCallbacks |
336 | def setUp(self): |
337 | - super(CredentialsManagementTestCase, self).setUp() |
338 | + yield super(CredentialsManagementTestCase, self).setUp() |
339 | |
340 | self.mocker = Mocker() |
341 | self.client = CredentialsManagement(timeout_func=lambda *a: None, |
342 | @@ -725,11 +731,12 @@ |
343 | self.memento.setLevel(logging.DEBUG) |
344 | ubuntu_sso.main.logger.addHandler(self.memento) |
345 | |
346 | + @defer.inlineCallbacks |
347 | def tearDown(self): |
348 | """Verify the mocking stuff and shut it down.""" |
349 | self.mocker.verify() |
350 | self.mocker.restore() |
351 | - super(CredentialsManagementTestCase, self).tearDown() |
352 | + yield super(CredentialsManagementTestCase, self).tearDown() |
353 | |
354 | def assert_dbus_method_correct(self, method): |
355 | """Check that 'method' is a dbus method with proper signatures.""" |
356 | @@ -766,8 +773,9 @@ |
357 | class CredentialsManagementRefCountingTestCase(CredentialsManagementTestCase): |
358 | """Tests for the CredentialsManagement ref counting.""" |
359 | |
360 | + @defer.inlineCallbacks |
361 | def setUp(self): |
362 | - super(CredentialsManagementRefCountingTestCase, self).setUp() |
363 | + yield super(CredentialsManagementRefCountingTestCase, self).setUp() |
364 | self.patch(ubuntu_sso.main, 'Credentials', FakeCredentials) |
365 | |
366 | def test_ref_counting(self): |
367 | @@ -1198,8 +1206,9 @@ |
368 | class CredentialsManagementOpsTestCase(CredentialsManagementTestCase): |
369 | """Tests for the CredentialsManagement login/register methods.""" |
370 | |
371 | + @defer.inlineCallbacks |
372 | def setUp(self): |
373 | - super(CredentialsManagementOpsTestCase, self).setUp() |
374 | + yield super(CredentialsManagementOpsTestCase, self).setUp() |
375 | self.args = dict((k, str(v)) for k, v in self.base_args.iteritems()) |
376 | self.cred_args = self.base_args.copy() |
377 | self.cred_args[SUCCESS_CB_KEY] = self.client.CredentialsFound |
378 | @@ -1237,15 +1246,19 @@ |
379 | class CredentialsManagementParamsTestCase(CredentialsManagementOpsTestCase): |
380 | """Tests for the CredentialsManagement extra parameters handling.""" |
381 | |
382 | + @defer.inlineCallbacks |
383 | def setUp(self): |
384 | - super(CredentialsManagementParamsTestCase, self).setUp() |
385 | + yield super(CredentialsManagementParamsTestCase, self).setUp() |
386 | self.args['dummy'] = 'nothing useful' |
387 | |
388 | |
389 | class CredentialsManagementSignalsTestCase(TestCase): |
390 | """Tests for the CredentialsManagement DBus signals.""" |
391 | |
392 | + @defer.inlineCallbacks |
393 | def setUp(self): |
394 | + """Set up.""" |
395 | + yield super(CredentialsManagementSignalsTestCase, self).setUp() |
396 | self.client = CredentialsManagement(timeout_func=lambda *a: None, |
397 | shutdown_func=lambda *a: None) |
398 | |
399 | |
400 | === modified file 'ubuntu_sso/main/tests/test_windows.py' |
401 | --- ubuntu_sso/main/tests/test_windows.py 2011-08-26 00:03:22 +0000 |
402 | +++ ubuntu_sso/main/tests/test_windows.py 2011-12-08 18:12:31 +0000 |
403 | @@ -87,9 +87,9 @@ |
404 | class SignalTestCase(MockerTestCase): |
405 | """Test the signal decorator.""" |
406 | |
407 | + @defer.inlineCallbacks |
408 | def setUp(self): |
409 | - """Set the tests.""" |
410 | - super(SignalTestCase, self).setUp() |
411 | + yield super(SignalTestCase, self).setUp() |
412 | self.fake_object = FakeDecoratedObject() |
413 | self.cb = self.mocker.mock() |
414 | |
415 | @@ -201,9 +201,10 @@ |
416 | class SSOLoginTestCase(TestCase): |
417 | """Test the login class.""" |
418 | |
419 | + @defer.inlineCallbacks |
420 | def setUp(self): |
421 | """Setup tests.""" |
422 | - super(SSOLoginTestCase, self).setUp() |
423 | + yield super(SSOLoginTestCase, self).setUp() |
424 | self.mocker = Mocker() |
425 | self.root = self.mocker.mock() |
426 | self.except_to_errdict = self.mocker.replace( |
427 | @@ -219,13 +220,16 @@ |
428 | self.client_factory = PBClientFactory() |
429 | self.connector = reactor.connectTCP(LOCALHOST, port, |
430 | self.client_factory) |
431 | + self.client = yield self._get_client() |
432 | # pylint: enable=E1101 |
433 | |
434 | + @defer.inlineCallbacks |
435 | def tearDown(self): |
436 | """Clean reactor.""" |
437 | + yield super(SSOLoginTestCase, self).tearDown() |
438 | if self.server_factory.protocolInstance is not None: |
439 | self.server_factory.protocolInstance.transport.loseConnection() |
440 | - return defer.gatherResults([self._tearDownServer(), |
441 | + yield defer.gatherResults([self._tearDownServer(), |
442 | self._tearDownClient()]) |
443 | |
444 | def _tearDownServer(self): |
445 | @@ -975,11 +979,13 @@ |
446 | self.client_factory) |
447 | # pylint: enable=E1101 |
448 | |
449 | + @defer.inlineCallbacks |
450 | def tearDown(self): |
451 | """Clean reactor.""" |
452 | + yield super(CredentialsManagementTestCase, self).tearDown() |
453 | if self.server_factory.protocolInstance is not None: |
454 | self.server_factory.protocolInstance.transport.loseConnection() |
455 | - return defer.gatherResults([self._tearDownServer(), |
456 | + yield defer.gatherResults([self._tearDownServer(), |
457 | self._tearDownClient()]) |
458 | |
459 | def _tearDownServer(self): |
460 | |
461 | === modified file 'ubuntu_sso/qt/tests/test_windows.py' |
462 | --- ubuntu_sso/qt/tests/test_windows.py 2011-08-18 15:40:02 +0000 |
463 | +++ ubuntu_sso/qt/tests/test_windows.py 2011-12-08 18:12:31 +0000 |
464 | @@ -16,6 +16,7 @@ |
465 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
466 | """Test the ui controllers.""" |
467 | |
468 | +from twisted.internet import defer |
469 | from twisted.trial.unittest import TestCase |
470 | |
471 | from mocker import ANY, MATCH, MockerTestCase |
472 | @@ -76,9 +77,10 @@ |
473 | class ChooseSignInControllerTestCase(MockerTestCase): |
474 | """Test the choose sign in controller.""" |
475 | |
476 | + @defer.inlineCallbacks |
477 | def setUp(self): |
478 | """Set tests.""" |
479 | - super(ChooseSignInControllerTestCase, self).setUp() |
480 | + yield super(ChooseSignInControllerTestCase, self).setUp() |
481 | self.view = self.mocker.mock() |
482 | self.backend = self.mocker.mock() |
483 | self.controller = ChooseSignInController() |
484 | @@ -139,9 +141,10 @@ |
485 | class CurrentUserControllerTestCase(MockerTestCase): |
486 | """Test the current user controller.""" |
487 | |
488 | + @defer.inlineCallbacks |
489 | def setUp(self): |
490 | """Setup tests.""" |
491 | - super(CurrentUserControllerTestCase, self).setUp() |
492 | + yield super(CurrentUserControllerTestCase, self).setUp() |
493 | self.view = self.mocker.mock() |
494 | self.backend = self.mocker.mock() |
495 | self.connect = self.mocker.mock() |
496 | @@ -269,9 +272,10 @@ |
497 | on_error_method_name = "on_login_error" |
498 | controller_class = CurrentUserController |
499 | |
500 | + @defer.inlineCallbacks |
501 | def setUp(self): |
502 | """Setup test.""" |
503 | - super(CurrentUserControllerErrorTestCase, self).setUp() |
504 | + yield super(CurrentUserControllerErrorTestCase, self).setUp() |
505 | self.message_box = FakeMessageBox() |
506 | self.controller = self.controller_class( |
507 | message_box=self.message_box) |
508 | @@ -326,9 +330,10 @@ |
509 | on_error_method_name = "on_email_validation_error" |
510 | controller_class = EmailVerificationController |
511 | |
512 | + @defer.inlineCallbacks |
513 | def setUp(self): |
514 | """Setup test.""" |
515 | - super(EmailVerificationControllerErrorTestCase, self).setUp() |
516 | + yield super(EmailVerificationControllerErrorTestCase, self).setUp() |
517 | # This error handler takes one extra argument. |
518 | self.on_error_method = lambda error: getattr( |
519 | self.controller, self.on_error_method_name)('APP', error) |
520 | @@ -342,9 +347,10 @@ |
521 | on_error_method_name = "on_user_registration_error" |
522 | controller_class = SetUpAccountController |
523 | |
524 | + @defer.inlineCallbacks |
525 | def setUp(self): |
526 | """Setup test.""" |
527 | - super(SetUpAccountControllerErrorTestCase, self).setUp() |
528 | + yield super(SetUpAccountControllerErrorTestCase, self).setUp() |
529 | self.patch(self.controller, "_refresh_captcha", lambda *args: None) |
530 | |
531 | |
532 | @@ -361,9 +367,10 @@ |
533 | |
534 | """Tests for CurrentUserController, but without Mocker.""" |
535 | |
536 | + @defer.inlineCallbacks |
537 | def setUp(self): |
538 | """Setup test.""" |
539 | - super(CurrentUserControllerValidationTest, self).setUp() |
540 | + yield super(CurrentUserControllerValidationTest, self).setUp() |
541 | self.message_box = FakeMessageBox() |
542 | self.controller = CurrentUserController( |
543 | message_box=self.message_box) |
544 | @@ -406,9 +413,10 @@ |
545 | class SetUpAccountControllerTestCase(MockerTestCase): |
546 | """test the controller used to setup a new account.""" |
547 | |
548 | + @defer.inlineCallbacks |
549 | def setUp(self): |
550 | """Set the different tests.""" |
551 | - super(SetUpAccountControllerTestCase, self).setUp() |
552 | + yield super(SetUpAccountControllerTestCase, self).setUp() |
553 | self.view = self.mocker.mock() |
554 | self.backend = self.mocker.mock() |
555 | self.get_password_strength = self.mocker.replace( |
556 | @@ -672,7 +680,6 @@ |
557 | |
558 | |
559 | class FakeView(object): |
560 | - |
561 | """A fake view.""" |
562 | |
563 | app_name = "TestApp" |
564 | @@ -683,12 +690,12 @@ |
565 | |
566 | |
567 | class SetupAccountControllerValidationTest(TestCase): |
568 | - |
569 | - """Tests for SetupAccountController, but without Mocker.""" |
570 | - |
571 | + """Tests for validating the account setup controller.""" |
572 | + |
573 | + @defer.inlineCallbacks |
574 | def setUp(self): |
575 | """Set the different tests.""" |
576 | - super(SetupAccountControllerValidationTest, self).setUp() |
577 | + yield super(SetupAccountControllerValidationTest, self).setUp() |
578 | self.message_box = FakeMessageBox() |
579 | self.controller = SetUpAccountController(message_box=self.message_box) |
580 | self.patch(self.controller, '_refresh_captcha', self._set_called) |
581 | @@ -754,9 +761,10 @@ |
582 | class EmailVerificationControllerTestCase(MockerTestCase): |
583 | """Test the controller.""" |
584 | |
585 | + @defer.inlineCallbacks |
586 | def setUp(self): |
587 | """Set tests.""" |
588 | - super(EmailVerificationControllerTestCase, self).setUp() |
589 | + yield super(EmailVerificationControllerTestCase, self).setUp() |
590 | self.view = self.mocker.mock() |
591 | self.backend = self.mocker.mock() |
592 | self.controller = EmailVerificationController( |
593 | @@ -816,9 +824,11 @@ |
594 | class EmailVerificationControllerValidationTestCase(TestCase): |
595 | """Tests for EmailVerificationController, but without Mocker.""" |
596 | |
597 | + @defer.inlineCallbacks |
598 | def setUp(self): |
599 | """Set the different tests.""" |
600 | - super(EmailVerificationControllerValidationTestCase, self).setUp() |
601 | + yield super(EmailVerificationControllerValidationTestCase, |
602 | + self).setUp() |
603 | self.message_box = FakeMessageBox() |
604 | self.controller = EmailVerificationController( |
605 | message_box=self.message_box) |
606 | @@ -837,9 +847,10 @@ |
607 | class ErrorControllerTestCase(MockerTestCase): |
608 | """Test the success page controller.""" |
609 | |
610 | + @defer.inlineCallbacks |
611 | def setUp(self): |
612 | """Set the tests.""" |
613 | - super(ErrorControllerTestCase, self).setUp() |
614 | + yield super(ErrorControllerTestCase, self).setUp() |
615 | self.view = self.mocker.mock() |
616 | self.backend = self.mocker.mock() |
617 | self.controller = ErrorController() |
618 | @@ -870,9 +881,10 @@ |
619 | class SuccessControllerTestCase(MockerTestCase): |
620 | """Test the success page controller.""" |
621 | |
622 | + @defer.inlineCallbacks |
623 | def setUp(self): |
624 | """Set the tests.""" |
625 | - super(SuccessControllerTestCase, self).setUp() |
626 | + yield super(SuccessControllerTestCase, self).setUp() |
627 | self.view = self.mocker.mock() |
628 | self.backend = self.mocker.mock() |
629 | self.controller = SuccessController() |
630 | @@ -903,9 +915,10 @@ |
631 | class UbuntuSSOWizardControllerTestCase(MockerTestCase): |
632 | """Test the wizard controller.""" |
633 | |
634 | + @defer.inlineCallbacks |
635 | def setUp(self): |
636 | """Set tests.""" |
637 | - super(UbuntuSSOWizardControllerTestCase, self).setUp() |
638 | + yield super(UbuntuSSOWizardControllerTestCase, self).setUp() |
639 | self.app_name = 'test' |
640 | self.view = self.mocker.mock() |
641 | self.backend = self.mocker.mock() |
642 | @@ -1022,9 +1035,10 @@ |
643 | |
644 | """Tests for ForgottenPasswordController, but without Mocker.""" |
645 | |
646 | + @defer.inlineCallbacks |
647 | def setUp(self): |
648 | """Set the different tests.""" |
649 | - super(ForgottenPasswordControllerValidationTest, self).setUp() |
650 | + yield super(ForgottenPasswordControllerValidationTest, self).setUp() |
651 | self.message_box = FakeMessageBox() |
652 | self.controller = ForgottenPasswordController( |
653 | message_box=self.message_box) |
654 | @@ -1061,9 +1075,10 @@ |
655 | class ForgottenPasswordControllerTestCase(MockerTestCase): |
656 | """Test the controller of the fogotten password page.""" |
657 | |
658 | + @defer.inlineCallbacks |
659 | def setUp(self): |
660 | """Setup the tests.""" |
661 | - super(ForgottenPasswordControllerTestCase, self).setUp() |
662 | + yield super(ForgottenPasswordControllerTestCase, self).setUp() |
663 | self.view = self.mocker.mock() |
664 | self.backend = self.mocker.mock() |
665 | self.controller = ForgottenPasswordController() |
666 | @@ -1154,9 +1169,10 @@ |
667 | class ResetPasswordControllerTestCase(MockerTestCase): |
668 | """Ensure that the reset password works as expected.""" |
669 | |
670 | + @defer.inlineCallbacks |
671 | def setUp(self): |
672 | """Setup the tests.""" |
673 | - super(ResetPasswordControllerTestCase, self).setUp() |
674 | + yield super(ResetPasswordControllerTestCase, self).setUp() |
675 | self.view = self.mocker.mock() |
676 | self.backend = self.mocker.mock() |
677 | self.controller = ResetPasswordController() |
678 | @@ -1275,9 +1291,10 @@ |
679 | |
680 | """Tests for ResetPasswordController, but without Mocker.""" |
681 | |
682 | + @defer.inlineCallbacks |
683 | def setUp(self): |
684 | """Setup test.""" |
685 | - super(ResetPasswordControllerValidationTest, self).setUp() |
686 | + yield super(ResetPasswordControllerValidationTest, self).setUp() |
687 | self.controller = ResetPasswordController() |
688 | self.controller.view = FakeResetPasswordPage() |
689 | self._called = False |
690 | |
691 | === modified file 'ubuntu_sso/tests/__init__.py' |
692 | --- ubuntu_sso/tests/__init__.py 2011-08-11 21:26:53 +0000 |
693 | +++ ubuntu_sso/tests/__init__.py 2011-12-08 18:12:31 +0000 |
694 | @@ -18,6 +18,7 @@ |
695 | |
696 | import os |
697 | |
698 | +from twisted.internet import defer |
699 | from twisted.trial import unittest |
700 | |
701 | from ubuntu_sso.keyring import get_token_name |
702 | @@ -52,8 +53,9 @@ |
703 | class TestCase(unittest.TestCase): |
704 | """Customized test case that keeps tracks of method calls.""" |
705 | |
706 | + @defer.inlineCallbacks |
707 | def setUp(self): |
708 | - super(TestCase, self).setUp() |
709 | + yield super(TestCase, self).setUp() |
710 | self._called = False |
711 | |
712 | def _set_called(self, *args, **kwargs): |
713 | |
714 | === modified file 'ubuntu_sso/tests/test_account.py' |
715 | --- ubuntu_sso/tests/test_account.py 2011-08-22 18:20:09 +0000 |
716 | +++ ubuntu_sso/tests/test_account.py 2011-12-08 18:12:31 +0000 |
717 | @@ -24,6 +24,7 @@ |
718 | from lazr.restfulclient.errors import HTTPError |
719 | # pylint: enable=F0401 |
720 | from twisted.trial.unittest import TestCase |
721 | +from twisted.internet import defer |
722 | |
723 | from ubuntu_sso.account import (Account, AuthenticationError, EmailTokenError, |
724 | InvalidEmailError, InvalidPasswordError, NewPasswordError, SERVICE_URL, |
725 | @@ -147,8 +148,10 @@ |
726 | class AccountTestCase(TestCase): |
727 | """Test suite for the SSO login processor.""" |
728 | |
729 | + @defer.inlineCallbacks |
730 | def setUp(self): |
731 | """Init.""" |
732 | + yield super(AccountTestCase, self).setUp() |
733 | self.processor = Account(sso_service_class=FakedSSOServer) |
734 | self.register_kwargs = dict(email=EMAIL, password=PASSWORD, |
735 | displayname=NAME, |
736 | @@ -157,8 +160,10 @@ |
737 | self.login_kwargs = dict(email=EMAIL, password=PASSWORD, |
738 | token_name=TOKEN_NAME) |
739 | |
740 | + @defer.inlineCallbacks |
741 | def tearDown(self): |
742 | - """Clean up.""" |
743 | + """Tear down.""" |
744 | + yield super(AccountTestCase, self).tearDown() |
745 | self.processor = None |
746 | |
747 | def test_generate_captcha(self): |
748 | |
749 | === modified file 'ubuntu_sso/tests/test_credentials.py' |
750 | --- ubuntu_sso/tests/test_credentials.py 2011-08-22 16:21:36 +0000 |
751 | +++ ubuntu_sso/tests/test_credentials.py 2011-12-08 18:12:31 +0000 |
752 | @@ -102,18 +102,16 @@ |
753 | class BasicTestCase(TestCase): |
754 | """Test case with a helper tracker.""" |
755 | |
756 | + @defer.inlineCallbacks |
757 | def setUp(self): |
758 | """Init.""" |
759 | + yield super(BasicTestCase, self).setUp() |
760 | self._called = False # helper |
761 | |
762 | self.memento = MementoHandler() |
763 | self.memento.setLevel(logging.DEBUG) |
764 | credentials.logger.addHandler(self.memento) |
765 | |
766 | - def tearDown(self): |
767 | - """Clean up.""" |
768 | - self._called = False |
769 | - |
770 | def _set_called(self, *args, **kwargs): |
771 | """Set _called to True.""" |
772 | self._called = (args, kwargs) |
773 | @@ -122,9 +120,10 @@ |
774 | class CredentialsTestCase(BasicTestCase): |
775 | """Test suite for the Credentials class.""" |
776 | |
777 | + @defer.inlineCallbacks |
778 | def setUp(self): |
779 | """Init.""" |
780 | - super(CredentialsTestCase, self).setUp() |
781 | + yield super(CredentialsTestCase, self).setUp() |
782 | self.obj = credentials.Credentials(success_cb=self.success, |
783 | error_cb=self.error, |
784 | denial_cb=self.denial, |
785 | @@ -359,8 +358,9 @@ |
786 | class PingUrlTestCase(CredentialsTestCase): |
787 | """Test suite for the URL pinging.""" |
788 | |
789 | + @defer.inlineCallbacks |
790 | def setUp(self): |
791 | - super(PingUrlTestCase, self).setUp() |
792 | + yield super(PingUrlTestCase, self).setUp() |
793 | self._request = None |
794 | |
795 | def faked_urlopen(request): |
796 | @@ -549,8 +549,9 @@ |
797 | kwargs = {} |
798 | inner_class = FakedClientGUI |
799 | |
800 | + @defer.inlineCallbacks |
801 | def setUp(self): |
802 | - super(RegisterTestCase, self).setUp() |
803 | + yield super(RegisterTestCase, self).setUp() |
804 | self.inner_kwargs = UI_KWARGS.copy() |
805 | self.inner_kwargs['login_only'] = self.login_only |
806 | self.method_call = getattr(self.obj, self.operation) |
807 | @@ -646,8 +647,9 @@ |
808 | kwargs = {'email': EMAIL, 'password': PASSWORD} |
809 | inner_class = FakedSSOLoginRoot |
810 | |
811 | + @defer.inlineCallbacks |
812 | def setUp(self): |
813 | - super(LoginEmailPasswordTestCase, self).setUp() |
814 | + yield super(LoginEmailPasswordTestCase, self).setUp() |
815 | self.inner_kwargs = {APP_NAME_KEY: APP_NAME, 'email': EMAIL, |
816 | 'password': PASSWORD, |
817 | 'result_cb': self.obj._login_success_cb, |
818 | |
819 | === modified file 'ubuntu_sso/utils/tests/test_tcpactivation.py' |
820 | --- ubuntu_sso/utils/tests/test_tcpactivation.py 2011-07-15 14:25:35 +0000 |
821 | +++ ubuntu_sso/utils/tests/test_tcpactivation.py 2011-12-08 18:12:31 +0000 |
822 | @@ -71,8 +71,10 @@ |
823 | class AsyncSleepTestCase(TestCase): |
824 | """Tests for the async_sleep function.""" |
825 | |
826 | + @defer.inlineCallbacks |
827 | def setUp(self): |
828 | """Initialize this test instance.""" |
829 | + yield super(AsyncSleepTestCase, self).setUp() |
830 | self.test_timeout = 5.0 |
831 | self.clock = task.Clock() |
832 | self.patch(tcpactivation, "reactor", self.clock) |
833 | @@ -110,8 +112,10 @@ |
834 | |
835 | timeout = 2 |
836 | |
837 | + @defer.inlineCallbacks |
838 | def setUp(self): |
839 | """Initialize this test instance.""" |
840 | + yield super(PortDetectFactoryTestCase, self).setUp() |
841 | self.factory = PortDetectFactory() |
842 | |
843 | @defer.inlineCallbacks |
844 | @@ -169,8 +173,10 @@ |
845 | class ActivationDetectorTestCase(TestCase): |
846 | """Tests for the ActivationDetector class.""" |
847 | |
848 | + @defer.inlineCallbacks |
849 | def setUp(self): |
850 | """Initialize this test instance.""" |
851 | + yield super(ActivationDetectorTestCase, self).setUp() |
852 | self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE, |
853 | SAMPLE_PORT) |
854 | |
855 | @@ -206,8 +212,10 @@ |
856 | |
857 | timeout = 2 |
858 | |
859 | + @defer.inlineCallbacks |
860 | def setUp(self): |
861 | """Initialize this test instance.""" |
862 | + yield super(ActivationClientTestCase, self).setUp() |
863 | self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE, |
864 | SAMPLE_PORT) |
865 | |
866 | @@ -292,8 +300,10 @@ |
867 | |
868 | timeout = 2 |
869 | |
870 | + @defer.inlineCallbacks |
871 | def setUp(self): |
872 | """Initialize this test instance.""" |
873 | + yield super(ActivationInstanceTestCase, self).setUp() |
874 | self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE, |
875 | SAMPLE_PORT) |
876 | |
877 | |
878 | === modified file 'ubuntu_sso/utils/tests/test_txsecrets.py' |
879 | --- ubuntu_sso/utils/tests/test_txsecrets.py 2011-07-05 15:26:05 +0000 |
880 | +++ ubuntu_sso/utils/tests/test_txsecrets.py 2011-12-08 18:12:31 +0000 |
881 | @@ -394,8 +394,9 @@ |
882 | timeout = 10 |
883 | secret_service_class = SecretServiceMock |
884 | |
885 | + @inlineCallbacks |
886 | def setUp(self): |
887 | - super(BaseTestCase, self).setUp() |
888 | + yield super(BaseTestCase, self).setUp() |
889 | self.session_bus = dbus.SessionBus() |
890 | self.mock_service = self.dbus_publish(txsecrets.SECRETS_SERVICE, |
891 | self.secret_service_class) |
Looks great!