Merge lp:~diegosarmentero/ubuntu-sso-client/tests-broken into lp:ubuntu-sso-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Natalia Bidart
Approved revision: 811
Merged at revision: 806
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/tests-broken
Merge into: lp:ubuntu-sso-client
Diff against target: 938 lines (+146/-73)
14 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/-1)
ubuntu_sso/main/tests/test_linux.py (+17/-6)
ubuntu_sso/main/tests/test_windows.py (+10/-5)
ubuntu_sso/qt/tests/test_common.py (+3/-1)
ubuntu_sso/qt/tests/test_controllers.py (+39/-21)
ubuntu_sso/qt/tests/test_reset_password.py (+3/-1)
ubuntu_sso/tests/__init__.py (+3/-1)
ubuntu_sso/tests/test_account.py (+7/-2)
ubuntu_sso/tests/test_credentials.py (+10/-8)
ubuntu_sso/utils/tests/test_oauth_headers.py (+2/-0)
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:~diegosarmentero/ubuntu-sso-client/tests-broken
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+80596@code.launchpad.net

Commit message

Fixed Tests (LP: #882518).

Description of the change

Fixed Tests (LP: #882518).

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Please remove all the dummies:

    @defer.inlineCallbacks
    def setUp(self):
        """Set up."""
        yield super(TermsAndConditionsTestCase, self).setUp()

    @defer.inlineCallbacks
    def tearDown(self):
        """Tear down."""
        yield super(TermsAndConditionsTestCase, self).tearDown()

there is no need for that.
Also, there is a lint issue.

review: Needs Fixing
806. By Diego Sarmentero

Removing setUp and tearDown where is not needed.

Revision history for this message
Manuel de la Peña (mandel) :
review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Qt test are failing with:

  CurrentUserControllerTestCase
    test_connect_ui ... Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1020, in _inlineCallbacks
    result = g.send(result)
exceptions.AttributeError: 'NoneType' object has no attribute 'send'
[ERROR]
    test_login ... Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1020, in _inlineCallbacks
    result = g.send(result)
exceptions.AttributeError: 'NoneType' object has no attribute 'send'
[ERROR]
    test_on_forgotten_password ... Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1020, in _inlineCallbacks
    result = g.send(result)
exceptions.AttributeError: 'NoneType' object has no attribute 'send'
[ERROR]
    test_on_logged_in ... Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1020, in _inlineCallbacks
    result = g.send(result)
exceptions.AttributeError: 'NoneType' object has no attribute 'send'
[ERROR]
    test_setup_ui ... Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1020, in _inlineCallbacks
    result = g.send(result)
exceptions.AttributeError: 'NoneType' object has no attribute 'send'
[ERROR]
    test_title_subtitle ... Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1020, in _inlineCallbacks
    result = g.send(result)
exceptions.AttributeError: 'NoneType' object has no attribute 'send'
[ERROR]
    test_translated_strings ... Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1020, in _inlineCallbacks
    result = g.send(result)
exceptions.AttributeError: 'NoneType' object has no attribute 'send'
[ERROR]

review: Needs Fixing
807. By Diego Sarmentero

Fixed tests.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Error on windows...

Traceback (most recent call last):
  File "C:\Python27\\Scripts\u1trial", line 269, in <module>
    main()
  File "C:\Python27\\Scripts\u1trial", line 265, in main
    TestRunner(force_gc=options.force_gc).run(args, options)
  File "C:\Python27\\Scripts\u1trial", line 187, in run
    options.ignored_paths))
  File "C:\Python27\\Scripts\u1trial", line 162, in _collect_tests
    module_suite = self._load_unittest(filepath)
  File "C:\Python27\\Scripts\u1trial", line 90, in _load_unittest
    module = __import__(modpath, None, None, [""])
  File "E:\ussoc\review_tests-broken\ubuntu_sso\main\tests\test_windows.py", lin
