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
1=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
2--- ubuntuone/controlpanel/gtk/gui.py 2010-12-14 20:41:48 +0000
3+++ ubuntuone/controlpanel/gtk/gui.py 2010-12-14 20:41:48 +0000
4@@ -176,17 +176,25 @@
5 ControlPanelMixin.__init__(self, filename='controlpanel.ui')
6 self._window_id = window_id
7
8+ self.management = None
9 self.overview = OverviewPanel(window_id=window_id)
10 self.overview.connect('credentials-found',
11 self.on_show_management_panel)
12 self.add(self.overview)
13 self.show()
14
15- def on_show_management_panel(self, *args, **kwargs):
16+ def on_show_management_panel(self, widget=None,
17+ credentials_are_new=False, token=None):
18 """Show the netbook (main panel)."""
19 if self.overview in self.get_children():
20 self.remove(self.overview)
21- self.add(ManagementPanel())
22+
23+ self.management = ManagementPanel()
24+ if credentials_are_new:
25+ # redirect user to Folders page to review folders subscription
26+ self.management.folders_button.clicked()
27+
28+ self.add(self.management)
29
30
31 class UbuntuOneBin(gtk.VBox):
32@@ -228,6 +236,7 @@
33 self.warning_label.set_property('xalign', 0.5)
34 self.warning_label.connect('size-allocate', self.on_size_allocate)
35
36+ self._credentials_are_new = False
37 self._messages = messages
38 self._window_id = window_id
39 self._build_messages()
40@@ -318,13 +327,14 @@
41 @log_call(logger.info)
42 def on_credentials_found(self, app_name, credentials):
43 """SSO backend notifies of credentials found."""
44- self.emit('credentials-found', app_name, credentials)
45+ self.emit('credentials-found', self._credentials_are_new, credentials)
46 self.hide()
47
48 @filter_by_app_name
49 @log_call(logger.info)
50 def on_credentials_not_found(self, app_name):
51 """SSO backend notifies of credentials not found."""
52+ self._credentials_are_new = True
53 self.set_property('greyed', False)
54
55 @filter_by_app_name
56@@ -434,6 +444,7 @@
57
58 if not info:
59 self.volumes_label.set_markup(self.NO_VOLUMES)
60+ self.label_alignment.show()
61 return
62 else:
63 self.label_alignment.hide()
64@@ -467,6 +478,9 @@
65 @log_call(logger.error)
66 def on_volumes_info_error(self, error_dict=None):
67 """Backend notifies of an error when fetching volumes info."""
68+ self.volumes_label.stop()
69+ self._set_warning(self.VALUE_ERROR, self.volumes_label)
70+ self.label_alignment.show()
71
72 def on_subscribed_clicked(self, checkbutton):
73 """The user toggled 'checkbutton'."""
74@@ -576,6 +590,7 @@
75
76 self.backend.account_info()
77 self.backend.file_sync_status()
78+ self.account_button.clicked()
79
80 def _update_quota(self, msg, data=None):
81 """Update the quota info."""
82@@ -634,12 +649,9 @@
83 @log_call(logger.error)
84 def on_file_sync_status_error(self, error_dict=None):
85 """Backend notifies of an error when fetching file sync status."""
86- msg = error_dict.get('error_msg', None)
87- if msg is None:
88- msg = error_dict.get('message', self.VALUE_ERROR)
89- self._update_status(WARNING_MARKUP % msg)
90+ self._update_status(WARNING_MARKUP % self.FILE_SYNC_ERROR)
91
92
93 gobject.signal_new('credentials-found', OverviewPanel,
94 gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
95- (gobject.TYPE_STRING, gobject.TYPE_PYOBJECT))
96+ (gobject.TYPE_BOOLEAN, gobject.TYPE_PYOBJECT))
97
98=== modified file 'ubuntuone/controlpanel/gtk/tests/test_gui.py'
99--- ubuntuone/controlpanel/gtk/tests/test_gui.py 2010-12-14 20:41:48 +0000
100+++ ubuntuone/controlpanel/gtk/tests/test_gui.py 2010-12-14 20:41:48 +0000
101@@ -309,6 +309,34 @@
102
103 self.assertEqual(1, len(self.ui.get_children()))
104
105+ def test_credentials_found_shows_account_management_panel(self):
106+ """On 'credentials-found' signal, the management panel is shown.
107+
108+ If first signal parameter is False, visible tab should be account.
109+
110+ """
111+ a_token = object()
112+ self.ui.overview.emit('credentials-found', False, a_token)
113+
114+ children = self.ui.get_children()
115+ self.assertIsInstance(children[-1], gui.ManagementPanel)
116+ self.assertEqual(self.ui.management.notebook.get_current_page(),
117+ self.ui.management.ACCOUNT_PAGE)
118+
119+ def test_credentials_found_shows_folders_management_panel(self):
120+ """On 'credentials-found' signal, the management panel is shown.
121+
122+ If first signal parameter is True, visible tab should be folders.
123+
124+ """
125+ a_token = object()
126+ self.ui.overview.emit('credentials-found', True, a_token)
127+
128+ children = self.ui.get_children()
129+ self.assertIsInstance(children[-1], gui.ManagementPanel)
130+ self.assertEqual(self.ui.management.notebook.get_current_page(),
131+ self.ui.management.FOLDERS_PAGE)
132+
133
134 class UbuntuOneBinTestCase(BaseTestCase):
135 """The test suite for a Ubuntu One panel."""
136@@ -425,6 +453,7 @@
137
138 def test_find_credentials_is_called(self):
139 """Credentials are asked to SSO backend."""
140+ self.assertFalse(self.ui._credentials_are_new)
141 self.assert_backend_called('find_credentials', (gui.U1_APP_NAME, {}),
142 backend=self.ui.sso_backend)
143
144@@ -435,12 +464,27 @@
145 self.ui.on_credentials_found(gui.U1_APP_NAME, TOKEN)
146
147 self.assertFalse(self.ui.get_visible())
148- self.assertEqual(self._called, ((self.ui, gui.U1_APP_NAME, TOKEN), {}))
149+ # assume credentials were in local keyring
150+ self.assertEqual(self._called, ((self.ui, False, TOKEN), {}))
151+
152+ def test_on_credentials_found_when_creds_are_not_new(self):
153+ """Callback 'on_credentials_found' distinguish if creds are new."""
154+ self.ui.connect('credentials-found', self._set_called)
155+
156+ # credentials weren't in the system
157+ self.ui.on_credentials_not_found(gui.U1_APP_NAME)
158+ # now they are!
159+ self.ui.on_credentials_found(gui.U1_APP_NAME, TOKEN)
160+
161+ self.assertFalse(self.ui.get_visible())
162+ # assume credentials were not in local keyring
163+ self.assertEqual(self._called, ((self.ui, True, TOKEN), {}))
164
165 def test_on_credentials_not_found(self):
166 """Callback 'on_credentials_not_found' is correct."""
167 self.ui.on_credentials_not_found(gui.U1_APP_NAME)
168 self.assertTrue(self.ui.get_visible())
169+ self.assertTrue(self.ui._credentials_are_new)
170
171 def test_on_credentials_error(self):
172 """Callback 'on_credentials_error' is correct."""
173@@ -779,10 +823,6 @@
174 self.assertEqual(volume['volume_id'], check.get_label())
175 self.assertFalse(check.get_child().get_visible())
176
177- def test_on_volumes_info_error(self):
178- """The volumes info couldn't be retrieved."""
179- self.ui.on_volumes_info_error()
180-
181 def test_on_volumes_info_ready_clears_the_list(self):
182 """The old volumes info is cleared before updated."""
183 self.ui.on_volumes_info_ready(FAKE_VOLUMES_INFO)
184@@ -823,6 +863,23 @@
185 self.assert_backend_called('change_volume_settings',
186 (fid, {'subscribed': subscribed}))
187
188+ def test_on_volumes_info_error(self):
189+ """The volumes info couldn't be retrieved."""
190+ self.ui.on_volumes_info_error()
191+ self.assert_warning_correct(warning=self.ui.volumes_label,
192+ text=self.ui.VALUE_ERROR)
193+ self.assertFalse(self.ui.volumes_label.active)
194+ self.assertTrue(self.ui.label_alignment.get_visible())
195+
196+ def test_on_volumes_info_error_after_success(self):
197+ """The volumes info couldn't be retrieved after a prior success."""
198+ self.ui.on_volumes_info_ready(FAKE_VOLUMES_INFO)
199+
200+ self.ui.on_volumes_info_error()
201+
202+ self.test_on_volumes_info_error()
203+ self.test_on_volumes_info_ready_with_no_volumes()
204+
205
206 class DevicesTestCase(ControlPanelMixinTestCase):
207 """The test suite for the devices panel."""
208@@ -1058,5 +1115,6 @@
209 """The file sync status couldn't be retrieved."""
210 self.ui.on_file_sync_status_error({'error_msg': 'error msg'})
211
212- self.assert_warning_correct(self.ui.status_label, 'error msg')
213+ self.assert_warning_correct(self.ui.status_label,
214+ self.ui.FILE_SYNC_ERROR)
215 self.assertFalse(self.ui.status_label.active)

Subscribers

People subscribed via source and target branches