Merge lp:~rodrigo-moya/ubuntuone-client/use-sso-in-u1-prefs into lp:ubuntuone-client

Proposed by Rodrigo Moya
Status: Merged
Approved by: dobey
Approved revision: 651
Merged at revision: 650
Proposed branch: lp:~rodrigo-moya/ubuntuone-client/use-sso-in-u1-prefs
Merge into: lp:ubuntuone-client
Diff against target: 517 lines (+71/-125)
2 files modified
bin/ubuntuone-preferences (+54/-82)
tests/test_preferences.py (+17/-43)
To merge this branch: bzr merge lp:~rodrigo-moya/ubuntuone-client/use-sso-in-u1-prefs
Reviewer Review Type Date Requested Status
dobey (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+33523@code.launchpad.net

Commit message

Make ubuntuone-preferences use ubuntu-sso

Description of the change

Make ubuntuone-preferences use ubuntu-sso

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

For the constants use those in ubuntuone/clientdefs.py.

Please fix the docstrings "Helper that handles the REST response." (and the similar ones).

This needs to use APP_NAME instead of 'ubuntuone': iface.clear_token('ubuntuone'.
This also: + if app_name == "Ubuntu One":

Remove + print "Got credentials"
Remove _() for log messages.

review: Needs Fixing
648. By Rodrigo Moya

Some fixes

Revision history for this message
dobey (dobey) wrote :

Your change introduces a regression where multiple dialogs can be opened in the same process. There should only ever be one single dialog for this process.

review: Needs Fixing
649. By Rodrigo Moya

Create the dialog only once

Revision history for this message
dobey (dobey) wrote :

It looks like test_login_check in the tests is skipped at the moment, but it should be updated to comply with the changes here too. I'd also avoid using globals for the oauth_token and oauth_consumer variables, and store them as attributes in the dialog (and pass them on to the other classes and methods that might need them).

I'm still confused about the changes for the dialog creation though. Why did you change it to not create the dialog when starting up? Shouldn't the dialog be created and shown, and its window id passed over to ubuntu_sso for setting as the parent?

The dialog creation was how it was, in order to show the dialog to the user as soon as possible, so that they know things are happening. Is there a good reason to not do that now?

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

The docstrings were not fixed (see lines 92-94 and 104-106)

review: Needs Fixing
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

> The docstrings were not fixed (see lines 92-94 and 104-106)

I think they're fixed now, I guess you wanted them on just 1 line?

650. By Rodrigo Moya

Fixed docstrings

Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

> It looks like test_login_check in the tests is skipped at the moment, but it
> should be updated to comply with the changes here too. I'd also avoid using
> globals for the oauth_token and oauth_consumer variables, and store them as
> attributes in the dialog (and pass them on to the other classes and methods
> that might need them).
>
test_login_check still depends on the real DBus service to be run, not sure how we can make it work without depending on the tests in ubuntu-sso-client. If there's a way, I'm ok with doing it, but not in this branch, which is needed for the new release to be done today or tomorrow at the latest.

> I'm still confused about the changes for the dialog creation though. Why did
> you change it to not create the dialog when starting up? Shouldn't the dialog
> be created and shown, and its window id passed over to ubuntu_sso for setting
> as the parent?
>
well, what was the point of having a dialog with all the widgets showing temporary data ('Unknown', etc)? So, now, we create the dialog associated to the LoginHandler, and show it when we get the credentials or when calling _present

> The dialog creation was how it was, in order to show the dialog to the user as
> soon as possible, so that they know things are happening. Is there a good
> reason to not do that now?
>
if the credentials are in the keyring, the dialog will show up inmediately, if not, they will see the SSO login/register screen

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

Looks great now!

review: Approve
651. By Rodrigo Moya

Move instantiation of dialog back to its original place

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/ubuntuone-preferences'
--- bin/ubuntuone-preferences 2010-06-16 18:44:02 +0000
+++ bin/ubuntuone-preferences 2010-08-24 21:19:41 +0000
@@ -3,9 +3,10 @@
33
4# ubuntuone-client-applet - Tray icon applet for managing Ubuntu One4# ubuntuone-client-applet - Tray icon applet for managing Ubuntu One
5#5#
6# Author: Rodney Dawes <rodney.dawes@canonical.com>6# Authors: Rodney Dawes <rodney.dawes@canonical.com>
7# Rodrigo Moya <rodrigo.moya@canonical.com>
7#8#
8# Copyright 2009 Canonical Ltd.9# Copyright 2009-2010 Canonical Ltd.
9#10#
10# This program is free software: you can redistribute it and/or modify it11# This program is free software: you can redistribute it and/or modify it
11# under the terms of the GNU General Public License version 3, as published12# under the terms of the GNU General Public License version 3, as published
@@ -29,12 +30,11 @@
29import sys30import sys
30import time31import time
31import gettext32import gettext
32import gnomekeyring
33import subprocess33import subprocess
34from threading import Thread34from threading import Thread
35from oauth import oauth35from oauth import oauth
3636
37from ubuntu_sso import DBUS_IFACE_AUTH_NAME, DBUS_PATH_AUTH37from ubuntu_sso import DBUS_IFACE_AUTH_NAME, DBUS_IFACE_CRED_NAME, DBUS_CRED_PATH
38from ubuntuone import clientdefs38from ubuntuone import clientdefs
39from ubuntuone.syncdaemon.tools import SyncDaemonTool39from ubuntuone.syncdaemon.tools import SyncDaemonTool
40from ubuntuone.api.restclient import RestClient40from ubuntuone.api.restclient import RestClient
@@ -62,7 +62,7 @@
62try:62try:
63 from desktopcouch.replication_services import ubuntuone as dcouch63 from desktopcouch.replication_services import ubuntuone as dcouch
64except ImportError:64except ImportError:
65 logger.error(_("DesktopCouch replication API not found"))65 logger.error("DesktopCouch replication API not found")
6666
67DBusGMainLoop(set_as_default=True)67DBusGMainLoop(set_as_default=True)
6868
@@ -92,7 +92,8 @@
92BW_CHCK_ARGS = ['dpkg', '-l', BW_PKG_NAME]92BW_CHCK_ARGS = ['dpkg', '-l', BW_PKG_NAME]
9393
94# This is a global so we can avoid creating multiple instances in some cases94# This is a global so we can avoid creating multiple instances in some cases
95prefs_dialog = None95oauth_token = None
96oauth_consumer = None
9697
97def dbus_async(*args, **kwargs):98def dbus_async(*args, **kwargs):
98 """Simple handler to make dbus do stuff async."""99 """Simple handler to make dbus do stuff async."""
@@ -103,48 +104,31 @@
103 """Make a login request to the login handling daemon."""104 """Make a login request to the login handling daemon."""
104 try:105 try:
105 client = bus.get_object(DBUS_IFACE_AUTH_NAME,106 client = bus.get_object(DBUS_IFACE_AUTH_NAME,
106 DBUS_PATH_AUTH,107 DBUS_CRED_PATH,
107 follow_name_owner_changes=True)108 follow_name_owner_changes=True)
108 iface = dbus.Interface(client, DBUS_IFACE_AUTH_NAME)109 iface = dbus.Interface(client, DBUS_IFACE_CRED_NAME)
109 iface.login('https://ubuntuone.com', 'ubuntuone',110 iface.login_or_register_to_get_credentials(
110 reply_handler=dbus_async,111 clientdefs.APP_NAME,
111 error_handler=error_handler)112 clientdefs.TC_URL,
113 clientdefs.DESCRIPTION,
114 0,
115 reply_handler=dbus_async,
116 error_handler=error_handler)
112 except DBusException, e:117 except DBusException, e:
113 error_handler(e)118 error_handler(e)
114119
115def get_access_token(keyring):120def do_rest_request(rest_client, url, method, callback):
116 """Get the access token from the keyring."""121 """Helper that handles the REST request."""
117 items = []122 result = rest_client.call(url, method, oauth_consumer, oauth_token)
118 try:
119 items = keyring.find_items_sync(
120 keyring.ITEM_GENERIC_SECRET,
121 {'ubuntuone-realm': "https://ubuntuone.com",
122 'oauth-consumer-key': 'ubuntuone'})
123 secret = items[0].secret
124 return oauth.OAuthToken.from_string(secret)
125 except (gnomekeyring.NoMatchError, gnomekeyring.DeniedError):
126 return None
127
128def do_rest_request(rest_client, url, method, token, callback):
129 """
130 Helper that handles the REST response.
131 """
132 consumer = oauth.OAuthConsumer('ubuntuone', 'hammertime')
133 result = rest_client.call(url, method, consumer, token)
134123
135 gtk.gdk.threads_enter()124 gtk.gdk.threads_enter()
136 callback(result)125 callback(result)
137 gtk.gdk.threads_leave()126 gtk.gdk.threads_leave()
138127
139def make_rest_request(url=None, method='GET',128def make_rest_request(url=None, method='GET', callback=None):
140 callback=None, keyring=None):129 """Helper that makes an oauth-wrapped REST request."""
141 """
142 Helper that makes an oauth-wrapped REST request.
143 """
144 token = get_access_token(keyring)
145
146 rest_client = RestClient(url)130 rest_client = RestClient(url)
147 Thread(target=do_rest_request, args=(rest_client, url, method, token, callback)).start()131 Thread(target=do_rest_request, args=(rest_client, url, method, callback)).start()
148132
149class DevicesWidget(gtk.Table):133class DevicesWidget(gtk.Table):
150 """134 """
@@ -152,20 +136,14 @@
152 """136 """
153 def __init__(self,137 def __init__(self,
154 bus,138 bus,
155 keyring=gnomekeyring,
156 realm='https://ubuntuone.com',
157 consumer_key='ubuntuone',
158 url='https://one.ubuntu.com/api/1.0/devices/'):139 url='https://one.ubuntu.com/api/1.0/devices/'):
159 super(DevicesWidget, self).__init__(rows=2, columns=3)140 super(DevicesWidget, self).__init__(rows=2, columns=3)
160 self.bus = bus141 self.bus = bus
161 self.keyring = keyring
162 self.sdtool = SyncDaemonTool(bus)142 self.sdtool = SyncDaemonTool(bus)
163 self.set_border_width(6)143 self.set_border_width(6)
164 self.set_row_spacings(6)144 self.set_row_spacings(6)
165 self.set_col_spacings(6)145 self.set_col_spacings(6)
166 self.devices = None146 self.devices = None
167 self.realm = realm
168 self.consumer_key = consumer_key
169 self.base_url = url147 self.base_url = url
170 self.conn = None148 self.conn = None
171 self.consumer = None149 self.consumer = None
@@ -301,14 +279,7 @@
301279
302 Hook up parse_devices to run on the result (when it gets here).280 Hook up parse_devices to run on the result (when it gets here).
303 """281 """
304 try:282 make_rest_request(url=self.base_url, callback=self.parse_devices)
305 get_access_token(self.keyring)
306 except gnomekeyring.NoMatchError:
307 self.error("No token in the keyring")
308 self.devices = None
309 else:
310 make_rest_request(url=self.base_url, keyring=self.keyring,
311 callback=self.parse_devices)
312283
313 def parse_devices(self, result):284 def parse_devices(self, result):
314 """285 """
@@ -356,8 +327,6 @@
356 """327 """
357 self.clear_devices_view()328 self.clear_devices_view()
358329
359 token = get_access_token(self.keyring)
360
361 fsync_enabled = self.sdtool.is_files_sync_enabled()330 fsync_enabled = self.sdtool.is_files_sync_enabled()
362331
363 if not self.devices:332 if not self.devices:
@@ -365,7 +334,7 @@
365 # a stopgap device so you can at least try to connect334 # a stopgap device so you can at least try to connect
366 self.devices = [{'kind': 'Computer',335 self.devices = [{'kind': 'Computer',
367 'description': _("<LOCAL MACHINE>"),336 'description': _("<LOCAL MACHINE>"),
368 'token': token.key if token else '',337 'token': oauth_token.key if oauth_token else '',
369 'FAKE': 'YES'}]338 'FAKE': 'YES'}]
370 else:339 else:
371 self.resize(len(self.devices)+1, 3)340 self.resize(len(self.devices)+1, 3)
@@ -387,7 +356,7 @@
387 butn.connect('clicked', self.remove,356 butn.connect('clicked', self.remove,
388 row['kind'], row.get('token'))357 row['kind'], row.get('token'))
389 self.attach(butn, 2, 3, i, i+1, xoptions=0, yoptions=0)358 self.attach(butn, 2, 3, i, i+1, xoptions=0, yoptions=0)
390 if ((token and row.get('token') == token.key or 'FAKE' in row)359 if ((oauth_token and row.get('token') == oauth_token.key or 'FAKE' in row)
391 and fsync_enabled):360 and fsync_enabled):
392 self.bw_chk = ck_btn = gtk.CheckButton(361 self.bw_chk = ck_btn = gtk.CheckButton(
393 _("_Limit Bandwidth Usage"))362 _("_Limit Bandwidth Usage"))
@@ -463,20 +432,18 @@
463 """432 """
464 make_rest_request(url=('%sremove/%s/%s' % (self.base_url,433 make_rest_request(url=('%sremove/%s/%s' % (self.base_url,
465 kind.lower(), token)),434 kind.lower(), token)),
466 keyring=self.keyring,
467 callback=self.parse_devices)435 callback=self.parse_devices)
468 local = get_access_token(self.keyring)
469 def local_removal_cb(*args, **kwargs):436 def local_removal_cb(*args, **kwargs):
470 """Try to get a new token if we remove the local one."""437 """Try to get a new token if we remove the local one."""
471 do_login_request(self.bus, self.error)438 do_login_request(self.bus, self.error)
472439
473 if token == local.key:440 if token == oauth_token.key:
474 try:441 try:
475 client = self.bus.get_object(DBUS_IFACE_AUTH_NAME,442 client = self.bus.get_object(DBUS_IFACE_CRED_NAME,
476 DBUS_PATH_AUTH,443 DBUS_CRED_PATH,
477 follow_name_owner_changes=True)444 follow_name_owner_changes=True)
478 iface = dbus.Interface(client, DBUS_IFACE_AUTH_NAME)445 iface = dbus.Interface(client, DBUS_IFACE_CRED_NAME)
479 iface.clear_token('https://ubuntuone.com', 'ubuntuone',446 iface.clear_token('ubuntuone',
480 reply_handler=local_removal_cb,447 reply_handler=local_removal_cb,
481 error_handler=self.error)448 error_handler=self.error)
482 except DBusException, e:449 except DBusException, e:
@@ -486,7 +453,7 @@
486class UbuntuOneDialog(gtk.Dialog):453class UbuntuOneDialog(gtk.Dialog):
487 """Preferences dialog."""454 """Preferences dialog."""
488455
489 def __init__(self, config=None, keyring=gnomekeyring, *args, **kw):456 def __init__(self, config=None, *args, **kw):
490 """Initializes our config dialog."""457 """Initializes our config dialog."""
491 super(UbuntuOneDialog, self).__init__(*args, **kw)458 super(UbuntuOneDialog, self).__init__(*args, **kw)
492 self.set_title(_("Ubuntu One Preferences"))459 self.set_title(_("Ubuntu One Preferences"))
@@ -506,7 +473,6 @@
506 self.ums_id = None473 self.ums_id = None
507474
508 self.__bus = dbus.SessionBus()475 self.__bus = dbus.SessionBus()
509 self.keyring = keyring
510476
511 # Timeout ID to avoid spamming DBus from spinbutton changes477 # Timeout ID to avoid spamming DBus from spinbutton changes
512 self.__update_id = 0478 self.__update_id = 0
@@ -663,7 +629,6 @@
663 def request_quota_info(self):629 def request_quota_info(self):
664 """Request new quota info from server, and update display."""630 """Request new quota info from server, and update display."""
665 make_rest_request(url='https://one.ubuntu.com/api/quota/',631 make_rest_request(url='https://one.ubuntu.com/api/quota/',
666 keyring=self.keyring,
667 callback=self.got_quota_info)632 callback=self.got_quota_info)
668633
669 def got_account_info(self, user):634 def got_account_info(self, user):
@@ -675,7 +640,6 @@
675 def request_account_info(self):640 def request_account_info(self):
676 """Request account info from server, and update display."""641 """Request account info from server, and update display."""
677 make_rest_request(url='https://one.ubuntu.com/api/account/',642 make_rest_request(url='https://one.ubuntu.com/api/account/',
678 keyring=self.keyring,
679 callback=self.got_account_info)643 callback=self.got_account_info)
680644
681 def __bw_inst_cb(self, button):645 def __bw_inst_cb(self, button):
@@ -950,7 +914,7 @@
950 self.notebook.append_page(sw)914 self.notebook.append_page(sw)
951 self.notebook.set_tab_label_text(sw, _("Devices"))915 self.notebook.set_tab_label_text(sw, _("Devices"))
952 sw.show()916 sw.show()
953 self.devices = DevicesWidget(self.__bus, self.keyring)917 self.devices = DevicesWidget(self.__bus)
954 sw.add_with_viewport(self.devices)918 sw.add_with_viewport(self.devices)
955 self.devices.list_devices()919 self.devices.list_devices()
956 self.devices.show_all()920 self.devices.show_all()
@@ -1036,7 +1000,6 @@
1036 def __init__(self, dialog, *args, **kw):1000 def __init__(self, dialog, *args, **kw):
1037 self.bus = dbus.SessionBus()1001 self.bus = dbus.SessionBus()
10381002
1039 # The actual UI
1040 self.dialog = dialog1003 self.dialog = dialog
10411004
1042 # DBus object magic1005 # DBus object magic
@@ -1059,20 +1022,28 @@
1059 if self.dialog.get_property('visible'):1022 if self.dialog.get_property('visible'):
1060 self.dialog.present_with_time(int(time.time()))1023 self.dialog.present_with_time(int(time.time()))
10611024
1062 def got_newcredentials(self, realm, consumer_key):1025 def got_newcredentials(self, app_name, credentials):
1063 """Show our dialog, since we can do stuff now."""1026 """Show our dialog, since we can do stuff now."""
1064 self.present()1027 global oauth_consumer
10651028 global oauth_token
1066 def got_oautherror(self, message=None):1029
1067 """Got an error during oauth."""1030 if app_name == clientdefs.APP_NAME:
1031 oauth_consumer = oauth.OAuthConsumer(credentials['consumer_key'],
1032 credentials['consumer_secret'])
1033 oauth_token = oauth.OAuthToken(credentials['token'],
1034 credentials['token_secret'])
1035 self.present()
1036
1037 def got_credentialserror(self, message=None):
1038 """Got an error during authentication."""
1068 if message:1039 if message:
1069 logger.error(message)1040 logger.error(message)
1070 else:1041 else:
1071 logger.error(_("OAuthError with no message."))1042 logger.error("CredentialsError with no message.")
10721043
1073 def got_authdenied(self):1044 def got_authdenied(self):
1074 """User denied access."""1045 """User denied access."""
1075 logger.error(_("Authorization was denied."))1046 logger.error("Authorization was denied.")
10761047
1077 def got_dbus_error(self, error):1048 def got_dbus_error(self, error):
1078 """Got a DBusError."""1049 """Got a DBusError."""
@@ -1082,16 +1053,16 @@
1082 """Register the dbus signal handlers."""1053 """Register the dbus signal handlers."""
1083 self.bus.add_signal_receiver(1054 self.bus.add_signal_receiver(
1084 handler_function=self.got_newcredentials,1055 handler_function=self.got_newcredentials,
1085 signal_name='NewCredentials',1056 signal_name='CredentialsFound',
1086 dbus_interface=DBUS_IFACE_AUTH_NAME)1057 dbus_interface=DBUS_IFACE_CRED_NAME)
1087 self.bus.add_signal_receiver(1058 self.bus.add_signal_receiver(
1088 handler_function=self.got_oautherror,1059 handler_function=self.got_credentialserror,
1089 signal_name='OAuthError',1060 signal_name='CredentialsError',
1090 dbus_interface=DBUS_IFACE_AUTH_NAME)1061 dbus_interface=DBUS_IFACE_CRED_NAME)
1091 self.bus.add_signal_receiver(1062 self.bus.add_signal_receiver(
1092 handler_function=self.got_authdenied,1063 handler_function=self.got_authdenied,
1093 signal_name='AuthorizationDenied',1064 signal_name='AuthorizationDenied',
1094 dbus_interface=DBUS_IFACE_AUTH_NAME)1065 dbus_interface=DBUS_IFACE_CRED_NAME)
10951066
10961067
1097if __name__ == "__main__":1068if __name__ == "__main__":
@@ -1120,6 +1091,7 @@
1120 try:1091 try:
1121 # The prefs dialog1092 # The prefs dialog
1122 gtk.gdk.threads_enter()1093 gtk.gdk.threads_enter()
1094
1123 prefs_dialog = UbuntuOneDialog()1095 prefs_dialog = UbuntuOneDialog()
1124 prefs_dialog.show()1096 prefs_dialog.show()
11251097
11261098
=== modified file 'tests/test_preferences.py'
--- tests/test_preferences.py 2010-08-16 14:00:13 +0000
+++ tests/test_preferences.py 2010-08-24 21:19:41 +0000
@@ -20,7 +20,6 @@
20import new20import new
21import os21import os
2222
23import gnomekeyring
24import ubuntu_sso23import ubuntu_sso
2524
26from contrib.mocker import MockerTestCase25from contrib.mocker import MockerTestCase
@@ -71,31 +70,6 @@
71 self._old_path = ubuntu_sso.DBUS_PATH_AUTH70 self._old_path = ubuntu_sso.DBUS_PATH_AUTH
72 ubuntu_sso.DBUS_PATH_AUTH = '/oauthdesktop'71 ubuntu_sso.DBUS_PATH_AUTH = '/oauthdesktop'
7372
74 # For testing keyring queries
75 self.keyring = self.mocker.mock()
76 self.item = self.mocker.mock(gnomekeyring.Found)
77
78 self.item_id = 999
79
80 self.item.item_id
81 self.mocker.result(self.item_id)
82 self.mocker.count(0, None)
83
84 self.item.secret
85 self.mocker.result('oauth_token=access_key'
86 '&oauth_token_secret=access_secret')
87 self.mocker.count(0, None)
88
89 self.keyring.find_items_sync(
90 None,
91 {'ubuntuone-realm': 'https://ubuntuone.com',
92 'oauth-consumer-key': 'ubuntuone'})
93 self.mocker.count(0, None)
94 self.mocker.result([self.item])
95 self.keyring.ITEM_GENERIC_SECRET
96 self.mocker.count(0, None)
97 self.mocker.result(None)
98
99 self.u1prefs.make_rest_request = self.make_rest_request73 self.u1prefs.make_rest_request = self.make_rest_request
100 self.u1prefs.SyncDaemonTool = SyncDaemonTool74 self.u1prefs.SyncDaemonTool = SyncDaemonTool
10175
@@ -114,7 +88,7 @@
114 yield DBusTwistedTestCase.tearDown(self)88 yield DBusTwistedTestCase.tearDown(self)
11589
116 def make_rest_request(self, url=None, method='GET',90 def make_rest_request(self, url=None, method='GET',
117 callback=None, keyring=None):91 callback=None):
118 """Override the real request call to mock some stuff."""92 """Override the real request call to mock some stuff."""
119 if callback:93 if callback:
120 callback(self.content)94 callback(self.content)
@@ -124,7 +98,7 @@
124 def test_bw_throttling(self):98 def test_bw_throttling(self):
125 """Test that toggling bw throttling works correctly."""99 """Test that toggling bw throttling works correctly."""
126 self.mocker.replay()100 self.mocker.replay()
127 widget = self.u1prefs.DevicesWidget(None, keyring=self.keyring)101 widget = self.u1prefs.DevicesWidget(None)
128 self.assertFalse(widget.got_limits)102 self.assertFalse(widget.got_limits)
129 widget.update_bw_settings = self.mocker.mock()103 widget.update_bw_settings = self.mocker.mock()
130 try:104 try:
@@ -160,7 +134,7 @@
160134
161 def test_list_devices_fills_devices_list_with_fake_result_when_empty(self):135 def test_list_devices_fills_devices_list_with_fake_result_when_empty(self):
162 self.mocker.replay()136 self.mocker.replay()
163 widget = self.u1prefs.DevicesWidget(None, keyring=self.keyring)137 widget = self.u1prefs.DevicesWidget(None)
164 widget.update_bw_settings = self.mocker.mock()138 widget.update_bw_settings = self.mocker.mock()
165 try:139 try:
166 widget.devices = []140 widget.devices = []
@@ -174,7 +148,7 @@
174148
175 def test_list_devices_shows_devices_list(self):149 def test_list_devices_shows_devices_list(self):
176 self.mocker.replay()150 self.mocker.replay()
177 widget = self.u1prefs.DevicesWidget(None, keyring=self.keyring)151 widget = self.u1prefs.DevicesWidget(None)
178 widget.update_bw_settings = self.mocker.mock()152 widget.update_bw_settings = self.mocker.mock()
179 try:153 try:
180 widget.devices = []154 widget.devices = []
@@ -205,7 +179,7 @@
205179
206 def test_list_devices_shows_real_devices_list(self):180 def test_list_devices_shows_real_devices_list(self):
207 self.mocker.replay()181 self.mocker.replay()
208 widget = self.u1prefs.DevicesWidget(None, keyring=self.keyring)182 widget = self.u1prefs.DevicesWidget(None)
209 widget.update_bw_settings = self.mocker.mock()183 widget.update_bw_settings = self.mocker.mock()
210 try:184 try:
211 widget.devices = [{'kind': 'Computer',185 widget.devices = [{'kind': 'Computer',
@@ -242,7 +216,7 @@
242 def test_quota_display(self):216 def test_quota_display(self):
243 """Test that quota display works correctly."""217 """Test that quota display works correctly."""
244 self.mocker.replay()218 self.mocker.replay()
245 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)219 dialog = self.u1prefs.UbuntuOneDialog()
246 self.assertTrue(dialog is not None)220 self.assertTrue(dialog is not None)
247 self.assertEqual(dialog.usage_graph.get_fraction(), 0.0)221 self.assertEqual(dialog.usage_graph.get_fraction(), 0.0)
248 dialog.update_quota_display(1024, 2048)222 dialog.update_quota_display(1024, 2048)
@@ -254,7 +228,7 @@
254 """Test that we can request the quota info properly."""228 """Test that we can request the quota info properly."""
255 self.content = {"total":2048, "used":1024}229 self.content = {"total":2048, "used":1024}
256 self.mocker.replay()230 self.mocker.replay()
257 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)231 dialog = self.u1prefs.UbuntuOneDialog()
258 self.assertTrue(dialog is not None)232 self.assertTrue(dialog is not None)
259 self.assertEqual(dialog.usage_graph.get_fraction(), 0.0)233 self.assertEqual(dialog.usage_graph.get_fraction(), 0.0)
260 dialog.request_quota_info()234 dialog.request_quota_info()
@@ -266,7 +240,7 @@
266 """Test that the quota notice is not visible if usage is low."""240 """Test that the quota notice is not visible if usage is low."""
267 self.content = {"total":2048, "used":1024}241 self.content = {"total":2048, "used":1024}
268 self.mocker.replay()242 self.mocker.replay()
269 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)243 dialog = self.u1prefs.UbuntuOneDialog()
270 self.assertTrue(dialog is not None)244 self.assertTrue(dialog is not None)
271 dialog.request_quota_info()245 dialog.request_quota_info()
272 # the label should just be the blank '\n'246 # the label should just be the blank '\n'
@@ -283,7 +257,7 @@
283 """257 """
284 self.content = {"total": 100, "used": 95}258 self.content = {"total": 100, "used": 95}
285 self.mocker.replay()259 self.mocker.replay()
286 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)260 dialog = self.u1prefs.UbuntuOneDialog()
287 self.assertTrue(dialog is not None)261 self.assertTrue(dialog is not None)
288 dialog.request_quota_info()262 dialog.request_quota_info()
289 # don't check the exact text, as it will probably263 # don't check the exact text, as it will probably
@@ -304,7 +278,7 @@
304 """278 """
305 self.content = {"total": 50<<30, "used": 49<<30}279 self.content = {"total": 50<<30, "used": 49<<30}
306 self.mocker.replay()280 self.mocker.replay()
307 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)281 dialog = self.u1prefs.UbuntuOneDialog()
308 self.assertTrue(dialog is not None)282 self.assertTrue(dialog is not None)
309 dialog.request_quota_info()283 dialog.request_quota_info()
310 # don't check the exact text, as it will probably284 # don't check the exact text, as it will probably
@@ -326,7 +300,7 @@
326 """300 """
327 self.content = {"total": 100, "used": 100}301 self.content = {"total": 100, "used": 100}
328 self.mocker.replay()302 self.mocker.replay()
329 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)303 dialog = self.u1prefs.UbuntuOneDialog()
330 self.assertTrue(dialog is not None)304 self.assertTrue(dialog is not None)
331 dialog.request_quota_info()305 dialog.request_quota_info()
332 # don't check the exact text, as it will probably306 # don't check the exact text, as it will probably
@@ -344,7 +318,7 @@
344 """Test that the quota notice is visible if usage is 100%."""318 """Test that the quota notice is visible if usage is 100%."""
345 self.content = {"total": 50<<30, "used": 50<<30}319 self.content = {"total": 50<<30, "used": 50<<30}
346 self.mocker.replay()320 self.mocker.replay()
347 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)321 dialog = self.u1prefs.UbuntuOneDialog()
348 self.assertTrue(dialog is not None)322 self.assertTrue(dialog is not None)
349 dialog.request_quota_info()323 dialog.request_quota_info()
350 # don't check the exact text, as it will probably324 # don't check the exact text, as it will probably
@@ -361,7 +335,7 @@
361 self.content = {"username": "ubuntuone", "nickname": "Ubuntu One",335 self.content = {"username": "ubuntuone", "nickname": "Ubuntu One",
362 "email": "uone@example.com"}336 "email": "uone@example.com"}
363 self.mocker.replay()337 self.mocker.replay()
364 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)338 dialog = self.u1prefs.UbuntuOneDialog()
365 self.assertTrue(dialog is not None)339 self.assertTrue(dialog is not None)
366 dialog.request_account_info()340 dialog.request_account_info()
367 self.content = {"total":2048, "used":1024}341 self.content = {"total":2048, "used":1024}
@@ -387,7 +361,7 @@
387 self.expect(toggle_db_sync('bookmarks', True))361 self.expect(toggle_db_sync('bookmarks', True))
388 self.expect(toggle_db_sync('bookmarks', False))362 self.expect(toggle_db_sync('bookmarks', False))
389 self.mocker.replay()363 self.mocker.replay()
390 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)364 dialog = self.u1prefs.UbuntuOneDialog()
391 self.assertTrue(dialog is not None)365 self.assertTrue(dialog is not None)
392 dialog.toggle_db_sync = toggle_db_sync366 dialog.toggle_db_sync = toggle_db_sync
393 dialog.bookmarks_check.set_active(True)367 dialog.bookmarks_check.set_active(True)
@@ -406,7 +380,7 @@
406 self.expect(toggle_db_sync('contacts', True))380 self.expect(toggle_db_sync('contacts', True))
407 self.expect(toggle_db_sync('contacts', False))381 self.expect(toggle_db_sync('contacts', False))
408 self.mocker.replay()382 self.mocker.replay()
409 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)383 dialog = self.u1prefs.UbuntuOneDialog()
410 self.assertTrue(dialog is not None)384 self.assertTrue(dialog is not None)
411 dialog.toggle_db_sync = toggle_db_sync385 dialog.toggle_db_sync = toggle_db_sync
412 dialog.abook_check.set_active(True)386 dialog.abook_check.set_active(True)
@@ -422,7 +396,7 @@
422 def test_toggle_files(self):396 def test_toggle_files(self):
423 """Test toggling the files service on/off."""397 """Test toggling the files service on/off."""
424 self.mocker.replay()398 self.mocker.replay()
425 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)399 dialog = self.u1prefs.UbuntuOneDialog()
426 self.assertTrue(dialog is not None)400 self.assertTrue(dialog is not None)
427 dialog.files_check.set_active(True)401 dialog.files_check.set_active(True)
428 self.assertTrue(dialog.files_check.get_active())402 self.assertTrue(dialog.files_check.get_active())
@@ -436,7 +410,7 @@
436 def test_toggle_files_and_music(self):410 def test_toggle_files_and_music(self):
437 """Test toggling the files and music services on/off."""411 """Test toggling the files and music services on/off."""
438 self.mocker.replay()412 self.mocker.replay()
439 dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring)413 dialog = self.u1prefs.UbuntuOneDialog()
440 self.assertTrue(dialog is not None)414 self.assertTrue(dialog is not None)
441 def files_toggled(checkbutton):415 def files_toggled(checkbutton):
442 enabled = checkbutton.get_active()416 enabled = checkbutton.get_active()

Subscribers

People subscribed via source and target branches