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
=== modified file 'ubuntu_sso/gtk/tests/test_gui.py'
--- ubuntu_sso/gtk/tests/test_gui.py 2011-09-21 17:10:14 +0000
+++ ubuntu_sso/gtk/tests/test_gui.py 2011-11-02 16:59:23 +0000
@@ -29,6 +29,7 @@
29import gtk29import gtk
30import webkit30import webkit
3131
32from twisted.internet import defer
32from twisted.trial.unittest import TestCase33from twisted.trial.unittest import TestCase
33from ubuntuone.devtools.handlers import MementoHandler34from ubuntuone.devtools.handlers import MementoHandler
3435
@@ -158,18 +159,16 @@
158class BasicTestCase(TestCase):159class BasicTestCase(TestCase):
159 """Test case with a helper tracker."""160 """Test case with a helper tracker."""
160161
162 @defer.inlineCallbacks
161 def setUp(self):163 def setUp(self):
162 """Init."""164 """Init."""
165 yield super(BasicTestCase, self).setUp()
163 self._called = False # helper166 self._called = False # helper
164167
165 self.memento = MementoHandler()168 self.memento = MementoHandler()
166 self.memento.setLevel(logging.DEBUG)169 self.memento.setLevel(logging.DEBUG)
167 gui.logger.addHandler(self.memento)170 gui.logger.addHandler(self.memento)
168171
169 def tearDown(self):
170 """Clean up."""
171 self._called = False
172
173 def _set_called(self, *args, **kwargs):172 def _set_called(self, *args, **kwargs):
174 """Set _called to True."""173 """Set _called to True."""
175 self._called = (args, kwargs)174 self._called = (args, kwargs)
@@ -178,9 +177,10 @@
178class LabeledEntryTestCase(BasicTestCase):177class LabeledEntryTestCase(BasicTestCase):
179 """Test suite for the labeled entry."""178 """Test suite for the labeled entry."""
180179
180 @defer.inlineCallbacks
181 def setUp(self):181 def setUp(self):
182 """Init."""182 """Init."""
183 super(LabeledEntryTestCase, self).setUp()183 yield super(LabeledEntryTestCase, self).setUp()
184 self.label = 'Test me please'184 self.label = 'Test me please'
185 self.entry = gui.LabeledEntry(label=self.label)185 self.entry = gui.LabeledEntry(label=self.label)
186186
@@ -189,11 +189,6 @@
189 window.add(self.entry)189 window.add(self.entry)
190 window.show_all()190 window.show_all()
191191
192 def tearDown(self):
193 """Clean up."""
194 self.entry = None
195 super(LabeledEntryTestCase, self).tearDown()
196
197 def grab_focus(self, focus_in=True):192 def grab_focus(self, focus_in=True):
198 """Grab focus on widget, if None use self.entry."""193 """Grab focus on widget, if None use self.entry."""
199 direction = 'in' if focus_in else 'out'194 direction = 'in' if focus_in else 'out'
@@ -352,9 +347,10 @@
352class PasswordLabeledEntryTestCase(LabeledEntryTestCase):347class PasswordLabeledEntryTestCase(LabeledEntryTestCase):
353 """Test suite for the labeled entry when is_password is True."""348 """Test suite for the labeled entry when is_password is True."""
354349
350 @defer.inlineCallbacks
355 def setUp(self):351 def setUp(self):
356 """Init."""352 """Init."""
357 super(PasswordLabeledEntryTestCase, self).setUp()353 yield super(PasswordLabeledEntryTestCase, self).setUp()
358 self.entry.is_password = True354 self.entry.is_password = True
359355
360 def test_password_fields_are_visible_at_startup(self):356 def test_password_fields_are_visible_at_startup(self):
@@ -382,9 +378,10 @@
382 gui_class = gui.UbuntuSSOClientGUI378 gui_class = gui.UbuntuSSOClientGUI
383 kwargs = dict(app_name=APP_NAME, tc_url=TC_URL, help_text=HELP_TEXT)379 kwargs = dict(app_name=APP_NAME, tc_url=TC_URL, help_text=HELP_TEXT)
384380
381 @defer.inlineCallbacks
385 def setUp(self):382 def setUp(self):
386 """Init."""383 """Init."""
387 super(UbuntuSSOClientTestCase, self).setUp()384 yield super(UbuntuSSOClientTestCase, self).setUp()
388 self.patch(dbus, 'SessionBus', FakedSessionBus)385 self.patch(dbus, 'SessionBus', FakedSessionBus)
389 self.patch(dbus, 'Interface', FakedSSOBackend)386 self.patch(dbus, 'Interface', FakedSSOBackend)
390 self.pages = ('enter_details', 'processing', 'verify_email', 'finish',387 self.pages = ('enter_details', 'processing', 'verify_email', 'finish',
@@ -393,11 +390,11 @@
393 self.ui = self.gui_class(**self.kwargs)390 self.ui = self.gui_class(**self.kwargs)
394 self.error = {'message': UNKNOWN_ERROR}391 self.error = {'message': UNKNOWN_ERROR}
395392
393 @defer.inlineCallbacks
396 def tearDown(self):394 def tearDown(self):
397 """Clean up."""
398 self.ui.bus.callbacks = {}395 self.ui.bus.callbacks = {}
399 self.ui = None396 self.ui = None
400 super(UbuntuSSOClientTestCase, self).tearDown()397 yield super(UbuntuSSOClientTestCase, self).tearDown()
401398
402 def assert_entries_are_packed_to_ui(self, container_name, entries):399 def assert_entries_are_packed_to_ui(self, container_name, entries):
403 """Every entry is properly packed in the ui 'container_name'."""400 """Every entry is properly packed in the ui 'container_name'."""
@@ -917,8 +914,9 @@
917class TermsAndConditionsBrowserTestCase(UbuntuSSOClientTestCase):914class TermsAndConditionsBrowserTestCase(UbuntuSSOClientTestCase):
918 """Test suite for the terms & conditions browser."""915 """Test suite for the terms & conditions browser."""
919916
917 @defer.inlineCallbacks
920 def setUp(self):918 def setUp(self):
921 super(TermsAndConditionsBrowserTestCase, self).setUp()919 yield super(TermsAndConditionsBrowserTestCase, self).setUp()
922 self.patch(webkit, 'WebView', FakedEmbeddedBrowser)920 self.patch(webkit, 'WebView', FakedEmbeddedBrowser)
923921
924 self.ui.tc_button.clicked()922 self.ui.tc_button.clicked()
@@ -926,9 +924,10 @@
926 assert len(children) == 1924 assert len(children) == 1
927 self.browser = children[0]925 self.browser = children[0]
928926
927 @defer.inlineCallbacks
929 def tearDown(self):928 def tearDown(self):
930 self.ui.tc_browser_vbox.hide()929 self.ui.tc_browser_vbox.hide()
931 super(TermsAndConditionsBrowserTestCase, self).tearDown()930 yield super(TermsAndConditionsBrowserTestCase, self).tearDown()
932931
933 def test_tc_browser_is_created_when_tc_page_is_shown(self):932 def test_tc_browser_is_created_when_tc_page_is_shown(self):
934 """The browser is created when the TC button is clicked."""933 """The browser is created when the TC button is clicked."""
@@ -1074,9 +1073,10 @@
1074class RegistrationErrorTestCase(UbuntuSSOClientTestCase):1073class RegistrationErrorTestCase(UbuntuSSOClientTestCase):
1075 """Test suite for the user registration error handling."""1074 """Test suite for the user registration error handling."""
10761075
1076 @defer.inlineCallbacks
1077 def setUp(self):1077 def setUp(self):
1078 """Init."""1078 """Init."""
1079 super(RegistrationErrorTestCase, self).setUp()1079 yield super(RegistrationErrorTestCase, self).setUp()
1080 self.click_join_with_valid_data()1080 self.click_join_with_valid_data()
10811081
1082 def test_previous_page_is_shown(self):1082 def test_previous_page_is_shown(self):
@@ -1121,9 +1121,10 @@
1121class VerifyEmailTestCase(UbuntuSSOClientTestCase):1121class VerifyEmailTestCase(UbuntuSSOClientTestCase):
1122 """Test suite for the user registration (verify email page)."""1122 """Test suite for the user registration (verify email page)."""
11231123
1124 @defer.inlineCallbacks
1124 def setUp(self):1125 def setUp(self):
1125 """Init."""1126 """Init."""
1126 super(VerifyEmailTestCase, self).setUp()1127 yield super(VerifyEmailTestCase, self).setUp()
1127 self.ui.on_user_registered(app_name=APP_NAME, email=EMAIL)1128 self.ui.on_user_registered(app_name=APP_NAME, email=EMAIL)
1128 self.click_verify_email_with_valid_data()1129 self.click_verify_email_with_valid_data()
11291130
@@ -1265,9 +1266,10 @@
1265class VerifyEmailValidationTestCase(UbuntuSSOClientTestCase):1266class VerifyEmailValidationTestCase(UbuntuSSOClientTestCase):
1266 """Test suite for the user registration validation (verify email page)."""1267 """Test suite for the user registration validation (verify email page)."""
12671268
1269 @defer.inlineCallbacks
1268 def setUp(self):1270 def setUp(self):
1269 """Init."""1271 """Init."""
1270 super(VerifyEmailValidationTestCase, self).setUp()1272 yield super(VerifyEmailValidationTestCase, self).setUp()
1271 self.ui.on_user_registered(app_name=APP_NAME, email=EMAIL)1273 self.ui.on_user_registered(app_name=APP_NAME, email=EMAIL)
12721274
1273 def test_warning_is_shown_if_empty_email_token(self):1275 def test_warning_is_shown_if_empty_email_token(self):
@@ -1315,9 +1317,10 @@
1315class RegistrationValidationTestCase(UbuntuSSOClientTestCase):1317class RegistrationValidationTestCase(UbuntuSSOClientTestCase):
1316 """Test suite for the user registration validations."""1318 """Test suite for the user registration validations."""
13171319
1320 @defer.inlineCallbacks
1318 def setUp(self):1321 def setUp(self):
1319 """Init."""1322 """Init."""
1320 super(RegistrationValidationTestCase, self).setUp()1323 yield super(RegistrationValidationTestCase, self).setUp()
1321 self.ui.join_ok_button.set_sensitive(True)1324 self.ui.join_ok_button.set_sensitive(True)
13221325
1323 def test_warning_is_shown_if_name_empty(self):1326 def test_warning_is_shown_if_name_empty(self):
@@ -1448,9 +1451,10 @@
1448class LoginTestCase(UbuntuSSOClientTestCase):1451class LoginTestCase(UbuntuSSOClientTestCase):
1449 """Test suite for the user login pages."""1452 """Test suite for the user login pages."""
14501453
1454 @defer.inlineCallbacks
1451 def setUp(self):1455 def setUp(self):
1452 """Init."""1456 """Init."""
1453 super(LoginTestCase, self).setUp()1457 yield super(LoginTestCase, self).setUp()
1454 self.ui.login_button.clicked()1458 self.ui.login_button.clicked()
14551459
1456 def test_login_button_clicked_morphs_to_login_page(self):1460 def test_login_button_clicked_morphs_to_login_page(self):
@@ -1600,9 +1604,10 @@
1600class LoginValidationTestCase(UbuntuSSOClientTestCase):1604class LoginValidationTestCase(UbuntuSSOClientTestCase):
1601 """Test suite for the user login validation."""1605 """Test suite for the user login validation."""
16021606
1607 @defer.inlineCallbacks
1603 def setUp(self):1608 def setUp(self):
1604 """Init."""1609 """Init."""
1605 super(LoginValidationTestCase, self).setUp()1610 yield super(LoginValidationTestCase, self).setUp()
1606 self.ui.login_button.clicked()1611 self.ui.login_button.clicked()
16071612
1608 def test_warning_is_shown_if_empty_email(self):1613 def test_warning_is_shown_if_empty_email(self):
@@ -1656,9 +1661,10 @@
1656class ResetPasswordTestCase(UbuntuSSOClientTestCase):1661class ResetPasswordTestCase(UbuntuSSOClientTestCase):
1657 """Test suite for the reset password functionality."""1662 """Test suite for the reset password functionality."""
16581663
1664 @defer.inlineCallbacks
1659 def setUp(self):1665 def setUp(self):
1660 """Init."""1666 """Init."""
1661 super(ResetPasswordTestCase, self).setUp()1667 yield super(ResetPasswordTestCase, self).setUp()
1662 self.ui.login_button.clicked()1668 self.ui.login_button.clicked()
1663 self.ui.forgotten_password_button.clicked()1669 self.ui.forgotten_password_button.clicked()
16641670
@@ -1820,9 +1826,10 @@
1820class SetNewPasswordTestCase(UbuntuSSOClientTestCase):1826class SetNewPasswordTestCase(UbuntuSSOClientTestCase):
1821 """Test suite for setting a new password functionality."""1827 """Test suite for setting a new password functionality."""
18221828
1829 @defer.inlineCallbacks
1823 def setUp(self):1830 def setUp(self):
1824 """Init."""1831 """Init."""
1825 super(SetNewPasswordTestCase, self).setUp()1832 yield super(SetNewPasswordTestCase, self).setUp()
1826 self.click_request_password_token_with_valid_data()1833 self.click_request_password_token_with_valid_data()
1827 self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL)1834 self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL)
18281835
@@ -2122,9 +2129,10 @@
2122 REGISTRATION_SUCCESS = 'registration_success_callback'2129 REGISTRATION_SUCCESS = 'registration_success_callback'
2123 USER_CANCELLATION = 'user_cancellation_callback'2130 USER_CANCELLATION = 'user_cancellation_callback'
21242131
2132 @defer.inlineCallbacks
2125 def setUp(self):2133 def setUp(self):
2126 """Init."""2134 """Init."""
2127 super(CallbacksTestCase, self).setUp()2135 yield super(CallbacksTestCase, self).setUp()
2128 self._called = {}2136 self._called = {}
2129 for name in (self.LOGIN_SUCCESSFULL,2137 for name in (self.LOGIN_SUCCESSFULL,
2130 self.REGISTRATION_SUCCESS,2138 self.REGISTRATION_SUCCESS,
@@ -2258,9 +2266,10 @@
2258class DefaultButtonsTestCase(UbuntuSSOClientTestCase):2266class DefaultButtonsTestCase(UbuntuSSOClientTestCase):
2259 """Each UI page has a default button when visible."""2267 """Each UI page has a default button when visible."""
22602268
2269 @defer.inlineCallbacks
2261 def setUp(self):2270 def setUp(self):
2262 """Init."""2271 """Init."""
2263 super(DefaultButtonsTestCase, self).setUp()2272 yield super(DefaultButtonsTestCase, self).setUp()
2264 self.mapping = (2273 self.mapping = (
2265 ('enter_details_vbox', 'join_ok_button'),2274 ('enter_details_vbox', 'join_ok_button'),
2266 ('tc_browser_vbox', 'tc_back_button'),2275 ('tc_browser_vbox', 'tc_back_button'),
22672276
=== modified file 'ubuntu_sso/keyring/tests/test_linux.py'
--- ubuntu_sso/keyring/tests/test_linux.py 2011-10-17 18:24:55 +0000
+++ ubuntu_sso/keyring/tests/test_linux.py 2011-11-02 16:59:23 +0000
@@ -114,8 +114,10 @@
114114
115 timeout = 5115 timeout = 5
116116
117 @defer.inlineCallbacks
117 def setUp(self):118 def setUp(self):
118 """Initialize the mock used in these tests."""119 """Initialize the mock used in these tests."""
120 yield super(TestKeyring, self).setUp()
119 self.mock_service = None121 self.mock_service = None
120 self.service = self.patch(keyring, "SecretService",122 self.service = self.patch(keyring, "SecretService",
121 self.get_mock_service)123 self.get_mock_service)
122124
=== modified file 'ubuntu_sso/keyring/tests/test_windows.py'
--- ubuntu_sso/keyring/tests/test_windows.py 2011-10-13 12:03:04 +0000
+++ ubuntu_sso/keyring/tests/test_windows.py 2011-11-02 16:59:23 +0000
@@ -18,6 +18,7 @@
1818
19from json import dumps19from json import dumps
2020
21from twisted.internet import defer
21from twisted.trial.unittest import TestCase22from twisted.trial.unittest import TestCase
2223
23from ubuntu_sso.keyring import windows24from ubuntu_sso.keyring import windows
@@ -60,9 +61,10 @@
60class TestWindowsKeyring(TestCase):61class TestWindowsKeyring(TestCase):
61 """Test the windows keyring implementation."""62 """Test the windows keyring implementation."""
6263
64 @defer.inlineCallbacks
63 def setUp(self):65 def setUp(self):
64 """Setup tests."""66 """Setup tests."""
65 super(TestWindowsKeyring, self).setUp()67 yield super(TestWindowsKeyring, self).setUp()
66 self.app_name = 'app_name'68 self.app_name = 'app_name'
67 self.fake_keyring = FakePyKeyring()69 self.fake_keyring = FakePyKeyring()
68 self.keyring = windows.Keyring(self.fake_keyring)70 self.keyring = windows.Keyring(self.fake_keyring)
6971
=== modified file 'ubuntu_sso/main/tests/test_linux.py'
--- ubuntu_sso/main/tests/test_linux.py 2011-09-29 20:49:45 +0000
+++ ubuntu_sso/main/tests/test_linux.py 2011-11-02 16:59:23 +0000
@@ -24,7 +24,6 @@
2424
25from mocker import Mocker, ARGS, KWARGS25from mocker import Mocker, ARGS, KWARGS
26from twisted.internet import defer26from twisted.internet import defer
27from twisted.trial.unittest import TestCase
28from ubuntuone.devtools.handlers import MementoHandler27from ubuntuone.devtools.handlers import MementoHandler
2928
30import ubuntu_sso.keyring29import ubuntu_sso.keyring
@@ -75,8 +74,10 @@
7574
76 timeout = 275 timeout = 2
7776
77 @defer.inlineCallbacks
78 def setUp(self):78 def setUp(self):
79 """Create the mocking bus."""79 """Create the mocking bus."""
80 yield super(SsoDbusTestCase, self).setUp()
80 self.mocker = Mocker()81 self.mocker = Mocker()
81 self.mockbusname = self.mocker.mock()82 self.mockbusname = self.mocker.mock()
82 mockbus = self.mocker.mock()83 mockbus = self.mocker.mock()
@@ -97,10 +98,12 @@
97 self.keyring_was_set = False98 self.keyring_was_set = False
98 self.keyring_values = None99 self.keyring_values = None
99100
101 @defer.inlineCallbacks
100 def tearDown(self):102 def tearDown(self):
101 """Verify the mocking bus and shut it down."""103 """Verify the mocking bus and shut it down."""
102 self.mocker.verify()104 self.mocker.verify()
103 self.mocker.restore()105 self.mocker.restore()
106 yield super(SsoDbusTestCase, self).tearDown()
104107
105 def test_creation(self):108 def test_creation(self):
106 """Test that the object creation is successful."""109 """Test that the object creation is successful."""
@@ -569,8 +572,9 @@
569 UI_CLASS_KEY: 'SuperUI', UI_MODULE_KEY: 'foo.bar.baz',572 UI_CLASS_KEY: 'SuperUI', UI_MODULE_KEY: 'foo.bar.baz',
570 }573 }
571574
575 @defer.inlineCallbacks
572 def setUp(self):576 def setUp(self):
573 super(CredentialsManagementTestCase, self).setUp()577 yield super(CredentialsManagementTestCase, self).setUp()
574578
575 self.mocker = Mocker()579 self.mocker = Mocker()
576 self.client = CredentialsManagement(timeout_func=lambda *a: None,580 self.client = CredentialsManagement(timeout_func=lambda *a: None,
@@ -582,11 +586,12 @@
582 self.memento.setLevel(logging.DEBUG)586 self.memento.setLevel(logging.DEBUG)
583 ubuntu_sso.main.logger.addHandler(self.memento)587 ubuntu_sso.main.logger.addHandler(self.memento)
584588
589 @defer.inlineCallbacks
585 def tearDown(self):590 def tearDown(self):
586 """Verify the mocking stuff and shut it down."""591 """Verify the mocking stuff and shut it down."""
587 self.mocker.verify()592 self.mocker.verify()
588 self.mocker.restore()593 self.mocker.restore()
589 super(CredentialsManagementTestCase, self).tearDown()594 yield super(CredentialsManagementTestCase, self).tearDown()
590595
591 def assert_dbus_method_correct(self, method, out_signature=''):596 def assert_dbus_method_correct(self, method, out_signature=''):
592 """Check that 'method' is a dbus method with proper signatures."""597 """Check that 'method' is a dbus method with proper signatures."""
@@ -626,8 +631,9 @@
626class CredentialsManagementRefCountingTestCase(CredentialsManagementTestCase):631class CredentialsManagementRefCountingTestCase(CredentialsManagementTestCase):
627 """Tests for the CredentialsManagement ref counting."""632 """Tests for the CredentialsManagement ref counting."""
628633
634 @defer.inlineCallbacks
629 def setUp(self):635 def setUp(self):
630 super(CredentialsManagementRefCountingTestCase, self).setUp()636 yield super(CredentialsManagementRefCountingTestCase, self).setUp()
631 self.patch(ubuntu_sso.main, 'Credentials', FakeCredentials)637 self.patch(ubuntu_sso.main, 'Credentials', FakeCredentials)
632638
633 def test_ref_counting(self):639 def test_ref_counting(self):
@@ -1140,8 +1146,9 @@
1140class CredentialsManagementOpsTestCase(CredentialsManagementTestCase):1146class CredentialsManagementOpsTestCase(CredentialsManagementTestCase):
1141 """Tests for the CredentialsManagement login/register methods."""1147 """Tests for the CredentialsManagement login/register methods."""
11421148
1149 @defer.inlineCallbacks
1143 def setUp(self):1150 def setUp(self):
1144 super(CredentialsManagementOpsTestCase, self).setUp()1151 yield super(CredentialsManagementOpsTestCase, self).setUp()
1145 self.args = dict((k, str(v)) for k, v in self.base_args.iteritems())1152 self.args = dict((k, str(v)) for k, v in self.base_args.iteritems())
1146 self.cred_args = self.base_args.copy()1153 self.cred_args = self.base_args.copy()
1147 self.cred_args[SUCCESS_CB_KEY] = self.client.CredentialsFound1154 self.cred_args[SUCCESS_CB_KEY] = self.client.CredentialsFound
@@ -1179,15 +1186,19 @@
1179class CredentialsManagementParamsTestCase(CredentialsManagementOpsTestCase):1186class CredentialsManagementParamsTestCase(CredentialsManagementOpsTestCase):
1180 """Tests for the CredentialsManagement extra parameters handling."""1187 """Tests for the CredentialsManagement extra parameters handling."""
11811188
1189 @defer.inlineCallbacks
1182 def setUp(self):1190 def setUp(self):
1183 super(CredentialsManagementParamsTestCase, self).setUp()1191 yield super(CredentialsManagementParamsTestCase, self).setUp()
1184 self.args['dummy'] = 'nothing useful'1192 self.args['dummy'] = 'nothing useful'
11851193
11861194
1187class CredentialsManagementSignalsTestCase(TestCase):1195class CredentialsManagementSignalsTestCase(TestCase):
1188 """Tests for the CredentialsManagement DBus signals."""1196 """Tests for the CredentialsManagement DBus signals."""
11891197
1198 @defer.inlineCallbacks
1190 def setUp(self):1199 def setUp(self):
1200 """Set up."""
1201 yield super(CredentialsManagementSignalsTestCase, self).setUp()
1191 self.client = CredentialsManagement(timeout_func=lambda *a: None,1202 self.client = CredentialsManagement(timeout_func=lambda *a: None,
1192 shutdown_func=lambda *a: None)1203 shutdown_func=lambda *a: None)
11931204
11941205
=== modified file 'ubuntu_sso/main/tests/test_windows.py'
--- ubuntu_sso/main/tests/test_windows.py 2011-09-27 14:06:12 +0000
+++ ubuntu_sso/main/tests/test_windows.py 2011-11-02 16:59:23 +0000
@@ -96,9 +96,9 @@
96class SignalTestCase(MockerTestCase):96class SignalTestCase(MockerTestCase):
97 """Test the signal decorator."""97 """Test the signal decorator."""
9898
99 @defer.inlineCallbacks
99 def setUp(self):100 def setUp(self):
100 """Set the tests."""101 yield super(SignalTestCase, self).setUp()
101 super(SignalTestCase, self).setUp()
102 self.fake_object = FakeDecoratedObject()102 self.fake_object = FakeDecoratedObject()
103 self.cb = self.mocker.mock()103 self.cb = self.mocker.mock()
104104
@@ -275,15 +275,16 @@
275 self.client_factory = PBClientFactory()275 self.client_factory = PBClientFactory()
276 self.connector = reactor.connectTCP(LOCALHOST, port,276 self.connector = reactor.connectTCP(LOCALHOST, port,
277 self.client_factory)277 self.client_factory)
278
279 self.client = yield self._get_client()278 self.client = yield self._get_client()
280 # pylint: enable=E1101279 # pylint: enable=E1101
281280
281 @defer.inlineCallbacks
282 def tearDown(self):282 def tearDown(self):
283 """Clean reactor."""283 """Clean reactor."""
284 yield super(SSOLoginTestCase, self).tearDown()
284 if self.server_factory.protocolInstance is not None:285 if self.server_factory.protocolInstance is not None:
285 self.server_factory.protocolInstance.transport.loseConnection()286 self.server_factory.protocolInstance.transport.loseConnection()
286 return defer.gatherResults([self._tearDownServer(),287 yield defer.gatherResults([self._tearDownServer(),
287 self._tearDownClient()])288 self._tearDownClient()])
288289
289 def _tearDownServer(self):290 def _tearDownServer(self):
@@ -565,11 +566,13 @@
565 self.client = yield self._get_client()566 self.client = yield self._get_client()
566 # pylint: enable=E1101567 # pylint: enable=E1101
567568
569 @defer.inlineCallbacks
568 def tearDown(self):570 def tearDown(self):
569 """Clean reactor."""571 """Clean reactor."""
572 yield super(CredentialsManagementTestCase, self).tearDown()
570 if self.server_factory.protocolInstance is not None:573 if self.server_factory.protocolInstance is not None:
571 self.server_factory.protocolInstance.transport.loseConnection()574 self.server_factory.protocolInstance.transport.loseConnection()
572 return defer.gatherResults([self._tearDownServer(),575 yield defer.gatherResults([self._tearDownServer(),
573 self._tearDownClient()])576 self._tearDownClient()])
574577
575 def _tearDownServer(self):578 def _tearDownServer(self):
@@ -854,7 +857,9 @@
854857
855 # pylint: disable=W0212858 # pylint: disable=W0212
856859
860 @defer.inlineCallbacks
857 def setUp(self):861 def setUp(self):
862 yield super(UbuntuSSOClientTestCase, self).setUp()
858 self.mac = MockActivationClient()863 self.mac = MockActivationClient()
859 self.patch(windows, "reactor", MockReactor())864 self.patch(windows, "reactor", MockReactor())
860 self.patch(windows, "PBClientFactory", MockPBClientFactory)865 self.patch(windows, "PBClientFactory", MockPBClientFactory)
861866
=== modified file 'ubuntu_sso/qt/tests/test_common.py'
--- ubuntu_sso/qt/tests/test_common.py 2011-09-01 17:05:11 +0000
+++ ubuntu_sso/qt/tests/test_common.py 2011-11-02 16:59:23 +0000
@@ -17,6 +17,7 @@
17"""Test the common functions."""17"""Test the common functions."""
1818
19from PyQt4 import QtGui19from PyQt4 import QtGui
20from twisted.internet import defer
20from twisted.trial.unittest import TestCase21from twisted.trial.unittest import TestCase
2122
22from ubuntu_sso.qt.common import (check_as_invalid,23from ubuntu_sso.qt.common import (check_as_invalid,
@@ -35,9 +36,10 @@
35class PasswordTestCase(TestCase):36class PasswordTestCase(TestCase):
36 """Test passwords conditions."""37 """Test passwords conditions."""
3738
39 @defer.inlineCallbacks
38 def setUp(self):40 def setUp(self):
39 """Setup tests."""41 """Setup tests."""
40 super(PasswordTestCase, self).setUp()42 yield super(PasswordTestCase, self).setUp()
41 self.line_edit = QtGui.QLineEdit()43 self.line_edit = QtGui.QLineEdit()
42 self.line_edit_confirm = QtGui.QLineEdit()44 self.line_edit_confirm = QtGui.QLineEdit()
43 self.label_assistance = QtGui.QLabel()45 self.label_assistance = QtGui.QLabel()
4446
=== modified file 'ubuntu_sso/qt/tests/test_controllers.py'
--- ubuntu_sso/qt/tests/test_controllers.py 2011-10-07 12:31:54 +0000
+++ ubuntu_sso/qt/tests/test_controllers.py 2011-11-02 16:59:23 +0000
@@ -711,9 +711,10 @@
711class ChooseSignInControllerTestCase(BaseTestCase):711class ChooseSignInControllerTestCase(BaseTestCase):
712 """Test the choose sign in controller."""712 """Test the choose sign in controller."""
713713
714 @defer.inlineCallbacks
714 def setUp(self):715 def setUp(self):
715 """Set tests."""716 """Set tests."""
716 super(ChooseSignInControllerTestCase, self).setUp()717 yield super(ChooseSignInControllerTestCase, self).setUp()
717 self.title = 'title'718 self.title = 'title'
718 self.subtitle = 'subtitle'719 self.subtitle = 'subtitle'
719 self.controller = ChooseSignInController(self.title, self.subtitle)720 self.controller = ChooseSignInController(self.title, self.subtitle)
@@ -768,9 +769,10 @@
768class CurrentUserControllerTestCase(BaseTestCase):769class CurrentUserControllerTestCase(BaseTestCase):
769 """Test the current user controller."""770 """Test the current user controller."""
770771
772 @defer.inlineCallbacks
771 def setUp(self):773 def setUp(self):
772 """Setup tests."""774 """Setup tests."""
773 super(CurrentUserControllerTestCase, self).setUp()775 yield super(CurrentUserControllerTestCase, self).setUp()
774 self.controller = CurrentUserController(title='the title',776 self.controller = CurrentUserController(title='the title',
775 subtitle='the subtitle')777 subtitle='the subtitle')
776 self.view = FakeCurrentUserView()778 self.view = FakeCurrentUserView()
@@ -867,9 +869,10 @@
867 on_error_method_name = "on_login_error"869 on_error_method_name = "on_login_error"
868 controller_class = CurrentUserController870 controller_class = CurrentUserController
869871
872 @defer.inlineCallbacks
870 def setUp(self):873 def setUp(self):
871 """Setup test."""874 """Setup test."""
872 super(CurrentUserControllerErrorTestCase, self).setUp()875 yield super(CurrentUserControllerErrorTestCase, self).setUp()
873 self.message_box = FakeMessageBox()876 self.message_box = FakeMessageBox()
874 self.controller = self.controller_class(877 self.controller = self.controller_class(
875 message_box=self.message_box)878 message_box=self.message_box)
@@ -928,9 +931,10 @@
928 on_error_method_name = "on_email_validation_error"931 on_error_method_name = "on_email_validation_error"
929 controller_class = EmailVerificationController932 controller_class = EmailVerificationController
930933
934 @defer.inlineCallbacks
931 def setUp(self):935 def setUp(self):
932 """Setup test."""936 """Setup test."""
933 super(EmailVerificationControllerErrorTestCase, self).setUp()937 yield super(EmailVerificationControllerErrorTestCase, self).setUp()
934 # This error handler takes one extra argument.938 # This error handler takes one extra argument.
935 self.on_error_method = lambda error: getattr(939 self.on_error_method = lambda error: getattr(
936 self.controller, self.on_error_method_name)('APP', error)940 self.controller, self.on_error_method_name)('APP', error)
@@ -944,9 +948,10 @@
944 on_error_method_name = "on_user_registration_error"948 on_error_method_name = "on_user_registration_error"
945 controller_class = SetUpAccountController949 controller_class = SetUpAccountController
946950
951 @defer.inlineCallbacks
947 def setUp(self):952 def setUp(self):
948 """Setup test."""953 """Setup test."""
949 super(SetUpAccountControllerErrorTestCase, self).setUp()954 yield super(SetUpAccountControllerErrorTestCase, self).setUp()
950 self.patch(self.controller, "_refresh_captcha", lambda *args: None)955 self.patch(self.controller, "_refresh_captcha", lambda *args: None)
951956
952957
@@ -963,9 +968,10 @@
963968
964 """Tests for CurrentUserController, but without Mocker."""969 """Tests for CurrentUserController, but without Mocker."""
965970
971 @defer.inlineCallbacks
966 def setUp(self):972 def setUp(self):
967 """Setup test."""973 """Setup test."""
968 super(CurrentUserControllerValidationTest, self).setUp()974 yield super(CurrentUserControllerValidationTest, self).setUp()
969 self.message_box = FakeMessageBox()975 self.message_box = FakeMessageBox()
970 self.controller = CurrentUserController(976 self.controller = CurrentUserController(
971 message_box=self.message_box)977 message_box=self.message_box)
@@ -1023,9 +1029,10 @@
1023class SetUpAccountControllerTestCase(BaseTestCase):1029class SetUpAccountControllerTestCase(BaseTestCase):
1024 """test the controller used to setup a new account."""1030 """test the controller used to setup a new account."""
10251031
1032 @defer.inlineCallbacks
1026 def setUp(self):1033 def setUp(self):
1027 """Set the different tests."""1034 """Set the different tests."""
1028 super(SetUpAccountControllerTestCase, self).setUp()1035 yield super(SetUpAccountControllerTestCase, self).setUp()
1029 self.view = FakeSetupAccountPageView()1036 self.view = FakeSetupAccountPageView()
1030 self.message_box = FakeMessageBox()1037 self.message_box = FakeMessageBox()
1031 self.controller = SetUpAccountController(message_box=self.message_box)1038 self.controller = SetUpAccountController(message_box=self.message_box)
@@ -1432,9 +1439,10 @@
1432class SetupAccountControllerCaptchaTest(BaseTestCase):1439class SetupAccountControllerCaptchaTest(BaseTestCase):
1433 """Tests for SetupAccountController, but without Mocker."""1440 """Tests for SetupAccountController, but without Mocker."""
14341441
1442 @defer.inlineCallbacks
1435 def setUp(self):1443 def setUp(self):
1436 """Set the different tests."""1444 """Set the different tests."""
1437 super(SetupAccountControllerCaptchaTest, self).setUp()1445 yield super(SetupAccountControllerCaptchaTest, self).setUp()
1438 self.message_box = FakeMessageBox()1446 self.message_box = FakeMessageBox()
1439 self.controller = SetUpAccountController(message_box=self.message_box)1447 self.controller = SetUpAccountController(message_box=self.message_box)
1440 self.patch(self.controller, 'view', FakeSetupAccountView())1448 self.patch(self.controller, 'view', FakeSetupAccountView())
@@ -1452,9 +1460,10 @@
1452class SetupAccountControllerValidationTest(BaseTestCase):1460class SetupAccountControllerValidationTest(BaseTestCase):
1453 """Tests for SetupAccountController, but without Mocker."""1461 """Tests for SetupAccountController, but without Mocker."""
14541462
1463 @defer.inlineCallbacks
1455 def setUp(self):1464 def setUp(self):
1456 """Set the different tests."""1465 """Set the different tests."""
1457 super(SetupAccountControllerValidationTest, self).setUp()1466 yield super(SetupAccountControllerValidationTest, self).setUp()
1458 self.message_box = FakeMessageBox()1467 self.message_box = FakeMessageBox()
1459 self.controller = SetUpAccountController(message_box=self.message_box)1468 self.controller = SetUpAccountController(message_box=self.message_box)
1460 self.patch(self.controller, '_refresh_captcha', self._set_called)1469 self.patch(self.controller, '_refresh_captcha', self._set_called)
@@ -1509,9 +1518,10 @@
1509class EmailVerificationControllerTestCase(BaseTestCase):1518class EmailVerificationControllerTestCase(BaseTestCase):
1510 """Test the controller."""1519 """Test the controller."""
15111520
1521 @defer.inlineCallbacks
1512 def setUp(self):1522 def setUp(self):
1513 """Set tests."""1523 """Set tests."""
1514 super(EmailVerificationControllerTestCase, self).setUp()1524 yield super(EmailVerificationControllerTestCase, self).setUp()
1515 self.view = EmailVerificationView()1525 self.view = EmailVerificationView()
1516 self.backend = self.view1526 self.backend = self.view
1517 self.controller = EmailVerificationController(1527 self.controller = EmailVerificationController(
@@ -1599,9 +1609,11 @@
1599class EmailVerificationControllerValidationTestCase(BaseTestCase):1609class EmailVerificationControllerValidationTestCase(BaseTestCase):
1600 """Tests for EmailVerificationController, but without Mocker."""1610 """Tests for EmailVerificationController, but without Mocker."""
16011611
1612 @defer.inlineCallbacks
1602 def setUp(self):1613 def setUp(self):
1603 """Set the different tests."""1614 """Set the different tests."""
1604 super(EmailVerificationControllerValidationTestCase, self).setUp()1615 yield super(EmailVerificationControllerValidationTestCase,
1616 self).setUp()
1605 self.message_box = FakeMessageBox()1617 self.message_box = FakeMessageBox()
1606 self.controller = EmailVerificationController(1618 self.controller = EmailVerificationController(
1607 message_box=self.message_box)1619 message_box=self.message_box)
@@ -1642,9 +1654,9 @@
1642class ErrorControllerTestCase(BaseTestCase):1654class ErrorControllerTestCase(BaseTestCase):
1643 """Test the success page controller."""1655 """Test the success page controller."""
16441656
1657 @defer.inlineCallbacks
1645 def setUp(self):1658 def setUp(self):
1646 """Set the tests."""1659 yield super(ErrorControllerTestCase, self).setUp()
1647 super(ErrorControllerTestCase, self).setUp()
1648 self.view = ErrorPageView()1660 self.view = ErrorPageView()
1649 self.backend = self.view1661 self.backend = self.view
1650 self.controller = ErrorController()1662 self.controller = ErrorController()
@@ -1665,9 +1677,9 @@
1665class SuccessControllerTestCase(BaseTestCase):1677class SuccessControllerTestCase(BaseTestCase):
1666 """Test the success page controller."""1678 """Test the success page controller."""
16671679
1680 @defer.inlineCallbacks
1668 def setUp(self):1681 def setUp(self):
1669 """Set the tests."""1682 yield super(SuccessControllerTestCase, self).setUp()
1670 super(SuccessControllerTestCase, self).setUp()
1671 self.view = SuccessPageView()1683 self.view = SuccessPageView()
1672 self.backend = self.view1684 self.backend = self.view
1673 self.controller = SuccessController()1685 self.controller = SuccessController()
@@ -1688,9 +1700,10 @@
1688class UbuntuSSOWizardControllerTestCase(BaseTestCase):1700class UbuntuSSOWizardControllerTestCase(BaseTestCase):
1689 """Test the wizard controller."""1701 """Test the wizard controller."""
16901702
1703 @defer.inlineCallbacks
1691 def setUp(self):1704 def setUp(self):
1692 """Set tests."""1705 """Set tests."""
1693 super(UbuntuSSOWizardControllerTestCase, self).setUp()1706 yield super(UbuntuSSOWizardControllerTestCase, self).setUp()
1694 self.view = UbuntuSSOView()1707 self.view = UbuntuSSOView()
1695 self.backend = self.view1708 self.backend = self.view
1696 self.callback = self.view.callback1709 self.callback = self.view.callback
@@ -1765,9 +1778,10 @@
17651778
1766 """Tests for ForgottenPasswordController, but without Mocker."""1779 """Tests for ForgottenPasswordController, but without Mocker."""
17671780
1781 @defer.inlineCallbacks
1768 def setUp(self):1782 def setUp(self):
1769 """Set the different tests."""1783 """Set the different tests."""
1770 super(ForgottenPasswordControllerValidationTest, self).setUp()1784 yield super(ForgottenPasswordControllerValidationTest, self).setUp()
1771 self.message_box = FakeMessageBox()1785 self.message_box = FakeMessageBox()
1772 self.controller = ForgottenPasswordController(1786 self.controller = ForgottenPasswordController(
1773 message_box=self.message_box)1787 message_box=self.message_box)
@@ -1857,9 +1871,10 @@
1857class ForgottenPasswordControllerTestCase(BaseTestCase):1871class ForgottenPasswordControllerTestCase(BaseTestCase):
1858 """Test the controller of the fogotten password page."""1872 """Test the controller of the fogotten password page."""
18591873
1874 @defer.inlineCallbacks
1860 def setUp(self):1875 def setUp(self):
1861 """Setup the tests."""1876 """Setup the tests."""
1862 super(ForgottenPasswordControllerTestCase, self).setUp()1877 yield super(ForgottenPasswordControllerTestCase, self).setUp()
1863 self.view = FakeForgottenPasswordPageView()1878 self.view = FakeForgottenPasswordPageView()
1864 self.backend = self.view1879 self.backend = self.view
1865 self.controller = ForgottenPasswordController(1880 self.controller = ForgottenPasswordController(
@@ -1926,9 +1941,10 @@
1926class ResetPasswordControllerTestCase(BaseTestCase):1941class ResetPasswordControllerTestCase(BaseTestCase):
1927 """Ensure that the reset password works as expected."""1942 """Ensure that the reset password works as expected."""
19281943
1944 @defer.inlineCallbacks
1929 def setUp(self):1945 def setUp(self):
1930 """Setup the tests."""1946 """Setup the tests."""
1931 super(ResetPasswordControllerTestCase, self).setUp()1947 yield super(ResetPasswordControllerTestCase, self).setUp()
1932 self.view = ResetPasswordPageView()1948 self.view = ResetPasswordPageView()
1933 self.backend = self.view1949 self.backend = self.view
1934 self.controller = ResetPasswordController()1950 self.controller = ResetPasswordController()
@@ -2001,9 +2017,10 @@
20012017
2002 """Tests for ResetPasswordController, but without Mocker."""2018 """Tests for ResetPasswordController, but without Mocker."""
20032019
2020 @defer.inlineCallbacks
2004 def setUp(self):2021 def setUp(self):
2005 """Setup test."""2022 """Setup test."""
2006 super(ResetPasswordControllerValidationTest, self).setUp()2023 yield super(ResetPasswordControllerValidationTest, self).setUp()
2007 self.controller = ResetPasswordController()2024 self.controller = ResetPasswordController()
2008 self.controller.view = FakeResetPasswordPage()2025 self.controller.view = FakeResetPasswordPage()
20092026
@@ -2067,9 +2084,10 @@
20672084
2068 """Tests for ResetPasswordController, but without Mocker."""2085 """Tests for ResetPasswordController, but without Mocker."""
20692086
2087 @defer.inlineCallbacks
2070 def setUp(self):2088 def setUp(self):
2071 """Setup test."""2089 """Setup test."""
2072 super(ResetPasswordControllerRealControllerTest, self).setUp()2090 yield super(ResetPasswordControllerRealControllerTest, self).setUp()
2073 self.controller = ResetPasswordController()2091 self.controller = ResetPasswordController()
2074 self.controller.view = FakeWizardForResetPassword()2092 self.controller.view = FakeWizardForResetPassword()
20752093
20762094
=== modified file 'ubuntu_sso/qt/tests/test_reset_password.py'
--- ubuntu_sso/qt/tests/test_reset_password.py 2011-09-08 16:43:39 +0000
+++ ubuntu_sso/qt/tests/test_reset_password.py 2011-11-02 16:59:23 +0000
@@ -17,6 +17,7 @@
17"""Test the Reset Password Page."""17"""Test the Reset Password Page."""
1818
19from PyQt4 import QtGui, QtCore19from PyQt4 import QtGui, QtCore
20from twisted.internet import defer
20from twisted.trial.unittest import TestCase21from twisted.trial.unittest import TestCase
2122
22from ubuntu_sso.utils.ui import (23from ubuntu_sso.utils.ui import (
@@ -47,8 +48,9 @@
47class ResetPasswordTestCase(TestCase):48class ResetPasswordTestCase(TestCase):
48 """Test the ResetPasswordPage code."""49 """Test the ResetPasswordPage code."""
4950
51 @defer.inlineCallbacks
50 def setUp(self):52 def setUp(self):
51 super(ResetPasswordTestCase, self).setUp()53 yield super(ResetPasswordTestCase, self).setUp()
52 self.page = ResetPasswordPage(Ui_ResetPasswordPage(),54 self.page = ResetPasswordPage(Ui_ResetPasswordPage(),
53 None,55 None,
54 None)56 None)
5557
=== modified file 'ubuntu_sso/tests/__init__.py'
--- ubuntu_sso/tests/__init__.py 2011-08-11 21:26:53 +0000
+++ ubuntu_sso/tests/__init__.py 2011-11-02 16:59:23 +0000
@@ -18,6 +18,7 @@
1818
19import os19import os
2020
21from twisted.internet import defer
21from twisted.trial import unittest22from twisted.trial import unittest
2223
23from ubuntu_sso.keyring import get_token_name24from ubuntu_sso.keyring import get_token_name
@@ -52,8 +53,9 @@
52class TestCase(unittest.TestCase):53class TestCase(unittest.TestCase):
53 """Customized test case that keeps tracks of method calls."""54 """Customized test case that keeps tracks of method calls."""
5455
56 @defer.inlineCallbacks
55 def setUp(self):57 def setUp(self):
56 super(TestCase, self).setUp()58 yield super(TestCase, self).setUp()
57 self._called = False59 self._called = False
5860
59 def _set_called(self, *args, **kwargs):61 def _set_called(self, *args, **kwargs):
6062
=== modified file 'ubuntu_sso/tests/test_account.py'
--- ubuntu_sso/tests/test_account.py 2011-10-21 16:06:50 +0000
+++ ubuntu_sso/tests/test_account.py 2011-11-02 16:59:23 +0000
@@ -27,6 +27,7 @@
27# pylint: enable=F040127# pylint: enable=F0401
28from oauth import oauth28from oauth import oauth
29from twisted.trial.unittest import TestCase29from twisted.trial.unittest import TestCase
30from twisted.internet import defer
3031
31from ubuntu_sso.account import (32from ubuntu_sso.account import (
32 Account,33 Account,
@@ -200,8 +201,10 @@
200class AccountTestCase(TestCase):201class AccountTestCase(TestCase):
201 """Test suite for the SSO login processor."""202 """Test suite for the SSO login processor."""
202203
204 @defer.inlineCallbacks
203 def setUp(self):205 def setUp(self):
204 """Init."""206 """Set up."""
207 yield super(AccountTestCase, self).setUp()
205208
206 def fake_urlopen(url):209 def fake_urlopen(url):
207 """Fake an urlopen which will read from the disk."""210 """Fake an urlopen which will read from the disk."""
@@ -218,8 +221,10 @@
218 self.login_kwargs = dict(email=EMAIL, password=PASSWORD,221 self.login_kwargs = dict(email=EMAIL, password=PASSWORD,
219 token_name=TOKEN_NAME)222 token_name=TOKEN_NAME)
220223
224 @defer.inlineCallbacks
221 def tearDown(self):225 def tearDown(self):
222 """Clean up."""226 """Tear down."""
227 yield super(AccountTestCase, self).tearDown()
223 self.processor = None228 self.processor = None
224229
225 def test_generate_captcha(self):230 def test_generate_captcha(self):
226231
=== modified file 'ubuntu_sso/tests/test_credentials.py'
--- ubuntu_sso/tests/test_credentials.py 2011-09-22 14:29:21 +0000
+++ ubuntu_sso/tests/test_credentials.py 2011-11-02 16:59:23 +0000
@@ -103,18 +103,16 @@
103class BasicTestCase(TestCase):103class BasicTestCase(TestCase):
104 """Test case with a helper tracker."""104 """Test case with a helper tracker."""
105105
106 @defer.inlineCallbacks
106 def setUp(self):107 def setUp(self):
107 """Init."""108 """Init."""
109 yield super(BasicTestCase, self).setUp()
108 self._called = False # helper110 self._called = False # helper
109111
110 self.memento = MementoHandler()112 self.memento = MementoHandler()
111 self.memento.setLevel(logging.DEBUG)113 self.memento.setLevel(logging.DEBUG)
112 credentials.logger.addHandler(self.memento)114 credentials.logger.addHandler(self.memento)
113115
114 def tearDown(self):
115 """Clean up."""
116 self._called = False
117
118 def _set_called(self, *args, **kwargs):116 def _set_called(self, *args, **kwargs):
119 """Set _called to True."""117 """Set _called to True."""
120 self._called = (args, kwargs)118 self._called = (args, kwargs)
@@ -123,9 +121,10 @@
123class CredentialsTestCase(BasicTestCase):121class CredentialsTestCase(BasicTestCase):
124 """Test suite for the Credentials class."""122 """Test suite for the Credentials class."""
125123
124 @defer.inlineCallbacks
126 def setUp(self):125 def setUp(self):
127 """Init."""126 """Init."""
128 super(CredentialsTestCase, self).setUp()127 yield super(CredentialsTestCase, self).setUp()
129 self.obj = credentials.Credentials(success_cb=self.success,128 self.obj = credentials.Credentials(success_cb=self.success,
130 error_cb=self.error,129 error_cb=self.error,
131 denial_cb=self.denial,130 denial_cb=self.denial,
@@ -360,8 +359,9 @@
360class PingUrlTestCase(CredentialsTestCase):359class PingUrlTestCase(CredentialsTestCase):
361 """Test suite for the URL pinging."""360 """Test suite for the URL pinging."""
362361
362 @defer.inlineCallbacks
363 def setUp(self):363 def setUp(self):
364 super(PingUrlTestCase, self).setUp()364 yield super(PingUrlTestCase, self).setUp()
365 self._request = None365 self._request = None
366366
367 def faked_urlopen(request):367 def faked_urlopen(request):
@@ -552,8 +552,9 @@
552 kwargs = {}552 kwargs = {}
553 inner_class = FakedClientGUI553 inner_class = FakedClientGUI
554554
555 @defer.inlineCallbacks
555 def setUp(self):556 def setUp(self):
556 super(RegisterTestCase, self).setUp()557 yield super(RegisterTestCase, self).setUp()
557 self.inner_kwargs = UI_KWARGS.copy()558 self.inner_kwargs = UI_KWARGS.copy()
558 self.inner_kwargs['login_only'] = self.login_only559 self.inner_kwargs['login_only'] = self.login_only
559 self.method_call = getattr(self.obj, self.operation)560 self.method_call = getattr(self.obj, self.operation)
@@ -649,8 +650,9 @@
649 kwargs = {'email': EMAIL, 'password': PASSWORD}650 kwargs = {'email': EMAIL, 'password': PASSWORD}
650 inner_class = FakedSSOLoginRoot651 inner_class = FakedSSOLoginRoot
651652
653 @defer.inlineCallbacks
652 def setUp(self):654 def setUp(self):
653 super(LoginEmailPasswordTestCase, self).setUp()655 yield super(LoginEmailPasswordTestCase, self).setUp()
654 self.inner_kwargs = {APP_NAME_KEY: APP_NAME, 'email': EMAIL,656 self.inner_kwargs = {APP_NAME_KEY: APP_NAME, 'email': EMAIL,
655 'password': PASSWORD,657 'password': PASSWORD,
656 'result_cb': self.obj._login_success_cb,658 'result_cb': self.obj._login_success_cb,
657659
=== modified file 'ubuntu_sso/utils/tests/test_oauth_headers.py'
--- ubuntu_sso/utils/tests/test_oauth_headers.py 2011-10-06 21:46:56 +0000
+++ ubuntu_sso/utils/tests/test_oauth_headers.py 2011-11-02 16:59:23 +0000
@@ -191,8 +191,10 @@
191class TimestampCheckerTestCase(TestCase):191class TimestampCheckerTestCase(TestCase):
192 """Tests for the timestamp checker."""192 """Tests for the timestamp checker."""
193193
194 @defer.inlineCallbacks
194 def setUp(self):195 def setUp(self):
195 """Initialize a fake webserver."""196 """Initialize a fake webserver."""
197 yield super(TimestampCheckerTestCase, self).setUp()
196 self.ws = MockWebServer()198 self.ws = MockWebServer()
197 self.addCleanup(self.ws.stop)199 self.addCleanup(self.ws.stop)
198 self.patch(SyncTimestampChecker, "SERVER_URL", self.ws.get_url())200 self.patch(SyncTimestampChecker, "SERVER_URL", self.ws.get_url())
199201
=== modified file 'ubuntu_sso/utils/tests/test_tcpactivation.py'
--- ubuntu_sso/utils/tests/test_tcpactivation.py 2011-07-15 14:25:35 +0000
+++ ubuntu_sso/utils/tests/test_tcpactivation.py 2011-11-02 16:59:23 +0000
@@ -71,8 +71,10 @@
71class AsyncSleepTestCase(TestCase):71class AsyncSleepTestCase(TestCase):
72 """Tests for the async_sleep function."""72 """Tests for the async_sleep function."""
7373
74 @defer.inlineCallbacks
74 def setUp(self):75 def setUp(self):
75 """Initialize this test instance."""76 """Initialize this test instance."""
77 yield super(AsyncSleepTestCase, self).setUp()
76 self.test_timeout = 5.078 self.test_timeout = 5.0
77 self.clock = task.Clock()79 self.clock = task.Clock()
78 self.patch(tcpactivation, "reactor", self.clock)80 self.patch(tcpactivation, "reactor", self.clock)
@@ -110,8 +112,10 @@
110112
111 timeout = 2113 timeout = 2
112114
115 @defer.inlineCallbacks
113 def setUp(self):116 def setUp(self):
114 """Initialize this test instance."""117 """Initialize this test instance."""
118 yield super(PortDetectFactoryTestCase, self).setUp()
115 self.factory = PortDetectFactory()119 self.factory = PortDetectFactory()
116120
117 @defer.inlineCallbacks121 @defer.inlineCallbacks
@@ -169,8 +173,10 @@
169class ActivationDetectorTestCase(TestCase):173class ActivationDetectorTestCase(TestCase):
170 """Tests for the ActivationDetector class."""174 """Tests for the ActivationDetector class."""
171175
176 @defer.inlineCallbacks
172 def setUp(self):177 def setUp(self):
173 """Initialize this test instance."""178 """Initialize this test instance."""
179 yield super(ActivationDetectorTestCase, self).setUp()
174 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,180 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,
175 SAMPLE_PORT)181 SAMPLE_PORT)
176182
@@ -206,8 +212,10 @@
206212
207 timeout = 2213 timeout = 2
208214
215 @defer.inlineCallbacks
209 def setUp(self):216 def setUp(self):
210 """Initialize this test instance."""217 """Initialize this test instance."""
218 yield super(ActivationClientTestCase, self).setUp()
211 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,219 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,
212 SAMPLE_PORT)220 SAMPLE_PORT)
213221
@@ -292,8 +300,10 @@
292300
293 timeout = 2301 timeout = 2
294302
303 @defer.inlineCallbacks
295 def setUp(self):304 def setUp(self):
296 """Initialize this test instance."""305 """Initialize this test instance."""
306 yield super(ActivationInstanceTestCase, self).setUp()
297 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,307 self.config = ActivationConfig(SAMPLE_SERVICE, SAMPLE_CMDLINE,
298 SAMPLE_PORT)308 SAMPLE_PORT)
299309
300310
=== modified file 'ubuntu_sso/utils/tests/test_txsecrets.py'
--- ubuntu_sso/utils/tests/test_txsecrets.py 2011-07-05 15:26:05 +0000
+++ ubuntu_sso/utils/tests/test_txsecrets.py 2011-11-02 16:59:23 +0000
@@ -394,8 +394,9 @@
394 timeout = 10394 timeout = 10
395 secret_service_class = SecretServiceMock395 secret_service_class = SecretServiceMock
396396
397 @inlineCallbacks
397 def setUp(self):398 def setUp(self):
398 super(BaseTestCase, self).setUp()399 yield super(BaseTestCase, self).setUp()
399 self.session_bus = dbus.SessionBus()400 self.session_bus = dbus.SessionBus()
400 self.mock_service = self.dbus_publish(txsecrets.SECRETS_SERVICE,401 self.mock_service = self.dbus_publish(txsecrets.SECRETS_SERVICE,
401 self.secret_service_class)402 self.secret_service_class)

Subscribers

People subscribed via source and target branches