Merge lp:~nataliabidart/ubuntuone-control-panel/folders-if-new-creds into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 36
Merged at revision: 34
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/folders-if-new-creds
Merge into: lp:ubuntuone-control-panel
Prerequisite: lp:~nataliabidart/ubuntuone-control-panel/subscribe
Diff against target: 215 lines (+84/-14)
2 files modified
ubuntuone/controlpanel/gtk/gui.py (+20/-8)
ubuntuone/controlpanel/gtk/tests/test_gui.py (+64/-6)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/folders-if-new-creds
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Roman Yepishev (community) fieldtest Approve
Review via email: mp+43699@code.launchpad.net

Commit message

* After machine was added, Folders page is shown (LP: #674459).* VolumesInfoError signal is now handled (LP: #690292).

* VolumesInfoError signal is now handled (LP: #690292).

* When FileSyncStatusError is received, no more DbusException messages are leaked to the end user (LP: #690305).

Description of the change

To run the tests, use the command:

./run-tests

To test, open 2 terminals pointing to this branch.
You should remove your Ubuntu One token from seahorse to ensure following the expected workflow.

In terminal 1:

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

In terminal 2:

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

You'll see the "overview" screen (just like https://bugs.launchpad.net/ubuntuone-control-panel/+bug/690315/+attachment/1766070/+files/u1cp-overview.png).

Login (or register, as you prefer) and you should be taken directly to the "Folders" tab.
If you close the GTK UI and re open, you'll see the Account page.

To post a comment you must log in.
36. By Natalia Bidart

Binding bug nhumbers.

Revision history for this message
Roman Yepishev (rye) wrote :

Folders tab showing after authorization, account tab showing on subsequent startups: OK
Volume list errors: http://ubuntuone.com/p/U17/: OK
File status retrieval error: http://ubuntuone.com/p/U1G/: OK

review: Approve (fieldtest)
Revision history for this message
Roberto Alsina (ralsina) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
--- ubuntuone/controlpanel/gtk/gui.py 2010-12-14 20:41:48 +0000
+++ ubuntuone/controlpanel/gtk/gui.py 2010-12-14 20:41:48 +0000
@@ -176,17 +176,25 @@
176 ControlPanelMixin.__init__(self, filename='controlpanel.ui')176 ControlPanelMixin.__init__(self, filename='controlpanel.ui')
177 self._window_id = window_id177 self._window_id = window_id
178178
179 self.management = None
179 self.overview = OverviewPanel(window_id=window_id)180 self.overview = OverviewPanel(window_id=window_id)
180 self.overview.connect('credentials-found',181 self.overview.connect('credentials-found',
181 self.on_show_management_panel)182 self.on_show_management_panel)
182 self.add(self.overview)183 self.add(self.overview)
183 self.show()184 self.show()
184185
185 def on_show_management_panel(self, *args, **kwargs):186 def on_show_management_panel(self, widget=None,
187 credentials_are_new=False, token=None):
186 """Show the netbook (main panel)."""188 """Show the netbook (main panel)."""
187 if self.overview in self.get_children():189 if self.overview in self.get_children():
188 self.remove(self.overview)190 self.remove(self.overview)
189 self.add(ManagementPanel())191
192 self.management = ManagementPanel()
193 if credentials_are_new:
194 # redirect user to Folders page to review folders subscription
195 self.management.folders_button.clicked()
196
197 self.add(self.management)
190198
191199
192class UbuntuOneBin(gtk.VBox):200class UbuntuOneBin(gtk.VBox):
@@ -228,6 +236,7 @@
228 self.warning_label.set_property('xalign', 0.5)236 self.warning_label.set_property('xalign', 0.5)
229 self.warning_label.connect('size-allocate', self.on_size_allocate)237 self.warning_label.connect('size-allocate', self.on_size_allocate)
230238
239 self._credentials_are_new = False
231 self._messages = messages240 self._messages = messages
232 self._window_id = window_id241 self._window_id = window_id
233 self._build_messages()242 self._build_messages()
@@ -318,13 +327,14 @@
318 @log_call(logger.info)327 @log_call(logger.info)
319 def on_credentials_found(self, app_name, credentials):328 def on_credentials_found(self, app_name, credentials):
320 """SSO backend notifies of credentials found."""329 """SSO backend notifies of credentials found."""
321 self.emit('credentials-found', app_name, credentials)330 self.emit('credentials-found', self._credentials_are_new, credentials)
322 self.hide()331 self.hide()
323332
324 @filter_by_app_name333 @filter_by_app_name
325 @log_call(logger.info)334 @log_call(logger.info)
326 def on_credentials_not_found(self, app_name):335 def on_credentials_not_found(self, app_name):
327 """SSO backend notifies of credentials not found."""336 """SSO backend notifies of credentials not found."""
337 self._credentials_are_new = True
328 self.set_property('greyed', False)338 self.set_property('greyed', False)
329339
330 @filter_by_app_name340 @filter_by_app_name
@@ -434,6 +444,7 @@
434444
435 if not info:445 if not info:
436 self.volumes_label.set_markup(self.NO_VOLUMES)446 self.volumes_label.set_markup(self.NO_VOLUMES)
447 self.label_alignment.show()
437 return448 return
438 else:449 else:
439 self.label_alignment.hide()450 self.label_alignment.hide()
@@ -467,6 +478,9 @@
467 @log_call(logger.error)478 @log_call(logger.error)
468 def on_volumes_info_error(self, error_dict=None):479 def on_volumes_info_error(self, error_dict=None):
469 """Backend notifies of an error when fetching volumes info."""480 """Backend notifies of an error when fetching volumes info."""
481 self.volumes_label.stop()
482 self._set_warning(self.VALUE_ERROR, self.volumes_label)
483 self.label_alignment.show()
470484
471 def on_subscribed_clicked(self, checkbutton):485 def on_subscribed_clicked(self, checkbutton):
472 """The user toggled 'checkbutton'."""486 """The user toggled 'checkbutton'."""
@@ -576,6 +590,7 @@
576590
577 self.backend.account_info()591 self.backend.account_info()
578 self.backend.file_sync_status()592 self.backend.file_sync_status()
593 self.account_button.clicked()
579594
580 def _update_quota(self, msg, data=None):595 def _update_quota(self, msg, data=None):
581 """Update the quota info."""596 """Update the quota info."""
@@ -634,12 +649,9 @@
634 @log_call(logger.error)649 @log_call(logger.error)
635 def on_file_sync_status_error(self, error_dict=None):650 def on_file_sync_status_error(self, error_dict=None):
636 """Backend notifies of an error when fetching file sync status."""651 """Backend notifies of an error when fetching file sync status."""
637 msg = error_dict.get('error_msg', None)652 self._update_status(WARNING_MARKUP % self.FILE_SYNC_ERROR)
638 if msg is None:
639 msg = error_dict.get('message', self.VALUE_ERROR)
640 self._update_status(WARNING_MARKUP % msg)
641653
642654
643gobject.signal_new('credentials-found', OverviewPanel,655gobject.signal_new('credentials-found', OverviewPanel,
644 gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,656 gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
645 (gobject.TYPE_STRING, gobject.TYPE_PYOBJECT))657 (gobject.TYPE_BOOLEAN, gobject.TYPE_PYOBJECT))
646658
=== modified file 'ubuntuone/controlpanel/gtk/tests/test_gui.py'
--- ubuntuone/controlpanel/gtk/tests/test_gui.py 2010-12-14 20:41:48 +0000
+++ ubuntuone/controlpanel/gtk/tests/test_gui.py 2010-12-14 20:41:48 +0000
@@ -309,6 +309,34 @@
309309
310 self.assertEqual(1, len(self.ui.get_children()))310 self.assertEqual(1, len(self.ui.get_children()))
311311
312 def test_credentials_found_shows_account_management_panel(self):
313 """On 'credentials-found' signal, the management panel is shown.
314
315 If first signal parameter is False, visible tab should be account.
316
317 """
318 a_token = object()
319 self.ui.overview.emit('credentials-found', False, a_token)
320
321 children = self.ui.get_children()
322 self.assertIsInstance(children[-1], gui.ManagementPanel)
323 self.assertEqual(self.ui.management.notebook.get_current_page(),
324 self.ui.management.ACCOUNT_PAGE)
325
326 def test_credentials_found_shows_folders_management_panel(self):
327 """On 'credentials-found' signal, the management panel is shown.
328
329 If first signal parameter is True, visible tab should be folders.
330
331 """
332 a_token = object()
333 self.ui.overview.emit('credentials-found', True, a_token)
334
335 children = self.ui.get_children()
336 self.assertIsInstance(children[-1], gui.ManagementPanel)
337 self.assertEqual(self.ui.management.notebook.get_current_page(),
338 self.ui.management.FOLDERS_PAGE)
339
312340
313class UbuntuOneBinTestCase(BaseTestCase):341class UbuntuOneBinTestCase(BaseTestCase):
314 """The test suite for a Ubuntu One panel."""342 """The test suite for a Ubuntu One panel."""
@@ -425,6 +453,7 @@
425453
426 def test_find_credentials_is_called(self):454 def test_find_credentials_is_called(self):
427 """Credentials are asked to SSO backend."""455 """Credentials are asked to SSO backend."""
456 self.assertFalse(self.ui._credentials_are_new)
428 self.assert_backend_called('find_credentials', (gui.U1_APP_NAME, {}),457 self.assert_backend_called('find_credentials', (gui.U1_APP_NAME, {}),
429 backend=self.ui.sso_backend)458 backend=self.ui.sso_backend)
430459
@@ -435,12 +464,27 @@
435 self.ui.on_credentials_found(gui.U1_APP_NAME, TOKEN)464 self.ui.on_credentials_found(gui.U1_APP_NAME, TOKEN)
436465
437 self.assertFalse(self.ui.get_visible())466 self.assertFalse(self.ui.get_visible())
438 self.assertEqual(self._called, ((self.ui, gui.U1_APP_NAME, TOKEN), {}))467 # assume credentials were in local keyring
468 self.assertEqual(self._called, ((self.ui, False, TOKEN), {}))
469
470 def test_on_credentials_found_when_creds_are_not_new(self):
471 """Callback 'on_credentials_found' distinguish if creds are new."""
472 self.ui.connect('credentials-found', self._set_called)
473
474 # credentials weren't in the system
475 self.ui.on_credentials_not_found(gui.U1_APP_NAME)
476 # now they are!
477 self.ui.on_credentials_found(gui.U1_APP_NAME, TOKEN)
478
479 self.assertFalse(self.ui.get_visible())
480 # assume credentials were not in local keyring
481 self.assertEqual(self._called, ((self.ui, True, TOKEN), {}))
439482
440 def test_on_credentials_not_found(self):483 def test_on_credentials_not_found(self):
441 """Callback 'on_credentials_not_found' is correct."""484 """Callback 'on_credentials_not_found' is correct."""
442 self.ui.on_credentials_not_found(gui.U1_APP_NAME)485 self.ui.on_credentials_not_found(gui.U1_APP_NAME)
443 self.assertTrue(self.ui.get_visible())486 self.assertTrue(self.ui.get_visible())
487 self.assertTrue(self.ui._credentials_are_new)
444488
445 def test_on_credentials_error(self):489 def test_on_credentials_error(self):
446 """Callback 'on_credentials_error' is correct."""490 """Callback 'on_credentials_error' is correct."""
@@ -779,10 +823,6 @@
779 self.assertEqual(volume['volume_id'], check.get_label())823 self.assertEqual(volume['volume_id'], check.get_label())
780 self.assertFalse(check.get_child().get_visible())824 self.assertFalse(check.get_child().get_visible())
781825
782 def test_on_volumes_info_error(self):
783 """The volumes info couldn't be retrieved."""
784 self.ui.on_volumes_info_error()
785
786 def test_on_volumes_info_ready_clears_the_list(self):826 def test_on_volumes_info_ready_clears_the_list(self):
787 """The old volumes info is cleared before updated."""827 """The old volumes info is cleared before updated."""
788 self.ui.on_volumes_info_ready(FAKE_VOLUMES_INFO)828 self.ui.on_volumes_info_ready(FAKE_VOLUMES_INFO)
@@ -823,6 +863,23 @@
823 self.assert_backend_called('change_volume_settings',863 self.assert_backend_called('change_volume_settings',
824 (fid, {'subscribed': subscribed}))864 (fid, {'subscribed': subscribed}))
825865
866 def test_on_volumes_info_error(self):
867 """The volumes info couldn't be retrieved."""
868 self.ui.on_volumes_info_error()
869 self.assert_warning_correct(warning=self.ui.volumes_label,
870 text=self.ui.VALUE_ERROR)
871 self.assertFalse(self.ui.volumes_label.active)
872 self.assertTrue(self.ui.label_alignment.get_visible())
873
874 def test_on_volumes_info_error_after_success(self):
875 """The volumes info couldn't be retrieved after a prior success."""
876 self.ui.on_volumes_info_ready(FAKE_VOLUMES_INFO)
877
878 self.ui.on_volumes_info_error()
879
880 self.test_on_volumes_info_error()
881 self.test_on_volumes_info_ready_with_no_volumes()
882
826883
827class DevicesTestCase(ControlPanelMixinTestCase):884class DevicesTestCase(ControlPanelMixinTestCase):
828 """The test suite for the devices panel."""885 """The test suite for the devices panel."""
@@ -1058,5 +1115,6 @@
1058 """The file sync status couldn't be retrieved."""1115 """The file sync status couldn't be retrieved."""
1059 self.ui.on_file_sync_status_error({'error_msg': 'error msg'})1116 self.ui.on_file_sync_status_error({'error_msg': 'error msg'})
10601117
1061 self.assert_warning_correct(self.ui.status_label, 'error msg')1118 self.assert_warning_correct(self.ui.status_label,
1119 self.ui.FILE_SYNC_ERROR)
1062 self.assertFalse(self.ui.status_label.active)1120 self.assertFalse(self.ui.status_label.active)

Subscribers

People subscribed via source and target branches