Merge lp:~nataliabidart/ubuntuone-control-panel/cmt-wtf into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 165
Merged at revision: 164
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/cmt-wtf
Merge into: lp:ubuntuone-control-panel
Diff against target: 576 lines (+142/-381)
8 files modified
setup.py (+1/-1)
ubuntuone/controlpanel/gui/qt/main/linux.py (+1/-0)
ubuntuone/controlpanel/integrationtests/test_login_client/__init__.py (+0/-19)
ubuntuone/controlpanel/integrationtests/test_login_client/test_linux.py (+0/-207)
ubuntuone/controlpanel/login_client.py (+40/-0)
ubuntuone/controlpanel/login_client/__init__.py (+0/-27)
ubuntuone/controlpanel/login_client/linux.py (+0/-127)
ubuntuone/controlpanel/tests/test_login_client.py (+100/-0)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/cmt-wtf
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+65026@code.launchpad.net

Commit message

- Login client is now platform independent (LP: #798687).

Description of the change

To test IRL, and since we're replacing the backend that handles credentials, you should run both the new backend and the GTK UI:

$ DEBUG=True PYTHONPATH=. ./bin/ubuntuone-control-panel-backend
$ DEBUG=True PYTHONPATH=. ./bin/ubuntuone-control-panel-gtk

First test would be confirm that all your account and plan data is retrieved (this means that new credentials backend was able to retrieve correct credentials). Then you can remove the current device, and re-authenticate from the overview screen.

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Code looks good, account info was gotten successfully, removing and adding device worked. When I close the control panel, the backend gives this, which is probably not new:

2011-06-17 13:02:03,285 - ubuntuone.controlpanel.backend - INFO - shutdown: args (<ubuntuone.controlpanel.backend.ControlBackend object at 0x26eb990>,), kwargs {}.
Fatal Python error: PyEval_RestoreThread: NULL tstate
Aborted

review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks great, works as advertised.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2011-05-25 13:59:47 +0000
3+++ setup.py 2011-06-17 16:05:59 +0000
4@@ -230,7 +230,7 @@
5 packages=[
6 'ubuntuone', 'ubuntuone.controlpanel', 'ubuntuone.controlpanel.gui',
7 'ubuntuone.controlpanel.gui.gtk', 'ubuntuone.controlpanel.gui.qt',
8- 'ubuntuone.controlpanel.login_client', 'ubuntuone.controlpanel.sd_client',
9+ 'ubuntuone.controlpanel.sd_client',
10 'ubuntuone.controlpanel.web_client',
11 ],
12 extra_path='ubuntuone-control-panel',
13
14=== modified file 'ubuntuone/controlpanel/gui/qt/main/linux.py'
15--- ubuntuone/controlpanel/gui/qt/main/linux.py 2011-06-16 18:18:23 +0000
16+++ ubuntuone/controlpanel/gui/qt/main/linux.py 2011-06-17 16:05:59 +0000
17@@ -56,6 +56,7 @@
18 """A custom SDTool."""
19
20 settings = {
21+ 'file_sync_enabled': True,
22 'autoconnect': True,
23 'show_all_notifications': True,
24 'share_autosubscribe': False,
25
26=== removed directory 'ubuntuone/controlpanel/integrationtests/test_login_client'
27=== removed file 'ubuntuone/controlpanel/integrationtests/test_login_client/__init__.py'
28--- ubuntuone/controlpanel/integrationtests/test_login_client/__init__.py 2011-05-26 22:08:32 +0000
29+++ ubuntuone/controlpanel/integrationtests/test_login_client/__init__.py 1970-01-01 00:00:00 +0000
30@@ -1,19 +0,0 @@
31-# -*- coding: utf-8 -*-
32-
33-# Authors: Natalia B Bidart <natalia.bidart@canonical.com>
34-#
35-# Copyright 2011 Canonical Ltd.
36-#
37-# This program is free software: you can redistribute it and/or modify it
38-# under the terms of the GNU General Public License version 3, as published
39-# by the Free Software Foundation.
40-#
41-# This program is distributed in the hope that it will be useful, but
42-# WITHOUT ANY WARRANTY; without even the implied warranties of
43-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
44-# PURPOSE. See the GNU General Public License for more details.
45-#
46-# You should have received a copy of the GNU General Public License along
47-# with this program. If not, see <http://www.gnu.org/licenses/>.
48-
49-"""The login client test suite."""
50
51=== removed file 'ubuntuone/controlpanel/integrationtests/test_login_client/test_linux.py'
52--- ubuntuone/controlpanel/integrationtests/test_login_client/test_linux.py 2011-05-26 22:08:32 +0000
53+++ ubuntuone/controlpanel/integrationtests/test_login_client/test_linux.py 1970-01-01 00:00:00 +0000
54@@ -1,207 +0,0 @@
55-# -*- coding: utf-8 -*-
56-
57-# Authors: Alejandro J. Cura <alecu@canonical.com>
58-# Authors: Natalia B. Bidart <nataliabidart@canonical.com>
59-#
60-# Copyright 2010 Canonical Ltd.
61-#
62-# This program is free software: you can redistribute it and/or modify it
63-# under the terms of the GNU General Public License version 3, as published
64-# by the Free Software Foundation.
65-#
66-# This program is distributed in the hope that it will be useful, but
67-# WITHOUT ANY WARRANTY; without even the implied warranties of
68-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
69-# PURPOSE. See the GNU General Public License for more details.
70-#
71-# You should have received a copy of the GNU General Public License along
72-# with this program. If not, see <http://www.gnu.org/licenses/>.
73-
74-"""Tests for the DBus service when accessing Single Sign On."""
75-
76-# pylint: disable=C0103
77-# DBus signals have CamelCased names
78-
79-import dbus
80-
81-from ubuntu_sso import (DBUS_BUS_NAME,
82- DBUS_CREDENTIALS_PATH, DBUS_CREDENTIALS_IFACE)
83-from twisted.internet.defer import inlineCallbacks
84-
85-from ubuntuone.controlpanel import login_client
86-from ubuntuone.controlpanel.integrationtests import (MockDBusNoMethods,
87- DBusClientTestCase)
88-
89-
90-SAMPLE_CREDS = {
91- "token": "ABCDEF12345678",
92- "access_token": "DEADCAFE2010",
93-}
94-OTHER_CREDS = {"token": "other!"}
95-SAMPLE_ERROR = {"error message": "test", "detailed_error": "error details"}
96-
97-# pylint: disable=C0322
98-# pylint, you have to go to decorator's school
99-
100-
101-class MockDBusSSOService(dbus.service.Object):
102- """A mock object that mimicks ussoc."""
103-
104- found = True
105- wrong_app = None
106- error = None
107-
108- @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE,
109- in_signature='sa{ss}', out_signature='')
110- def find_credentials(self, app_name, args):
111- """Get creds from the keyring, login/register if needed."""
112- if self.wrong_app is None and self.error is None:
113- if self.found:
114- self.CredentialsFound(app_name, SAMPLE_CREDS)
115- else:
116- self.CredentialsNotFound(app_name)
117- elif self.wrong_app is not None and self.error is None:
118- self.CredentialsFound(self.wrong_app, OTHER_CREDS)
119- elif self.wrong_app is None and self.error is not None:
120- self.CredentialsError(app_name, self.error)
121- else:
122- self.CredentialsError(self.wrong_app, self.error)
123-
124- self.CredentialsFound(app_name, SAMPLE_CREDS)
125-
126- @dbus.service.method(dbus_interface=DBUS_CREDENTIALS_IFACE,
127- in_signature='sa{ss}', out_signature='')
128- def clear_credentials(self, app_name, args):
129- """Clear the credentials for an application."""
130- self.found = False
131-
132- if self.wrong_app is None and self.error is None:
133- self.CredentialsCleared(app_name)
134- elif self.wrong_app is not None and self.error is None:
135- self.CredentialsCleared(self.wrong_app)
136- elif self.wrong_app is None and self.error is not None:
137- self.CredentialsError(app_name, self.error)
138- else:
139- self.CredentialsError(self.wrong_app, self.error)
140-
141- self.CredentialsCleared(app_name)
142-
143- @dbus.service.signal(DBUS_CREDENTIALS_IFACE, signature='sa{ss}')
144- def CredentialsFound(self, app_name, credentials):
145- """Signal thrown when the credentials are found."""
146-
147- @dbus.service.signal(DBUS_CREDENTIALS_IFACE, signature='s')
148- def CredentialsNotFound(self, app_name):
149- """Signal thrown when the credentials are not found."""
150-
151- @dbus.service.signal(DBUS_CREDENTIALS_IFACE, signature='s')
152- def CredentialsCleared(self, app_name):
153- """Signal thrown when the credentials were cleared."""
154-
155- @dbus.service.signal(DBUS_CREDENTIALS_IFACE, signature='s')
156- def CredentialsStored(self, app_name):
157- """Signal thrown when the credentials were cleared."""
158-
159- @dbus.service.signal(DBUS_CREDENTIALS_IFACE, signature='sa{ss}')
160- def CredentialsError(self, app_name, error_dict):
161- """Signal thrown when there is a problem getting the credentials."""
162-
163-
164-class SSOClientTestCase(DBusClientTestCase):
165- """Test for the SSO dbus client."""
166-
167- def setUp(self):
168- super(SSOClientTestCase, self).setUp()
169- self.register_mockserver(DBUS_BUS_NAME, DBUS_CREDENTIALS_PATH,
170- MockDBusSSOService)
171- MockDBusSSOService.wrong_app = None
172- MockDBusSSOService.error = None
173- MockDBusSSOService.found = True
174-
175- # get_credentials
176-
177- @inlineCallbacks
178- def test_get_credentials_ok(self):
179- """Test the success case for get_credentials."""
180- creds = yield login_client.get_credentials()
181- self.assertEqual(creds, SAMPLE_CREDS)
182-
183- @inlineCallbacks
184- def test_get_credentials_not_found(self):
185- """Credentials were not found."""
186- yield login_client.clear_credentials() # not found will be sent
187- yield self.assertFailure(login_client.get_credentials(),
188- login_client.CredentialsError)
189-
190- @inlineCallbacks
191- def test_get_credentials_other(self):
192- """Creds for other apps are ignored."""
193- MockDBusSSOService.wrong_app = 'other app!'
194- creds = yield login_client.get_credentials()
195- self.assertEqual(creds, SAMPLE_CREDS)
196-
197- @inlineCallbacks
198- def test_get_credentials_error(self):
199- """Test what happens when the creds can't be retrieved."""
200- MockDBusSSOService.error = SAMPLE_ERROR
201- yield self.assertFailure(login_client.get_credentials(),
202- login_client.CredentialsError)
203-
204- @inlineCallbacks
205- def test_get_credentials_other_error(self):
206- """Other creds err before ours are retrieved."""
207- MockDBusSSOService.wrong_app = 'other app!'
208- MockDBusSSOService.error = SAMPLE_ERROR
209- creds = yield login_client.get_credentials()
210- self.assertEqual(creds, SAMPLE_CREDS)
211-
212- # clear_credentials
213-
214- @inlineCallbacks
215- def test_clear_credentials_ok(self):
216- """Test the success case for clear_credentials."""
217- result = yield login_client.clear_credentials()
218- self.assertEqual(result, login_client.APP_NAME)
219-
220- @inlineCallbacks
221- def test_clear_credentials_other(self):
222- """Creds for other apps are ignored."""
223- MockDBusSSOService.wrong_app = 'other app!'
224- result = yield login_client.clear_credentials()
225- self.assertEqual(result, login_client.APP_NAME)
226-
227- @inlineCallbacks
228- def test_clear_credentials_error(self):
229- """Test what happens when the creds can't be retrieved."""
230- MockDBusSSOService.error = SAMPLE_ERROR
231- yield self.assertFailure(login_client.clear_credentials(),
232- login_client.CredentialsError)
233-
234- @inlineCallbacks
235- def test_clear_credentials_other_error(self):
236- """Other creds err before ours are retrieved."""
237- MockDBusSSOService.wrong_app = 'other app!'
238- MockDBusSSOService.error = SAMPLE_ERROR
239- result = yield login_client.clear_credentials()
240- self.assertEqual(result, login_client.APP_NAME)
241-
242-
243-class NoMethodsSSOClientTestCase(DBusClientTestCase):
244- """Test for the SSO dbus client when the service provides no methods."""
245-
246- def setUp(self):
247- super(NoMethodsSSOClientTestCase, self).setUp()
248- self.register_mockserver(DBUS_BUS_NAME, DBUS_CREDENTIALS_PATH,
249- MockDBusNoMethods)
250-
251- @inlineCallbacks
252- def test_get_credentials_dbus_error(self):
253- """Test what happens when there's a DBus error."""
254- yield self.assertFailure(login_client.get_credentials(),
255- dbus.DBusException)
256-
257- @inlineCallbacks
258- def test_clear_credentials_dbus_error(self):
259- """Test what happens when there's a DBus error."""
260- yield self.assertFailure(login_client.clear_credentials(),
261- dbus.DBusException)
262
263=== removed directory 'ubuntuone/controlpanel/login_client'
264=== added file 'ubuntuone/controlpanel/login_client.py'
265--- ubuntuone/controlpanel/login_client.py 1970-01-01 00:00:00 +0000
266+++ ubuntuone/controlpanel/login_client.py 2011-06-17 16:05:59 +0000
267@@ -0,0 +1,40 @@
268+# -*- coding: utf-8 -*-
269+
270+# Authors: Natalia B. Bidart <nataliabidart@canonical.com>
271+#
272+# Copyright 2011 Canonical Ltd.
273+#
274+# This program is free software: you can redistribute it and/or modify it
275+# under the terms of the GNU General Public License version 3, as published
276+# by the Free Software Foundation.
277+#
278+# This program is distributed in the hope that it will be useful, but
279+# WITHOUT ANY WARRANTY; without even the implied warranties of
280+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
281+# PURPOSE. See the GNU General Public License for more details.
282+#
283+# You should have received a copy of the GNU General Public License along
284+# with this program. If not, see <http://www.gnu.org/licenses/>.
285+
286+"""Client to access Ubuntu One credentials."""
287+
288+
289+def get_sso_proxy():
290+ """Return a login client."""
291+ # No name 'credentials' in module 'ubuntuone.platform'
292+ # Reimport 'credentials' (imported line 22)
293+ # pylint: disable=E0611,W0404
294+ from ubuntuone.platform import credentials
295+ return credentials.CredentialsManagementTool()
296+
297+
298+def get_credentials():
299+ """Get the credentials for Ubuntu One."""
300+ proxy = get_sso_proxy()
301+ return proxy.find_credentials()
302+
303+
304+def clear_credentials():
305+ """Clear the credentials for Ubuntu One."""
306+ proxy = get_sso_proxy()
307+ return proxy.clear_credentials()
308
309=== removed file 'ubuntuone/controlpanel/login_client/__init__.py'
310--- ubuntuone/controlpanel/login_client/__init__.py 2011-05-18 19:12:57 +0000
311+++ ubuntuone/controlpanel/login_client/__init__.py 1970-01-01 00:00:00 +0000
312@@ -1,27 +0,0 @@
313-# -*- coding: utf-8 -*-
314-
315-# Authors: Natalia B Bidart <natalia.bidart@canonical.com>
316-#
317-# Copyright 2011 Canonical Ltd.
318-#
319-# This program is free software: you can redistribute it and/or modify it
320-# under the terms of the GNU General Public License version 3, as published
321-# by the Free Software Foundation.
322-#
323-# This program is distributed in the hope that it will be useful, but
324-# WITHOUT ANY WARRANTY; without even the implied warranties of
325-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
326-# PURPOSE. See the GNU General Public License for more details.
327-#
328-# You should have received a copy of the GNU General Public License along
329-# with this program. If not, see <http://www.gnu.org/licenses/>.
330-
331-"""The login client."""
332-
333-import sys
334-
335-# pylint: disable=W0401, W0614
336-
337-
338-if sys.platform == "linux2":
339- from ubuntuone.controlpanel.login_client.linux import *
340
341=== removed file 'ubuntuone/controlpanel/login_client/linux.py'
342--- ubuntuone/controlpanel/login_client/linux.py 2011-05-18 19:12:57 +0000
343+++ ubuntuone/controlpanel/login_client/linux.py 1970-01-01 00:00:00 +0000
344@@ -1,127 +0,0 @@
345-# -*- coding: utf-8 -*-
346-
347-# Authors: Alejandro J. Cura <alecu@canonical.com>
348-# Authors: Natalia B. Bidart <nataliabidart@canonical.com>
349-#
350-# Copyright 2010 Canonical Ltd.
351-#
352-# This program is free software: you can redistribute it and/or modify it
353-# under the terms of the GNU General Public License version 3, as published
354-# by the Free Software Foundation.
355-#
356-# This program is distributed in the hope that it will be useful, but
357-# WITHOUT ANY WARRANTY; without even the implied warranties of
358-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
359-# PURPOSE. See the GNU General Public License for more details.
360-#
361-# You should have received a copy of the GNU General Public License along
362-# with this program. If not, see <http://www.gnu.org/licenses/>.
363-
364-"""Client to use other DBus services."""
365-
366-import dbus.service
367-import ubuntu_sso
368-
369-from twisted.internet import defer
370-
371-from ubuntuone.clientdefs import APP_NAME
372-from ubuntuone.controlpanel.logger import setup_logging
373-
374-
375-logger = setup_logging('login_client')
376-
377-
378-class CredentialsError(Exception):
379- """No credentials could be retrieved."""
380-
381-
382-def no_op(*a):
383- """Do nothing"""
384-
385-
386-def get_sso_proxy():
387- """Get a DBus proxy for credentials management."""
388- bus = dbus.SessionBus()
389- obj = bus.get_object(bus_name=ubuntu_sso.DBUS_BUS_NAME,
390- object_path=ubuntu_sso.DBUS_CREDENTIALS_PATH,
391- follow_name_owner_changes=True)
392- proxy = dbus.Interface(object=obj,
393- dbus_interface=ubuntu_sso.DBUS_CREDENTIALS_IFACE)
394- return proxy
395-
396-
397-def get_credentials():
398- """Get the credentials from the ubuntu-sso-client."""
399- d = defer.Deferred()
400- proxy = get_sso_proxy()
401-
402- def found_credentials(app_name, creds):
403- """Credentials have been found."""
404- if app_name == APP_NAME:
405- logger.info('credentials were found! (%r).', APP_NAME)
406- d.callback(creds)
407-
408- def credentials_error(app_name, error_dict=None):
409- """No credentials could be retrieved."""
410- if app_name == APP_NAME:
411- if error_dict is None:
412- error_dict = {'error_message': 'Credentials were not found.',
413- 'detailed_error': ''}
414-
415- logger.error('credentials error (%r, %r).', app_name, error_dict)
416- error = CredentialsError(app_name, error_dict)
417- d.errback(error)
418-
419- foundsig = proxy.connect_to_signal("CredentialsFound", found_credentials)
420- notfoundsig = proxy.connect_to_signal("CredentialsNotFound",
421- credentials_error)
422- errorsig = proxy.connect_to_signal("CredentialsError", credentials_error)
423- logger.debug('calling get_credentials.')
424- proxy.find_credentials(APP_NAME, {'': ''},
425- reply_handler=no_op, error_handler=d.errback)
426-
427- def cleanup_signals(result):
428- """Remove signals after use."""
429- foundsig.remove()
430- notfoundsig.remove()
431- errorsig.remove()
432- return result
433-
434- d.addBoth(cleanup_signals)
435- return d
436-
437-
438-def clear_credentials():
439- """Clear the credentials using the ubuntu-sso-client."""
440- d = defer.Deferred()
441- proxy = get_sso_proxy()
442-
443- def credentials_cleared(app_name):
444- """Credentials have been cleared."""
445- logger.debug('credentials were cleared for app_name %r.', app_name)
446- if app_name == APP_NAME:
447- logger.info('credentials were cleared! (%r).', APP_NAME)
448- d.callback(app_name)
449-
450- def credentials_error(app_name, error_dict=None):
451- """No credentials could be retrieved."""
452- if app_name == APP_NAME:
453- logger.error('credentials error (%r, %r).', app_name, error_dict)
454- error = CredentialsError(app_name, error_dict)
455- d.errback(error)
456-
457- clearedsig = proxy.connect_to_signal("CredentialsCleared",
458- credentials_cleared)
459- errorsig = proxy.connect_to_signal("CredentialsError", credentials_error)
460- logger.warning('calling clear_credentials.')
461- proxy.clear_credentials(APP_NAME, {'': ''},
462- reply_handler=no_op, error_handler=d.errback)
463-
464- def cleanup_signals(result):
465- """Remove signals after use."""
466- clearedsig.remove()
467- errorsig.remove()
468- return result
469-
470- d.addBoth(cleanup_signals)
471- return d
472
473=== added file 'ubuntuone/controlpanel/tests/test_login_client.py'
474--- ubuntuone/controlpanel/tests/test_login_client.py 1970-01-01 00:00:00 +0000
475+++ ubuntuone/controlpanel/tests/test_login_client.py 2011-06-17 16:05:59 +0000
476@@ -0,0 +1,100 @@
477+# -*- coding: utf-8 -*-
478+
479+# Authors: Natalia B. Bidart <natalia.bidart@canonical.com>
480+#
481+# Copyright 2011 Canonical Ltd.
482+#
483+# This program is free software: you can redistribute it and/or modify it
484+# under the terms of the GNU General Public License version 3, as published
485+# by the Free Software Foundation.
486+#
487+# This program is distributed in the hope that it will be useful, but
488+# WITHOUT ANY WARRANTY; without even the implied warranties of
489+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
490+# PURPOSE. See the GNU General Public License for more details.
491+#
492+# You should have received a copy of the GNU General Public License along
493+# with this program. If not, see <http://www.gnu.org/licenses/>.
494+
495+"""Tests for the service when accessing the login client."""
496+
497+from twisted.internet import defer
498+# No name 'credentials' in module 'ubuntuone.platform'
499+# pylint: disable=E0611
500+from ubuntuone.platform import credentials
501+# pylint: enable=E0611
502+
503+from ubuntuone.controlpanel import login_client
504+from ubuntuone.controlpanel.tests import TestCase, TOKEN
505+
506+
507+class CustomError(Exception):
508+ """Custom error for tests."""
509+
510+
511+class FakedCredentialsManagementTool(object):
512+ """Fake the CredentialsManagementTool."""
513+
514+ credentials = None
515+
516+ @defer.inlineCallbacks
517+ def find_credentials(self):
518+ """Find credentials for Ubuntu One."""
519+ yield
520+ defer.returnValue(FakedCredentialsManagementTool.credentials)
521+
522+ @defer.inlineCallbacks
523+ def clear_credentials(self):
524+ """Clear credentials for Ubuntu One."""
525+ FakedCredentialsManagementTool.credentials = None
526+ yield
527+
528+
529+class BaseTestCase(TestCase):
530+ """Base TestCase for the login client methods."""
531+
532+ def setUp(self):
533+ super(BaseTestCase, self).setUp()
534+ self.patch(credentials, 'CredentialsManagementTool',
535+ FakedCredentialsManagementTool)
536+ FakedCredentialsManagementTool.credentials = TOKEN
537+
538+ def fake_fail(self, *a):
539+ """Fake a failure."""
540+ return defer.fail(CustomError(a))
541+
542+
543+class FindCredentialsTestCase(BaseTestCase):
544+ """Test for the find_credentials method."""
545+
546+ @defer.inlineCallbacks
547+ def test_find_credentials(self):
548+ """The credentials are properly retrieved."""
549+ actual = yield login_client.get_credentials()
550+ self.assertEqual(actual, TOKEN)
551+
552+ @defer.inlineCallbacks
553+ def test_find_credentials_throws_an_error(self):
554+ """If find_credentials fails, the error is propagated."""
555+ self.patch(FakedCredentialsManagementTool, 'find_credentials',
556+ self.fake_fail)
557+ yield self.assertFailure(login_client.get_credentials(),
558+ CustomError)
559+
560+
561+class ClearCredentialsTestCase(BaseTestCase):
562+ """Test for the clear_credentials method."""
563+
564+ @defer.inlineCallbacks
565+ def test_clear_credentials(self):
566+ """The credentials are properly retrieved."""
567+ yield login_client.clear_credentials()
568+ self.assertEqual(None, FakedCredentialsManagementTool.credentials)
569+
570+ @defer.inlineCallbacks
571+ def test_clear_credentials_throws_an_error(self):
572+ """If clear_credentials fails, the error is propagated."""
573+ self.patch(FakedCredentialsManagementTool, 'clear_credentials',
574+ self.fake_fail)
575+ yield self.assertFailure(login_client.clear_credentials(),
576+ CustomError)

Subscribers

People subscribed via source and target branches