Merge lp:~rodrigo-moya/ubuntuone-client/use-sso-in-u1-prefs into lp:ubuntuone-client
- use-sso-in-u1-prefs
- Merge into trunk
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 |
Related bugs: |
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-
Description of the change
Make ubuntuone-
- 648. By Rodrigo Moya
-
Some fixes
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.
- 649. By Rodrigo Moya
-
Create the dialog only once
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?
Natalia Bidart (nataliabidart) wrote : | # |
The docstrings were not fixed (see lines 92-94 and 104-106)
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
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
Natalia Bidart (nataliabidart) wrote : | # |
Looks great now!
- 651. By Rodrigo Moya
-
Move instantiation of dialog back to its original place
dobey (dobey) : | # |
Preview Diff
1 | === modified file 'bin/ubuntuone-preferences' |
2 | --- bin/ubuntuone-preferences 2010-06-16 18:44:02 +0000 |
3 | +++ bin/ubuntuone-preferences 2010-08-24 21:19:41 +0000 |
4 | @@ -3,9 +3,10 @@ |
5 | |
6 | # ubuntuone-client-applet - Tray icon applet for managing Ubuntu One |
7 | # |
8 | -# Author: Rodney Dawes <rodney.dawes@canonical.com> |
9 | +# Authors: Rodney Dawes <rodney.dawes@canonical.com> |
10 | +# Rodrigo Moya <rodrigo.moya@canonical.com> |
11 | # |
12 | -# Copyright 2009 Canonical Ltd. |
13 | +# Copyright 2009-2010 Canonical Ltd. |
14 | # |
15 | # This program is free software: you can redistribute it and/or modify it |
16 | # under the terms of the GNU General Public License version 3, as published |
17 | @@ -29,12 +30,11 @@ |
18 | import sys |
19 | import time |
20 | import gettext |
21 | -import gnomekeyring |
22 | import subprocess |
23 | from threading import Thread |
24 | from oauth import oauth |
25 | |
26 | -from ubuntu_sso import DBUS_IFACE_AUTH_NAME, DBUS_PATH_AUTH |
27 | +from ubuntu_sso import DBUS_IFACE_AUTH_NAME, DBUS_IFACE_CRED_NAME, DBUS_CRED_PATH |
28 | from ubuntuone import clientdefs |
29 | from ubuntuone.syncdaemon.tools import SyncDaemonTool |
30 | from ubuntuone.api.restclient import RestClient |
31 | @@ -62,7 +62,7 @@ |
32 | try: |
33 | from desktopcouch.replication_services import ubuntuone as dcouch |
34 | except ImportError: |
35 | - logger.error(_("DesktopCouch replication API not found")) |
36 | + logger.error("DesktopCouch replication API not found") |
37 | |
38 | DBusGMainLoop(set_as_default=True) |
39 | |
40 | @@ -92,7 +92,8 @@ |
41 | BW_CHCK_ARGS = ['dpkg', '-l', BW_PKG_NAME] |
42 | |
43 | # This is a global so we can avoid creating multiple instances in some cases |
44 | -prefs_dialog = None |
45 | +oauth_token = None |
46 | +oauth_consumer = None |
47 | |
48 | def dbus_async(*args, **kwargs): |
49 | """Simple handler to make dbus do stuff async.""" |
50 | @@ -103,48 +104,31 @@ |
51 | """Make a login request to the login handling daemon.""" |
52 | try: |
53 | client = bus.get_object(DBUS_IFACE_AUTH_NAME, |
54 | - DBUS_PATH_AUTH, |
55 | + DBUS_CRED_PATH, |
56 | follow_name_owner_changes=True) |
57 | - iface = dbus.Interface(client, DBUS_IFACE_AUTH_NAME) |
58 | - iface.login('https://ubuntuone.com', 'ubuntuone', |
59 | - reply_handler=dbus_async, |
60 | - error_handler=error_handler) |
61 | + iface = dbus.Interface(client, DBUS_IFACE_CRED_NAME) |
62 | + iface.login_or_register_to_get_credentials( |
63 | + clientdefs.APP_NAME, |
64 | + clientdefs.TC_URL, |
65 | + clientdefs.DESCRIPTION, |
66 | + 0, |
67 | + reply_handler=dbus_async, |
68 | + error_handler=error_handler) |
69 | except DBusException, e: |
70 | error_handler(e) |
71 | |
72 | -def get_access_token(keyring): |
73 | - """Get the access token from the keyring.""" |
74 | - items = [] |
75 | - try: |
76 | - items = keyring.find_items_sync( |
77 | - keyring.ITEM_GENERIC_SECRET, |
78 | - {'ubuntuone-realm': "https://ubuntuone.com", |
79 | - 'oauth-consumer-key': 'ubuntuone'}) |
80 | - secret = items[0].secret |
81 | - return oauth.OAuthToken.from_string(secret) |
82 | - except (gnomekeyring.NoMatchError, gnomekeyring.DeniedError): |
83 | - return None |
84 | - |
85 | -def do_rest_request(rest_client, url, method, token, callback): |
86 | - """ |
87 | - Helper that handles the REST response. |
88 | - """ |
89 | - consumer = oauth.OAuthConsumer('ubuntuone', 'hammertime') |
90 | - result = rest_client.call(url, method, consumer, token) |
91 | +def do_rest_request(rest_client, url, method, callback): |
92 | + """Helper that handles the REST request.""" |
93 | + result = rest_client.call(url, method, oauth_consumer, oauth_token) |
94 | |
95 | gtk.gdk.threads_enter() |
96 | callback(result) |
97 | gtk.gdk.threads_leave() |
98 | |
99 | -def make_rest_request(url=None, method='GET', |
100 | - callback=None, keyring=None): |
101 | - """ |
102 | - Helper that makes an oauth-wrapped REST request. |
103 | - """ |
104 | - token = get_access_token(keyring) |
105 | - |
106 | +def make_rest_request(url=None, method='GET', callback=None): |
107 | + """Helper that makes an oauth-wrapped REST request.""" |
108 | rest_client = RestClient(url) |
109 | - Thread(target=do_rest_request, args=(rest_client, url, method, token, callback)).start() |
110 | + Thread(target=do_rest_request, args=(rest_client, url, method, callback)).start() |
111 | |
112 | class DevicesWidget(gtk.Table): |
113 | """ |
114 | @@ -152,20 +136,14 @@ |
115 | """ |
116 | def __init__(self, |
117 | bus, |
118 | - keyring=gnomekeyring, |
119 | - realm='https://ubuntuone.com', |
120 | - consumer_key='ubuntuone', |
121 | url='https://one.ubuntu.com/api/1.0/devices/'): |
122 | super(DevicesWidget, self).__init__(rows=2, columns=3) |
123 | self.bus = bus |
124 | - self.keyring = keyring |
125 | self.sdtool = SyncDaemonTool(bus) |
126 | self.set_border_width(6) |
127 | self.set_row_spacings(6) |
128 | self.set_col_spacings(6) |
129 | self.devices = None |
130 | - self.realm = realm |
131 | - self.consumer_key = consumer_key |
132 | self.base_url = url |
133 | self.conn = None |
134 | self.consumer = None |
135 | @@ -301,14 +279,7 @@ |
136 | |
137 | Hook up parse_devices to run on the result (when it gets here). |
138 | """ |
139 | - try: |
140 | - get_access_token(self.keyring) |
141 | - except gnomekeyring.NoMatchError: |
142 | - self.error("No token in the keyring") |
143 | - self.devices = None |
144 | - else: |
145 | - make_rest_request(url=self.base_url, keyring=self.keyring, |
146 | - callback=self.parse_devices) |
147 | + make_rest_request(url=self.base_url, callback=self.parse_devices) |
148 | |
149 | def parse_devices(self, result): |
150 | """ |
151 | @@ -356,8 +327,6 @@ |
152 | """ |
153 | self.clear_devices_view() |
154 | |
155 | - token = get_access_token(self.keyring) |
156 | - |
157 | fsync_enabled = self.sdtool.is_files_sync_enabled() |
158 | |
159 | if not self.devices: |
160 | @@ -365,7 +334,7 @@ |
161 | # a stopgap device so you can at least try to connect |
162 | self.devices = [{'kind': 'Computer', |
163 | 'description': _("<LOCAL MACHINE>"), |
164 | - 'token': token.key if token else '', |
165 | + 'token': oauth_token.key if oauth_token else '', |
166 | 'FAKE': 'YES'}] |
167 | else: |
168 | self.resize(len(self.devices)+1, 3) |
169 | @@ -387,7 +356,7 @@ |
170 | butn.connect('clicked', self.remove, |
171 | row['kind'], row.get('token')) |
172 | self.attach(butn, 2, 3, i, i+1, xoptions=0, yoptions=0) |
173 | - if ((token and row.get('token') == token.key or 'FAKE' in row) |
174 | + if ((oauth_token and row.get('token') == oauth_token.key or 'FAKE' in row) |
175 | and fsync_enabled): |
176 | self.bw_chk = ck_btn = gtk.CheckButton( |
177 | _("_Limit Bandwidth Usage")) |
178 | @@ -463,20 +432,18 @@ |
179 | """ |
180 | make_rest_request(url=('%sremove/%s/%s' % (self.base_url, |
181 | kind.lower(), token)), |
182 | - keyring=self.keyring, |
183 | callback=self.parse_devices) |
184 | - local = get_access_token(self.keyring) |
185 | def local_removal_cb(*args, **kwargs): |
186 | """Try to get a new token if we remove the local one.""" |
187 | do_login_request(self.bus, self.error) |
188 | |
189 | - if token == local.key: |
190 | + if token == oauth_token.key: |
191 | try: |
192 | - client = self.bus.get_object(DBUS_IFACE_AUTH_NAME, |
193 | - DBUS_PATH_AUTH, |
194 | + client = self.bus.get_object(DBUS_IFACE_CRED_NAME, |
195 | + DBUS_CRED_PATH, |
196 | follow_name_owner_changes=True) |
197 | - iface = dbus.Interface(client, DBUS_IFACE_AUTH_NAME) |
198 | - iface.clear_token('https://ubuntuone.com', 'ubuntuone', |
199 | + iface = dbus.Interface(client, DBUS_IFACE_CRED_NAME) |
200 | + iface.clear_token('ubuntuone', |
201 | reply_handler=local_removal_cb, |
202 | error_handler=self.error) |
203 | except DBusException, e: |
204 | @@ -486,7 +453,7 @@ |
205 | class UbuntuOneDialog(gtk.Dialog): |
206 | """Preferences dialog.""" |
207 | |
208 | - def __init__(self, config=None, keyring=gnomekeyring, *args, **kw): |
209 | + def __init__(self, config=None, *args, **kw): |
210 | """Initializes our config dialog.""" |
211 | super(UbuntuOneDialog, self).__init__(*args, **kw) |
212 | self.set_title(_("Ubuntu One Preferences")) |
213 | @@ -506,7 +473,6 @@ |
214 | self.ums_id = None |
215 | |
216 | self.__bus = dbus.SessionBus() |
217 | - self.keyring = keyring |
218 | |
219 | # Timeout ID to avoid spamming DBus from spinbutton changes |
220 | self.__update_id = 0 |
221 | @@ -663,7 +629,6 @@ |
222 | def request_quota_info(self): |
223 | """Request new quota info from server, and update display.""" |
224 | make_rest_request(url='https://one.ubuntu.com/api/quota/', |
225 | - keyring=self.keyring, |
226 | callback=self.got_quota_info) |
227 | |
228 | def got_account_info(self, user): |
229 | @@ -675,7 +640,6 @@ |
230 | def request_account_info(self): |
231 | """Request account info from server, and update display.""" |
232 | make_rest_request(url='https://one.ubuntu.com/api/account/', |
233 | - keyring=self.keyring, |
234 | callback=self.got_account_info) |
235 | |
236 | def __bw_inst_cb(self, button): |
237 | @@ -950,7 +914,7 @@ |
238 | self.notebook.append_page(sw) |
239 | self.notebook.set_tab_label_text(sw, _("Devices")) |
240 | sw.show() |
241 | - self.devices = DevicesWidget(self.__bus, self.keyring) |
242 | + self.devices = DevicesWidget(self.__bus) |
243 | sw.add_with_viewport(self.devices) |
244 | self.devices.list_devices() |
245 | self.devices.show_all() |
246 | @@ -1036,7 +1000,6 @@ |
247 | def __init__(self, dialog, *args, **kw): |
248 | self.bus = dbus.SessionBus() |
249 | |
250 | - # The actual UI |
251 | self.dialog = dialog |
252 | |
253 | # DBus object magic |
254 | @@ -1059,20 +1022,28 @@ |
255 | if self.dialog.get_property('visible'): |
256 | self.dialog.present_with_time(int(time.time())) |
257 | |
258 | - def got_newcredentials(self, realm, consumer_key): |
259 | + def got_newcredentials(self, app_name, credentials): |
260 | """Show our dialog, since we can do stuff now.""" |
261 | - self.present() |
262 | - |
263 | - def got_oautherror(self, message=None): |
264 | - """Got an error during oauth.""" |
265 | + global oauth_consumer |
266 | + global oauth_token |
267 | + |
268 | + if app_name == clientdefs.APP_NAME: |
269 | + oauth_consumer = oauth.OAuthConsumer(credentials['consumer_key'], |
270 | + credentials['consumer_secret']) |
271 | + oauth_token = oauth.OAuthToken(credentials['token'], |
272 | + credentials['token_secret']) |
273 | + self.present() |
274 | + |
275 | + def got_credentialserror(self, message=None): |
276 | + """Got an error during authentication.""" |
277 | if message: |
278 | logger.error(message) |
279 | else: |
280 | - logger.error(_("OAuthError with no message.")) |
281 | + logger.error("CredentialsError with no message.") |
282 | |
283 | def got_authdenied(self): |
284 | """User denied access.""" |
285 | - logger.error(_("Authorization was denied.")) |
286 | + logger.error("Authorization was denied.") |
287 | |
288 | def got_dbus_error(self, error): |
289 | """Got a DBusError.""" |
290 | @@ -1082,16 +1053,16 @@ |
291 | """Register the dbus signal handlers.""" |
292 | self.bus.add_signal_receiver( |
293 | handler_function=self.got_newcredentials, |
294 | - signal_name='NewCredentials', |
295 | - dbus_interface=DBUS_IFACE_AUTH_NAME) |
296 | + signal_name='CredentialsFound', |
297 | + dbus_interface=DBUS_IFACE_CRED_NAME) |
298 | self.bus.add_signal_receiver( |
299 | - handler_function=self.got_oautherror, |
300 | - signal_name='OAuthError', |
301 | - dbus_interface=DBUS_IFACE_AUTH_NAME) |
302 | + handler_function=self.got_credentialserror, |
303 | + signal_name='CredentialsError', |
304 | + dbus_interface=DBUS_IFACE_CRED_NAME) |
305 | self.bus.add_signal_receiver( |
306 | handler_function=self.got_authdenied, |
307 | signal_name='AuthorizationDenied', |
308 | - dbus_interface=DBUS_IFACE_AUTH_NAME) |
309 | + dbus_interface=DBUS_IFACE_CRED_NAME) |
310 | |
311 | |
312 | if __name__ == "__main__": |
313 | @@ -1120,6 +1091,7 @@ |
314 | try: |
315 | # The prefs dialog |
316 | gtk.gdk.threads_enter() |
317 | + |
318 | prefs_dialog = UbuntuOneDialog() |
319 | prefs_dialog.show() |
320 | |
321 | |
322 | === modified file 'tests/test_preferences.py' |
323 | --- tests/test_preferences.py 2010-08-16 14:00:13 +0000 |
324 | +++ tests/test_preferences.py 2010-08-24 21:19:41 +0000 |
325 | @@ -20,7 +20,6 @@ |
326 | import new |
327 | import os |
328 | |
329 | -import gnomekeyring |
330 | import ubuntu_sso |
331 | |
332 | from contrib.mocker import MockerTestCase |
333 | @@ -71,31 +70,6 @@ |
334 | self._old_path = ubuntu_sso.DBUS_PATH_AUTH |
335 | ubuntu_sso.DBUS_PATH_AUTH = '/oauthdesktop' |
336 | |
337 | - # For testing keyring queries |
338 | - self.keyring = self.mocker.mock() |
339 | - self.item = self.mocker.mock(gnomekeyring.Found) |
340 | - |
341 | - self.item_id = 999 |
342 | - |
343 | - self.item.item_id |
344 | - self.mocker.result(self.item_id) |
345 | - self.mocker.count(0, None) |
346 | - |
347 | - self.item.secret |
348 | - self.mocker.result('oauth_token=access_key' |
349 | - '&oauth_token_secret=access_secret') |
350 | - self.mocker.count(0, None) |
351 | - |
352 | - self.keyring.find_items_sync( |
353 | - None, |
354 | - {'ubuntuone-realm': 'https://ubuntuone.com', |
355 | - 'oauth-consumer-key': 'ubuntuone'}) |
356 | - self.mocker.count(0, None) |
357 | - self.mocker.result([self.item]) |
358 | - self.keyring.ITEM_GENERIC_SECRET |
359 | - self.mocker.count(0, None) |
360 | - self.mocker.result(None) |
361 | - |
362 | self.u1prefs.make_rest_request = self.make_rest_request |
363 | self.u1prefs.SyncDaemonTool = SyncDaemonTool |
364 | |
365 | @@ -114,7 +88,7 @@ |
366 | yield DBusTwistedTestCase.tearDown(self) |
367 | |
368 | def make_rest_request(self, url=None, method='GET', |
369 | - callback=None, keyring=None): |
370 | + callback=None): |
371 | """Override the real request call to mock some stuff.""" |
372 | if callback: |
373 | callback(self.content) |
374 | @@ -124,7 +98,7 @@ |
375 | def test_bw_throttling(self): |
376 | """Test that toggling bw throttling works correctly.""" |
377 | self.mocker.replay() |
378 | - widget = self.u1prefs.DevicesWidget(None, keyring=self.keyring) |
379 | + widget = self.u1prefs.DevicesWidget(None) |
380 | self.assertFalse(widget.got_limits) |
381 | widget.update_bw_settings = self.mocker.mock() |
382 | try: |
383 | @@ -160,7 +134,7 @@ |
384 | |
385 | def test_list_devices_fills_devices_list_with_fake_result_when_empty(self): |
386 | self.mocker.replay() |
387 | - widget = self.u1prefs.DevicesWidget(None, keyring=self.keyring) |
388 | + widget = self.u1prefs.DevicesWidget(None) |
389 | widget.update_bw_settings = self.mocker.mock() |
390 | try: |
391 | widget.devices = [] |
392 | @@ -174,7 +148,7 @@ |
393 | |
394 | def test_list_devices_shows_devices_list(self): |
395 | self.mocker.replay() |
396 | - widget = self.u1prefs.DevicesWidget(None, keyring=self.keyring) |
397 | + widget = self.u1prefs.DevicesWidget(None) |
398 | widget.update_bw_settings = self.mocker.mock() |
399 | try: |
400 | widget.devices = [] |
401 | @@ -205,7 +179,7 @@ |
402 | |
403 | def test_list_devices_shows_real_devices_list(self): |
404 | self.mocker.replay() |
405 | - widget = self.u1prefs.DevicesWidget(None, keyring=self.keyring) |
406 | + widget = self.u1prefs.DevicesWidget(None) |
407 | widget.update_bw_settings = self.mocker.mock() |
408 | try: |
409 | widget.devices = [{'kind': 'Computer', |
410 | @@ -242,7 +216,7 @@ |
411 | def test_quota_display(self): |
412 | """Test that quota display works correctly.""" |
413 | self.mocker.replay() |
414 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
415 | + dialog = self.u1prefs.UbuntuOneDialog() |
416 | self.assertTrue(dialog is not None) |
417 | self.assertEqual(dialog.usage_graph.get_fraction(), 0.0) |
418 | dialog.update_quota_display(1024, 2048) |
419 | @@ -254,7 +228,7 @@ |
420 | """Test that we can request the quota info properly.""" |
421 | self.content = {"total":2048, "used":1024} |
422 | self.mocker.replay() |
423 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
424 | + dialog = self.u1prefs.UbuntuOneDialog() |
425 | self.assertTrue(dialog is not None) |
426 | self.assertEqual(dialog.usage_graph.get_fraction(), 0.0) |
427 | dialog.request_quota_info() |
428 | @@ -266,7 +240,7 @@ |
429 | """Test that the quota notice is not visible if usage is low.""" |
430 | self.content = {"total":2048, "used":1024} |
431 | self.mocker.replay() |
432 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
433 | + dialog = self.u1prefs.UbuntuOneDialog() |
434 | self.assertTrue(dialog is not None) |
435 | dialog.request_quota_info() |
436 | # the label should just be the blank '\n' |
437 | @@ -283,7 +257,7 @@ |
438 | """ |
439 | self.content = {"total": 100, "used": 95} |
440 | self.mocker.replay() |
441 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
442 | + dialog = self.u1prefs.UbuntuOneDialog() |
443 | self.assertTrue(dialog is not None) |
444 | dialog.request_quota_info() |
445 | # don't check the exact text, as it will probably |
446 | @@ -304,7 +278,7 @@ |
447 | """ |
448 | self.content = {"total": 50<<30, "used": 49<<30} |
449 | self.mocker.replay() |
450 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
451 | + dialog = self.u1prefs.UbuntuOneDialog() |
452 | self.assertTrue(dialog is not None) |
453 | dialog.request_quota_info() |
454 | # don't check the exact text, as it will probably |
455 | @@ -326,7 +300,7 @@ |
456 | """ |
457 | self.content = {"total": 100, "used": 100} |
458 | self.mocker.replay() |
459 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
460 | + dialog = self.u1prefs.UbuntuOneDialog() |
461 | self.assertTrue(dialog is not None) |
462 | dialog.request_quota_info() |
463 | # don't check the exact text, as it will probably |
464 | @@ -344,7 +318,7 @@ |
465 | """Test that the quota notice is visible if usage is 100%.""" |
466 | self.content = {"total": 50<<30, "used": 50<<30} |
467 | self.mocker.replay() |
468 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
469 | + dialog = self.u1prefs.UbuntuOneDialog() |
470 | self.assertTrue(dialog is not None) |
471 | dialog.request_quota_info() |
472 | # don't check the exact text, as it will probably |
473 | @@ -361,7 +335,7 @@ |
474 | self.content = {"username": "ubuntuone", "nickname": "Ubuntu One", |
475 | "email": "uone@example.com"} |
476 | self.mocker.replay() |
477 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
478 | + dialog = self.u1prefs.UbuntuOneDialog() |
479 | self.assertTrue(dialog is not None) |
480 | dialog.request_account_info() |
481 | self.content = {"total":2048, "used":1024} |
482 | @@ -387,7 +361,7 @@ |
483 | self.expect(toggle_db_sync('bookmarks', True)) |
484 | self.expect(toggle_db_sync('bookmarks', False)) |
485 | self.mocker.replay() |
486 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
487 | + dialog = self.u1prefs.UbuntuOneDialog() |
488 | self.assertTrue(dialog is not None) |
489 | dialog.toggle_db_sync = toggle_db_sync |
490 | dialog.bookmarks_check.set_active(True) |
491 | @@ -406,7 +380,7 @@ |
492 | self.expect(toggle_db_sync('contacts', True)) |
493 | self.expect(toggle_db_sync('contacts', False)) |
494 | self.mocker.replay() |
495 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
496 | + dialog = self.u1prefs.UbuntuOneDialog() |
497 | self.assertTrue(dialog is not None) |
498 | dialog.toggle_db_sync = toggle_db_sync |
499 | dialog.abook_check.set_active(True) |
500 | @@ -422,7 +396,7 @@ |
501 | def test_toggle_files(self): |
502 | """Test toggling the files service on/off.""" |
503 | self.mocker.replay() |
504 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
505 | + dialog = self.u1prefs.UbuntuOneDialog() |
506 | self.assertTrue(dialog is not None) |
507 | dialog.files_check.set_active(True) |
508 | self.assertTrue(dialog.files_check.get_active()) |
509 | @@ -436,7 +410,7 @@ |
510 | def test_toggle_files_and_music(self): |
511 | """Test toggling the files and music services on/off.""" |
512 | self.mocker.replay() |
513 | - dialog = self.u1prefs.UbuntuOneDialog(keyring=self.keyring) |
514 | + dialog = self.u1prefs.UbuntuOneDialog() |
515 | self.assertTrue(dialog is not None) |
516 | def files_toggled(checkbutton): |
517 | enabled = checkbutton.get_active() |
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.