e 289
    return defer.gatherResults([self._tearDownServer(),
SyntaxError: 'return' with argument inside generator

review: Needs Fixing
808. By Diego Sarmentero

Fixing tests.

809. By Diego Sarmentero

Fixing tests

810. By Diego Sarmentero

Fixed tests.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

* You have my approve, but please before merging remove the following tearDowns:

    @defer.inlineCallbacks
    def tearDown(self):
        """Clean up."""
        yield super(BasicTestCase, self).setUp()
        self._called = False

    @defer.inlineCallbacks
    def tearDown(self):
        """Clean up."""
        self.entry = None
        yield super(LabeledEntryTestCase, self).tearDown()

* Also, this setUp is undeeded:

    @defer.inlineCallbacks
    def setUp(self):
        """Set up."""
        yield super(CredentialsManagementClearTestCase, self).setUp()

* No need to add docstring for setUp or tearDown.

* Please remove the addings:

        self.addCleanup(self.connector.disconnect)
        self.addCleanup(self.listener.stopListening)

review: Needs Fixing
811. By Diego Sarmentero

Removing unnecessary lines.

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> * You have my approve, but please before merging remove the following
> tearDowns:
>
> @defer.inlineCallbacks
> def tearDown(self):
> """Clean up."""
> yield super(BasicTestCase, self).setUp()
> self._called = False
>
> @defer.inlineCallbacks
> def tearDown(self):
> """Clean up."""
> self.entry = None
> yield super(LabeledEntryTestCase, self).tearDown()
>
> * Also, this setUp is undeeded:
>
> @defer.inlineCallbacks
> def setUp(self):
> """Set up."""
> yield super(CredentialsManagementClearTestCase, self).setUp()
>
> * No need to add docstring for setUp or tearDown.
>
> * Please remove the addings:
>
> self.addCleanup(self.connector.disconnect)
> self.addCleanup(self.listener.stopListening)

Fixed

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

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-09-21 17:10:14 +0000
3+++ ubuntu_sso/gtk/tests/test_gui.py 2011-11-02 16:59:23 +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@@ -158,18 +159,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@@ -178,9 +177,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@@ -189,11 +189,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@@ -352,9 +347,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@@ -382,9 +378,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@@ -393,11 +390,11 @@
82 self.ui = self.gui_class(**self.kwargs)
83 self.error = {'message': 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@@ -917,8 +914,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@@ -926,9 +924,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@@ -1074,9 +1073,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@@ -1121,9 +1121,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@@ -1265,9 +1266,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@@ -1315,9 +1317,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@@ -1448,9 +1451,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@@ -1600,9 +1604,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@@ -1656,9 +1661,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@@ -1820,9 +1826,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@@ -2122,9 +2129,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@@ -2258,9 +2266,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-10-17 18:24:55 +0000
241+++ ubuntu_sso/keyring/tests/test_linux.py 2011-11-02 16:59:23 +0000
242@@ -114,8 +114,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-10-13 12:03:04 +0000
256+++ ubuntu_sso/keyring/tests/test_windows.py 2011-11-02 16:59:23 +0000
257@@ -18,6 +18,7 @@
258
259 from json import dumps
260
261+from twisted.internet import defer
262 from twisted.trial.unittest import TestCase
263
264 from ubuntu_sso.keyring import windows
265@@ -60,9 +61,10 @@
266 class TestWindowsKeyring(TestCase):
267 """Test the windows keyring implementation."""
268
269+ @defer.inlineCallbacks
270 def setUp(self):
271 """Setup tests."""
272- super(TestWindowsKeyring, self).setUp()
273+ yield super(TestWindowsKeyring, self).setUp()
274 self.app_name = 'app_name'
275 self.fake_keyring = FakePyKeyring()
276 self.keyring = windows.Keyring(self.fake_keyring)
277
278=== modified file 'ubuntu_sso/main/tests/test_linux.py'
279--- ubuntu_sso/main/tests/test_linux.py 2011-09-29 20:49:45 +0000
280+++ ubuntu_sso/main/tests/test_linux.py 2011-11-02 16:59:23 +0000
281@@ -24,7 +24,6 @@
282
283 from mocker import Mocker, ARGS, KWARGS
284 from twisted.internet import defer
285-from twisted.trial.unittest import TestCase
286 from ubuntuone.devtools.handlers import MementoHandler
287
288 import ubuntu_sso.keyring
289@@ -75,8 +74,10 @@
290
291 timeout = 2
292
293+ @defer.inlineCallbacks
294 def setUp(self):
295 """Create the mocking bus."""
296+ yield super(SsoDbusTestCase, self).setUp()
297 self.mocker = Mocker()
298 self.mockbusname = self.mocker.mock()
299 mockbus = self.mocker.mock()
300@@ -97,10 +98,12 @@
301 self.keyring_was_set = False
302 self.keyring_values = None
303
304+ @defer.inlineCallbacks
305 def tearDown(self):
306 """Verify the mocking bus and shut it down."""
307 self.mocker.verify()
308 self.mocker.restore()
309+ yield super(SsoDbusTestCase, self).tearDown()
310
311 def test_creation(self):
312 """Test that the object creation is successful."""
313@@ -569,8 +572,9 @@
314 UI_CLASS_KEY: 'SuperUI', UI_MODULE_KEY: 'foo.bar.baz',
315 }
316
317+ @defer.inlineCallbacks
318 def setUp(self):
319- super(CredentialsManagementTestCase, self).setUp()
320+ yield super(CredentialsManagementTestCase, self).setUp()
321
322 self.mocker = Mocker()
323 self.client = CredentialsManagement(timeout_func=lambda *a: None,
324@@ -582,11 +586,12 @@
325 self.memento.setLevel(logging.DEBUG)
326 ubuntu_sso.main.logger.addHandler(self.memento)
327
328+ @defer.inlineCallbacks
329 def tearDown(self):
330 """Verify the mocking stuff and shut it down."""
331 self.mocker.verify()
332 self.mocker.restore()
333- super(CredentialsManagementTestCase, self).tearDown()
334+ yield super(CredentialsManagementTestCase, self).tearDown()
335
336 def assert_dbus_method_correct(self, method, out_signature=''):
337 """Check that 'method' is a dbus method with proper signatures."""
338@@ -626,8 +631,9 @@
339 class CredentialsManagementRefCountingTestCase(CredentialsManagementTestCase):
340 """Tests for the CredentialsManagement ref counting."""
341
342+ @defer.inlineCallbacks
343 def setUp(self):
344- super(CredentialsManagementRefCountingTestCase, self).setUp()
345+ yield super(CredentialsManagementRefCountingTestCase, self).setUp()
346 self.patch(ubuntu_sso.main, 'Credentials', FakeCredentials)
347
348 def test_ref_counting(self):
349@@ -1140,8 +1146,9 @@
350 class CredentialsManagementOpsTestCase(CredentialsManagementTestCase):
351 """Tests for the CredentialsManagement login/register methods."""
352
353+ @defer.inlineCallbacks
354 def setUp(self):
355- super(CredentialsManagementOpsTestCase, self).setUp()
356+ yield super(CredentialsManagementOpsTestCase, self).setUp()
357 self.args = dict((k, str(v)) for k, v in self.base_args.iteritems())
358 self.cred_args = self.base_args.copy()
359 self.cred_args[SUCCESS_CB_KEY] = self.client.CredentialsFound
360@@ -1179,15 +1186,19 @@
361 class CredentialsManagementParamsTestCase(CredentialsManagementOpsTestCase):
362 """Tests for the CredentialsManagement extra parameters handling."""
363
364+ @defer.inlineCallbacks
365 def setUp(self):
366- super(CredentialsManagementParamsTestCase, self).setUp()
367+ yield super(CredentialsManagementParamsTestCase, self).setUp()
368 self.args['dummy'] = 'nothing useful'
369
370
371 class CredentialsManagementSignalsTestCase(TestCase):
372 """Tests for the CredentialsManagement DBus signals."""
373
374+ @defer.inlineCallbacks
375 def setUp(self):
376+ """Set up."""
377+ yield super(CredentialsManagementSignalsTestCase, self).setUp()
378 self.client = CredentialsManagement(timeout_func=lambda *a: None,
379 shutdown_func=lambda *a: None)
380
381
382=== modified file 'ubuntu_sso/main/tests/test_windows.py'
383--- ubuntu_sso/main/tests/test_windows.py 2011-09-27 14:06:12 +0000
384+++ ubuntu_sso/main/tests/test_windows.py 2011-11-02 16:59:23 +0000
385@@ -96,9 +96,9 @@
386 class SignalTestCase(MockerTestCase):
387 """Test the signal decorator."""
388
389+ @defer.inlineCallbacks
390 def setUp(self):
391- """Set the tests."""
392- super(SignalTestCase, self).setUp()
393+ yield super(SignalTestCase, self).setUp()
394 self.fake_object = FakeDecoratedObject()
395 self.cb = self.mocker.mock()
396
397@@ -275,15 +275,16 @@
398 self.client_factory = PBClientFactory()
399 self.connector = reactor.connectTCP(LOCALHOST, port,
400 self.client_factory)
401-
402 self.client = yield self._get_client()
403 # pylint: enable=E1101
404
405+ @defer.inlineCallbacks
406 def tearDown(self):
407 """Clean reactor."""
408+ yield super(SSOLoginTestCase, self).tearDown()
409 if self.server_factory.protocolInstance is not None:
410 self.server_factory.protocolInstance.transport.loseConnection()
411- return defer.gatherResults([self._tearDownServer(),
412+ yield defer.gatherResults([self._tearDownServer(),
413 self._tearDownClient()])
414
415 def _tearDownServer(self):
416@@ -565,11 +566,13 @@
417 self.client = yield self._get_client()
418 # pylint: enable=E1101
419
420+ @defer.inlineCallbacks
421 def tearDown(self):
422 """Clean reactor."""
423+ yield super(CredentialsManagementTestCase, self).tearDown()
424 if self.server_factory.protocolInstance is not None:
425 self.server_factory.protocolInstance.transport.loseConnection()
426- return defer.gatherResults([self._tearDownServer(),
427+ yield defer.gatherResults([self._tearDownServer(),
428 self._tearDownClient()])
429
430 def _tearDownServer(self):
431@@ -854,7 +857,9 @@
432
433 # pylint: disable=W0212
434
435+ @defer.inlineCallbacks
436 def setUp(self):
437+ yield super(UbuntuSSOClientTestCase, self).setUp()
438 self.mac = MockActivationClient()
439 self.patch(windows, "reactor", MockReactor())
440 self.patch(windows, "PBClientFactory", MockPBClientFactory)
441
442=== modified file 'ubuntu_sso/qt/tests/test_common.py'
443--- ubuntu_sso/qt/tests/test_common.py 2011-09-01 17:05:11 +0000
444+++ ubuntu_sso/qt/tests/test_common.py 2011-11-02 16:59:23 +0000
445@@ -17,6 +17,7 @@
446 """Test the common functions."""
447
448 from PyQt4 import QtGui
449+from twisted.internet import defer
450 from twisted.trial.unittest import TestCase
451
452 from ubuntu_sso.qt.common import (check_as_invalid,
453@@ -35,9 +36,10 @@
454 class PasswordTestCase(TestCase):
455 """Test passwords conditions."""
456
457+ @defer.inlineCallbacks
458 def setUp(self):
459 """Setup tests."""
460- super(PasswordTestCase, self).setUp()
461+ yield super(PasswordTestCase, self).setUp()
462 self.line_edit = QtGui.QLineEdit()
463 self.line_edit_confirm = QtGui.QLineEdit()
464 self.label_assistance = QtGui.QLabel()
465
466=== modified file 'ubuntu_sso/qt/tests/test_controllers.py'
467--- ubuntu_sso/qt/tests/test_controllers.py 2011-10-07 12:31:54 +0000
468+++ ubuntu_sso/qt/tests/test_controllers.py 2011-11-02 16:59:23 +0000
469@@ -711,9 +711,10 @@
470 class ChooseSignInControllerTestCase(BaseTestCase):
471 """Test the choose sign in controller."""
472
473+ @defer.inlineCallbacks
474 def setUp(self):
475 """Set tests."""
476- super(ChooseSignInControllerTestCase, self).setUp()
477+ yield super(ChooseSignInControllerTestCase, self).setUp()
478 self.title = 'title'
479 self.subtitle = 'subtitle'
480 self.controller = ChooseSignInController(self.title, self.subtitle)
481@@ -768,9 +769,10 @@
482 class CurrentUserControllerTestCase(BaseTestCase):
483 """Test the current user controller."""
484
485+ @defer.inlineCallbacks
486 def setUp(self):
487 """Setup tests."""
488- super(CurrentUserControllerTestCase, self).setUp()
489+ yield super(CurrentUserControllerTestCase, self).setUp()
490 self.controller = CurrentUserController(title='the title',
491 subtitle='the subtitle')
492 self.view = FakeCurrentUserView()
493@@ -867,9 +869,10 @@
494 on_error_method_name = "on_login_error"
495 controller_class = CurrentUserController
496
497+ @defer.inlineCallbacks
498 def setUp(self):
499 """Setup test."""
500- super(CurrentUserControllerErrorTestCase, self).setUp()
501+ yield super(CurrentUserControllerErrorTestCase, self).setUp()
502 self.message_box = FakeMessageBox()
503 self.controller = self.controller_class(
504 message_box=self.message_box)
505@@ -928,9 +931,10 @@
506 on_error_method_name = "on_email_validation_error"
507 controller_class = EmailVerificationController
508
509+ @defer.inlineCallbacks
510 def setUp(self):
511 """Setup test."""
512- super(EmailVerificationControllerErrorTestCase, self).setUp()
513+ yield super(EmailVerificationControllerErrorTestCase, self).setUp()
514 # This error handler takes one extra argument.
515 self.on_error_method = lambda error: getattr(
516 self.controller, self.on_error_method_name)('APP', error)
517@@ -944,9 +948,10 @@
518 on_error_method_name = "on_user_registration_error"
519 controller_class = SetUpAccountController
520
521+ @defer.inlineCallbacks
522 def setUp(self):
523 """Setup test."""
524- super(SetUpAccountControllerErrorTestCase, self).setUp()
525+ yield super(SetUpAccountControllerErrorTestCase, self).setUp()
526 self.patch(self.controller, "_refresh_captcha", lambda *args: None)
527
528
529@@ -963,9 +968,10 @@
530
531 """Tests for CurrentUserController, but without Mocker."""
532
533+ @defer.inlineCallbacks
534 def setUp(self):
535 """Setup test."""
536- super(CurrentUserControllerValidationTest, self).setUp()
537+ yield super(CurrentUserControllerValidationTest, self).setUp()
538 self.message_box = FakeMessageBox()
539 self.controller = CurrentUserController(
540 message_box=self.message_box)
541@@ -1023,9 +1029,10 @@
542 class SetUpAccountControllerTestCase(BaseTestCase):
543 """test the controller used to setup a new account."""
544
545+ @defer.inlineCallbacks
546 def setUp(self):
547 """Set the different tests."""
548- super(SetUpAccountControllerTestCase, self).setUp()
549+ yield super(SetUpAccountControllerTestCase, self).setUp()
550 self.view = FakeSetupAccountPageView()
551 self.message_box = FakeMessageBox()
552 self.controller = SetUpAccountController(message_box=self.message_box)
553@@ -1432,9 +1439,10 @@
554 class SetupAccountControllerCaptchaTest(BaseTestCase):
555 """Tests for SetupAccountController, but without Mocker."""
556
557+ @defer.inlineCallbacks
558 def setUp(self):
559 """Set the different tests."""
560- super(SetupAccountControllerCaptchaTest, self).setUp()
561+ yield super(SetupAccountControllerCaptchaTest, self).setUp()
562 self.message_box = FakeMessageBox()
563 self.controller = SetUpAccountController(message_box=self.message_box)
564 self.patch(self.controller, 'view', FakeSetupAccountView())
565@@ -1452,9 +1460,10 @@
566 class SetupAccountControllerValidationTest(BaseTestCase):
567 """Tests for SetupAccountController, but without Mocker."""
568
569+ @defer.inlineCallbacks
570 def setUp(self):
571 """Set the different tests."""
572- super(SetupAccountControllerValidationTest, self).setUp()
573+ yield super(SetupAccountControllerValidationTest, self).setUp()
574 self.message_box = FakeMessageBox()
575 self.controller = SetUpAccountController(message_box=self.message_box)
576 self.patch(self.controller, '_refresh_captcha', self._set_called)
577@@ -1509,9 +1518,10 @@
578 class EmailVerificationControllerTestCase(BaseTestCase):
579 """Test the controller."""
580
581+ @defer.inlineCallbacks
582 def setUp(self):
583 """Set tests."""
584- super(EmailVerificationControllerTestCase, self).setUp()
585+ yield super(EmailVerificationControllerTestCase, self).setUp()
586 self.view = EmailVerificationView()
587 self.backend = self.view
588 self.controller = EmailVerificationController(
589@@ -1599,9 +1609,11 @@
590 class EmailVerificationControllerValidationTestCase(BaseTestCase):
591 """Tests for EmailVerificationController, but without Mocker."""
592
593+ @defer.inlineCallbacks
594 def setUp(self):
595 """Set the different tests."""
596- super(EmailVerificationControllerValidationTestCase, self).setUp()
597+ yield super(EmailVerificationControllerValidationTestCase,
598+ self).setUp()
599 self.message_box = FakeMessageBox()
600 self.controller = EmailVerificationController(
601 message_box=self.message_box)
602@@ -1642,9 +1654,9 @@
603 class ErrorControllerTestCase(BaseTestCase):
604 """Test the success page controller."""
605
606+ @defer.inlineCallbacks
607 def setUp(self):
608- """Set the tests."""
609- super(ErrorControllerTestCase, self).setUp()
610+ yield super(ErrorControllerTestCase, self).setUp()
611 self.view = ErrorPageView()
612 self.backend = self.view
613 self.controller = ErrorController()
614@@ -1665,9 +1677,9 @@
615 class SuccessControllerTestCase(BaseTestCase):
616 """Test the success page controller."""
617
618+ @defer.inlineCallbacks
619 def setUp(self):
620- """Set the tests."""
621- super(SuccessControllerTestCase, self).setUp()
622+ yield super(SuccessControllerTestCase, self).setUp()
623 self.view = SuccessPageView()
624 self.backend = self.view
625 self.controller = SuccessController()
626@@ -1688,9 +1700,10 @@
627 class UbuntuSSOWizardControllerTestCase(BaseTestCase):
628 """Test the wizard controller."""
629
630+ @defer.inlineCallbacks
631 def setUp(self):
632 """Set tests."""
633- super(UbuntuSSOWizardControllerTestCase, self).setUp()
634+ yield super(UbuntuSSOWizardControllerTestCase, self).setUp()
635 self.view = UbuntuSSOView()
636 self.backend = self.view
637 self.callback = self.view.callback
638@@ -1765,9 +1778,10 @@
639
640 """Tests for ForgottenPasswordController, but without Mocker."""
641
642+ @defer.inlineCallbacks
643 def setUp(self):
644 """Set the different tests."""
645- super(ForgottenPasswordControllerValidationTest, self).setUp()
646+ yield super(ForgottenPasswordControllerValidationTest, self).setUp()
647 self.message_box = FakeMessageBox()
648 self.controller = ForgottenPasswordController(
649 message_box=self.message_box)
650@@ -1857,9 +1871,10 @@
651 class ForgottenPasswordControllerTestCase(BaseTestCase):
652 """Test the controller of the fogotten password page."""
653
654+ @defer.inlineCallbacks
655 def setUp(self):
656 """Setup the tests."""
657- super(ForgottenPasswordControllerTestCase, self).setUp()
658+ yield super(ForgottenPasswordControllerTestCase, self).setUp()
659 self.view = FakeForgottenPasswordPageView()
660 self.backend = self.view
661 self.controller = ForgottenPasswordController(
662@@ -1926,9 +1941,10 @@
663 class ResetPasswordControllerTestCase(BaseTestCase):
664 """Ensure that the reset password works as expected."""
665
666+ @defer.inlineCallbacks
667 def setUp(self):
668 """Setup the tests."""
669- super(ResetPasswordControllerTestCase, self).setUp()
670+ yield super(ResetPasswordControllerTestCase, self).setUp()
671 self.view = ResetPasswordPageView()
672 self.backend = self.view
673 self.controller = ResetPasswordController()
674@@ -2001,9 +2017,10 @@
675
676 """Tests for ResetPasswordController, but without Mocker."""
677
678+ @defer.inlineCallbacks
679 def setUp(self):
680 """Setup test."""
681- super(ResetPasswordControllerValidationTest, self).setUp()
682+ yield super(ResetPasswordControllerValidationTest, self).setUp()
683 self.controller = ResetPasswordController()
684 self.controller.view = FakeResetPasswordPage()
685
686@@ -2067,9 +2084,10 @@
687
688 """Tests for ResetPasswordController, but without Mocker."""
689
690+ @defer.inlineCallbacks
691 def setUp(self):
692 """Setup test."""
693- super(ResetPasswordControllerRealControllerTest, self).setUp()
694+ yield super(ResetPasswordControllerRealControllerTest, self).setUp()
695 self.controller = ResetPasswordController()
696 self.controller.view = FakeWizardForResetPassword()
697
698
699=== modified file 'ubuntu_sso/qt/tests/test_reset_password.py'
700--- ubuntu_sso/qt/tests/test_reset_password.py 2011-09-08 16:43:39 +0000
701+++ ubuntu_sso/qt/tests/test_reset_password.py 2011-11-02 16:59:23 +0000
702@@ -17,6 +17,7 @@
703 """Test the Reset Password Page."""
704
705 from PyQt4 import QtGui, QtCore
706+from twisted.internet import defer
707 from twisted.trial.unittest import TestCase
708
709 from ubuntu_sso.utils.ui import (
710@@ -47,8 +48,9 @@
711 class ResetPasswordTestCase(TestCase):
712 """Test the ResetPasswordPage code."""
713
714+ @defer.inlineCallbacks
715 def setUp(self):
716- super(ResetPasswordTestCase, self).setUp()
717+ yield super(ResetPasswordTestCase, self).setUp()
718 self.page = ResetPasswordPage(Ui_ResetPasswordPage(),
719 None,
720 None)
721
722=== modified file 'ubuntu_sso/tests/__init__.py'
723--- ubuntu_sso/tests/__init__.py 2011-08-11 21:26:53 +0000
724+++ ubuntu_sso/tests/__init__.py 2011-11-02 16:59:23 +0000
725@@ -18,6 +18,7 @@
726
727 import os
728
729+from twisted.internet import defer
730 from twisted.trial import unittest
731
732 from ubuntu_sso.keyring import get_token_name
733@@ -52,8 +53,9 @@
734 class TestCase(unittest.TestCase):
735 """Customized test case that keeps tracks of method calls."""
736
737+ @defer.inlineCallbacks
738 def setUp(self):
739- super(TestCase, self).setUp()
740+ yield super(TestCase, self).setUp()
741 self._called = False
742
743 def _set_called(self, *args, **kwargs):
744
745=== modified file 'ubuntu_sso/tests/test_account.py'
746--- ubuntu_sso/tests/test_account.py 2011-10-21 16:06:50 +0000
747+++ ubuntu_sso/tests/test_account.py 2011-11-02 16:59:23 +0000
748@@ -27,6 +27,7 @@
749 # pylint: enable=F0401
750 from oauth import oauth
751 from twisted.trial.unittest import TestCase
752+from twisted.internet import defer
753
754 from ubuntu_sso.account import (
755 Account,
756@@ -200,8 +201,10 @@
757 class AccountTestCase(TestCase):
758 """Test suite for the SSO login processor."""
759
760+ @defer.inlineCallbacks
761 def setUp(self):
762- """Init."""
763+ """Set up."""
764+ yield super(AccountTestCase, self).setUp()
765
766 def fake_urlopen(url):
767 """Fake an urlopen which will read from the disk."""
768@@ -218,8 +221,10 @@
769 self.login_kwargs = dict(email=EMAIL, password=PASSWORD,
770 token_name=TOKEN_NAME)
771
772+ @defer.inlineCallbacks
773 def tearDown(self):
774- """Clean up."""
775+ """Tear down."""
776+ yield super(AccountTestCase, self).tearDown()
777 self.processor = None
778
779 def test_generate_captcha(self):
780
781=== modified file 'ubuntu_sso/tests/test_credentials.py'
782--- ubuntu_sso/tests/test_credentials.py 2011-09-22 14:29:21 +0000
783+++ ubuntu_sso/tests/test_credentials.py 2011-11-02 16:59:23 +0000
784@@ -103,18 +103,16 @@
785 class BasicTestCase(TestCase):
786 """Test case with a helper tracker."""
787
788+ @defer.inlineCallbacks
789 def setUp(self):
790 """Init."""
791+ yield super(BasicTestCase, self).setUp()
792 self._called = False # helper
793
794 self.memento = MementoHandler()
795 self.memento.setLevel(logging.DEBUG)
796 credentials.logger.addHandler(self.memento)
797
798- def tearDown(self):
799- """Clean up."""
800- self._called = False
801-
802 def _set_called(self, *args, **kwargs):
803 """Set _called to True."""
804 self._called = (args, kwargs)
805@@ -123,9 +121,10 @@
806 class CredentialsTestCase(BasicTestCase):
807 """Test suite for the Credentials class."""
808
809+ @defer.inlineCallbacks
810 def setUp(self):
811 """Init."""
812- super(CredentialsTestCase, self).setUp()
813+ yield super(CredentialsTestCase, self).setUp()
814 self.obj = credentials.Credentials(success_cb=self.success,
815 error_cb=self.error,
816 denial_cb=self.denial,
817@@ -360,8 +359,9 @@
818 class PingUrlTestCase(CredentialsTestCase):
819 """Test suite for the URL pinging."""
820
821+ @defer.inlineCallbacks
822 def setUp(self):
823- super(PingUrlTestCase, self).setUp()
824+ yield super(PingUrlTestCase, self).setUp()
825 self._request = None
826
827 def faked_urlopen(request):
828@@ -552,8 +552,9 @@
829 kwargs = {}
830 inner_class = FakedClientGUI
831
832+ @defer.inlineCallbacks
833 def setUp(self):
834- super(RegisterTestCase, self).setUp()
835+ yield super(RegisterTestCase, self).setUp()
836 self.inner_kwargs = UI_KWARGS.copy()
837 self.inner_kwargs['login_only'] = self.login_only
838 self.method_call = getattr(self.obj, self.operation)
839@@ -649,8 +650,9 @@
840 kwargs = {'email': EMAIL, 'password': PASSWORD}
841 inner_class = FakedSSOLoginRoot
842
843+ @defer.inlineCallbacks
844 def setUp(self):
845- super(LoginEmailPasswordTestCase, self).setUp()
846+ yield super(LoginEmailPasswordTestCase, self).setUp()
847 self.inner_kwargs = {APP_NAME_KEY: APP_NAME, 'email': EMAIL,
848 'password': PASSWORD,
849 'result_cb': self.obj._login_success_cb,
850
851=== modified file 'ubuntu_sso/utils/tests/test_oauth_headers.py'
852--- ubuntu_sso/utils/tests/test_oauth_headers.py 2011-10-06 21:46:56 +0000
853+++ ubuntu_sso/utils/tests/test_oauth_headers.py 2011-11-02 16:59:23 +0000
854@@ -191,8 +191,10 @@
855 class TimestampCheckerTestCase(TestCase):
856 """Tests for the timestamp checker."""
857
858+ @defer.inlineCallbacks
859 def setUp(self):
860 """Initialize a fake webserver."""
861+ yield super(TimestampCheckerTestCase, self).setUp()
862 self.ws = MockWebServer()
863 self.addCleanup(self.ws.stop)
864 self.patch(SyncTimestampChecker, "SERVER_URL", self.ws.get_url())
865
866=== modified file 'ubuntu_sso/utils/tests/test_tcpactivation.py'
867--- ubuntu_sso/utils/tests/test_tcpactivation.py 2011-07-15 14:25:35 +0000
868+++ ubuntu_sso/utils/tests/test_tcpactivation.py 2011-11-02 16:59:23 +0000
869@@ -71,8 +71,10 @@
870 class AsyncSleepTestCase(TestCase):
871 """Tests for the async_sleep function."""
872
873+ @defer.inlineCallbacks
874 def setUp(self):
875 """Initialize this test instance."""
876+ yield super(AsyncSleepTestCase, self).setUp()
877 self.test_timeout = 5.0
878 self.clock = task.Clock()
879 self.patch(tcpactivation, "reactor", self.clock)
880@@ -110,8 +112,10 @@
881
882 timeout = 2
883
884+ @defer.inlineCallbacks
885 def setUp(self):
886 """Initialize this test instance."""
887+ yield super(PortDetectFactoryTestCase, self).setUp()
888 self.factory = PortDetectFactory()
889
890 @defer.inlineCallbacks
891@@ -169,8 +173,10 @@
892 class ActivationDetectorTestCase(TestCase):
893 """Tests for the ActivationDetector class."""
894
895+ @defer.inlineCallbacks
896 def setUp(self):
897 """Initialize this test instance."""
898+ yield super(ActivationDetectorTestCase, self).setUp()
899 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,
900 SAMPLE_PORT)
901
902@@ -206,8 +212,10 @@
903
904 timeout = 2
905
906+ @defer.inlineCallbacks
907 def setUp(self):
908 """Initialize this test instance."""
909+ yield super(ActivationClientTestCase, self).setUp()
910 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,
911 SAMPLE_PORT)
912
913@@ -292,8 +300,10 @@
914
915 timeout = 2
916
917+ @defer.inlineCallbacks
918 def setUp(self):
919 """Initialize this test instance."""
920+ yield super(ActivationInstanceTestCase, self).setUp()
921 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,
922 SAMPLE_PORT)
923
924
925=== modified file 'ubuntu_sso/utils/tests/test_txsecrets.py'
926--- ubuntu_sso/utils/tests/test_txsecrets.py 2011-07-05 15:26:05 +0000
927+++ ubuntu_sso/utils/tests/test_txsecrets.py 2011-11-02 16:59:23 +0000
928@@ -394,8 +394,9 @@
929 timeout = 10
930 secret_service_class = SecretServiceMock
931
932+ @inlineCallbacks
933 def setUp(self):
934- super(BaseTestCase, self).setUp()
935+ yield super(BaseTestCase, self).setUp()
936 self.session_bus = dbus.SessionBus()
937 self.mock_service = self.dbus_publish(txsecrets.SECRETS_SERVICE,
938 self.secret_service_class)

Subscribers

People subscribed via source and target branches