Merge lp:~nataliabidart/ubuntu-sso-client/no-more-blocking into lp:ubuntu-sso-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 850
Merged at revision: 850
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/no-more-blocking
Merge into: lp:ubuntu-sso-client
Diff against target: 154 lines (+1/-83)
4 files modified
ubuntu_sso/main/__init__.py (+0/-1)
ubuntu_sso/main/linux.py (+0/-14)
ubuntu_sso/main/tests/test_common.py (+1/-58)
ubuntu_sso/main/windows.py (+0/-10)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/no-more-blocking
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+91954@code.launchpad.net

Commit message

- Remove unused "thread_execute" function (LP: #928581).

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (61.2 KiB)

The attempt to merge lp:~nataliabidart/ubuntu-sso-client/no-more-blocking into lp:ubuntu-sso-client failed. Below is the output from the failed tests.

*** Running GTK test suite for ubuntu_sso ***
ubuntu_sso.tests.test_account
  AccountTestCase
    test_generate_captcha ... [OK]
    test_is_not_validated ... [OK]
    test_is_not_validated_empty_result ... [OK]
    test_is_validated ... [OK]
    test_login_if_http_error ... [OK]
    test_login_if_no_error ... [OK]
    test_register_user_checks_valid_email ... [OK]
    test_register_user_checks_valid_password ... [OK]
    test_register_user_if_status_error ... [OK]
    test_register_user_if_status_error_with_string_message ... [OK]
    test_register_user_if_status_ok ... [OK]
    test_register_user_if_status_unknown ... [OK]
    test_request_password_reset_token_if_http_error ... [OK]
    test_request_password_reset_token_if_status_ok ... [OK]
    test_request_password_reset_token_if_status_unknown ... [OK]
    test_set_new_password_if_http_error ... [OK]
    test_set_new_password_if_status_ok ... [OK]
    test_set_new_password_if_status_unknown ... [OK]
    test_validate_email_if_status_error ... [OK]
    test_validate_email_if_status_error_with_string_message ... [OK]
    test_validate_email_if_status_ok ... [OK]
    test_validate_email_if_status_unknown ... [OK]
  EnvironOverridesTestCase
    test_no_override_service_url ... [OK]
    test_override_service_url ... [OK]
    test_service_url_as_parameter ... [OK]
twisted.trial.unittest
  TestCase
    runTest ... [OK]
ubuntu_sso.tests.test_account
  TimestampedAuthorizerTestCase
    test_authorize_request_includes_timestamp ... [OK]
ubuntu_sso.tests.test_credentials
  BasicTestCase
    runTest ... [OK]
  ClearCredentialsTestCase
    test_clear_credentials ... [OK]
    test_keyring_failure ... [OK]
  CredentialsAuthDeniedTestCase
    test_auth_denial_cb ... [OK]
  CredentialsCallbacksTestCase
    test_callbacks_are_stored ... [OK]
    test_callbacks_default_to_no_op ... [OK]
    test_creation_parameters_are_stored ... ...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/main/__init__.py'
2--- ubuntu_sso/main/__init__.py 2012-02-03 13:54:29 +0000
3+++ ubuntu_sso/main/__init__.py 2012-02-08 00:37:21 +0000
4@@ -58,7 +58,6 @@
5
6 UbuntuSSOProxy = source.UbuntuSSOProxy
7 get_sso_client = source.get_sso_client
8-thread_execute = source.blocking
9
10
11 def except_to_errdict(e):
12
13=== modified file 'ubuntu_sso/main/linux.py'
14--- ubuntu_sso/main/linux.py 2012-02-03 13:54:29 +0000
15+++ ubuntu_sso/main/linux.py 2012-02-08 00:37:21 +0000
16@@ -27,7 +27,6 @@
17
18 import os
19 import signal
20-import threading
21
22 import dbus
23 import dbus.service
24@@ -52,19 +51,6 @@
25 logger = setup_logging("ubuntu_sso.main.linux")
26
27
28-def blocking(f, app_name, result_cb, error_cb):
29- """Run f in a thread; return or throw an exception thru the callbacks."""
30- def _in_thread():
31- """The part that runs inside the thread."""
32- try:
33- result_cb(app_name, f())
34- except Exception, e: # pylint: disable=W0703
35- msg = "Exception while running blocking code in a thread:"
36- logger.exception(msg)
37- error_cb(app_name, e)
38- threading.Thread(target=_in_thread).start()
39-
40-
41 class SSOLoginProxy(dbus.service.Object):
42 """Login thru the Single Sign On service."""
43
44
45=== modified file 'ubuntu_sso/main/tests/test_common.py'
46--- ubuntu_sso/main/tests/test_common.py 2012-01-20 18:08:04 +0000
47+++ ubuntu_sso/main/tests/test_common.py 2012-02-08 00:37:21 +0000
48@@ -25,7 +25,6 @@
49 CredentialsManagement,
50 except_to_errdict,
51 SSOLogin,
52- thread_execute,
53 TIMEOUT_INTERVAL,
54 UbuntuSSOService,
55 )
56@@ -43,22 +42,7 @@
57
58
59 class SampleException(Exception):
60- """The exception that will be thrown by the fake thread_execute."""
61-
62-
63-def fake_ok_thread_execute(f, app, cb, eb):
64- """A fake thread_execute function that succeeds."""
65- cb(app, f())
66-
67-
68-def fake_err_thread_execute(f, app, cb, eb):
69- """A fake thread_execute function that fails."""
70- try:
71- f()
72- except Exception, e: # pylint: disable=W0703
73- eb(app, except_to_errdict(e))
74- else:
75- eb(app, except_to_errdict(SampleException()))
76+ """A sample exception."""
77
78
79 class FakedProxy(Recorder):
80@@ -423,47 +407,6 @@
81 self.assertEqual(app_name, APP_NAME)
82
83
84-class BlockingFunctionTestCase(TestCase):
85- """Tests for the "thread_execute" function."""
86-
87- timeout = 5
88-
89- @defer.inlineCallbacks
90- def test_thread_execute(self):
91- """Test the normal behaviour."""
92- d = defer.Deferred()
93- expected_result = "expected result"
94-
95- def f():
96- """No failure."""
97- return expected_result
98-
99- thread_execute(f, APP_NAME, lambda *a: d.callback(a), d.errback)
100-
101- app_name, result = yield d
102-
103- self.assertEqual(result, expected_result)
104- self.assertEqual(app_name, APP_NAME)
105-
106- @defer.inlineCallbacks
107- def test_thread_execute_error(self):
108- """Test the behaviour when an Exception is raised."""
109- d = defer.Deferred()
110- expected_error_message = "expected error message"
111- expected_exc = SampleException(expected_error_message)
112-
113- def f():
114- """Failure."""
115- raise expected_exc
116-
117- thread_execute(f, APP_NAME, d.errback, lambda *a: d.callback(a))
118-
119- app_name, error = yield d
120-
121- self.assertEqual(app_name, APP_NAME)
122- self.assertEqual(error, expected_exc)
123-
124-
125 class CredentialsManagementTestCase(BaseTestCase):
126 """Tests for the CredentialsManagement DBus interface."""
127
128
129=== modified file 'ubuntu_sso/main/windows.py'
130--- ubuntu_sso/main/windows.py 2012-02-07 14:45:29 +0000
131+++ ubuntu_sso/main/windows.py 2012-02-08 00:37:21 +0000
132@@ -33,7 +33,6 @@
133
134 from twisted.internet import defer
135 from twisted.internet.task import LoopingCall
136-from twisted.internet.threads import deferToThread
137 from twisted.python.failure import Failure
138
139 from ubuntu_sso.logger import setup_logging
140@@ -88,15 +87,6 @@
141 return value
142
143
144-def blocking(f, app_name, result_cb, error_cb):
145- """Run f in a thread; return or throw an exception thru the callbacks."""
146- d = deferToThread(f)
147- # the calls in twisted will be called with the args in a diff order,
148- # in order to follow the linux api, we swap them around with a lambda
149- d.addCallback(lambda result, app: result_cb(app, result), app_name)
150- d.addErrback(lambda err, app: error_cb(app, err.value), app_name)
151-
152-
153 class SSOLoginProxy(RemoteService):
154 """Login thru the Single Sign On service."""
155

Subscribers

People subscribed via source and target branches