Merge lp:~nataliabidart/ubuntuone-control-panel/disable-files into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 122
Merged at revision: 125
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/disable-files
Merge into: lp:ubuntuone-control-panel
Diff against target: 409 lines (+104/-9)
4 files modified
ubuntuone/controlpanel/backend.py (+11/-2)
ubuntuone/controlpanel/gtk/gui.py (+17/-7)
ubuntuone/controlpanel/gtk/tests/test_gui.py (+19/-0)
ubuntuone/controlpanel/tests/test_backend.py (+57/-0)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/disable-files
Reviewer Review Type Date Requested Status
Chad Miller (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+56217@code.launchpad.net

Commit message

- Unify disable/enable file sync functionality among Services tab and global file sync status (LP: #729301).
- Cloud Folders tab is now disabled when the file sync service is (LP: #747482).

Description of the change

In order to test, you need to be running ubuntuone-client revno 932 or higher.

Then, using 2 terminals, you should:

1$> DEBUG=True PYTHONPATH=~/path/to/u1/client/revno-932-or-higher/:. ./bin/ubuntuone-control-panel-backend

2$> DEBUG=True PYTHONPATH=~/path/to/u1/client/revno-932-or-higher/:. ./bin/ubuntuone-control-panel-gtk

Go to the services tab and play with the 'enable file sync' checkbox. The global file sync status bar should be updated properly.
Go

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

Cloud Folders tab is now disabled when the file sync service is (LP: #747482).

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

+1

review: Approve
Revision history for this message
Chad Miller (cmiller) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/backend.py'
2--- ubuntuone/controlpanel/backend.py 2011-03-31 21:11:39 +0000
3+++ ubuntuone/controlpanel/backend.py 2011-04-04 18:22:45 +0000
4@@ -78,6 +78,7 @@
5 FOLDER_TYPE = u'UDF'
6 SHARE_TYPE = u'SHARE'
7 NAME_NOT_SET = u'ENAMENOTSET'
8+ STATUS_DISABLED = {MSG_KEY: '', STATUS_KEY: FILE_SYNC_DISABLED}
9
10 def __init__(self, shutdown_func=None):
11 """Initialize the webclient."""
12@@ -87,6 +88,7 @@
13 self.status_changed_handler = lambda *a: None
14
15 self._volumes = {} # cache last known volume info
16+ self.file_sync_disabled = False
17
18 def _process_file_sync_status(self, status):
19 """Process raw file sync status into custom format.
20@@ -100,7 +102,8 @@
21
22 """
23 if not status:
24- return {MSG_KEY: '', STATUS_KEY: FILE_SYNC_DISABLED}
25+ self.file_sync_disabled = True
26+ return self.STATUS_DISABLED
27
28 msg = '%s (%s)' % (status['description'], status['name'])
29 result = {MSG_KEY: msg}
30@@ -124,6 +127,7 @@
31 elif is_disconnected:
32 result[STATUS_KEY] = FILE_SYNC_DISCONNECTED
33 elif is_starting:
34+ self.file_sync_disabled = False
35 result[STATUS_KEY] = FILE_SYNC_STARTING
36 elif is_stopped:
37 result[STATUS_KEY] = FILE_SYNC_STOPPED
38@@ -131,7 +135,10 @@
39 logger.warning('file_sync_status: unknown (got %r)', status)
40 result[STATUS_KEY] = FILE_SYNC_UNKNOWN
41
42- return result
43+ if self.file_sync_disabled:
44+ return self.STATUS_DISABLED
45+ else:
46+ return result
47
48 def _set_status_changed_handler(self, handler):
49 """Set 'handler' to be called when file sync status changes."""
50@@ -370,12 +377,14 @@
51 def enable_files(self):
52 """Enable the files service."""
53 yield dbus_client.set_files_sync_enabled(True)
54+ self.file_sync_disabled = False
55
56 @log_call(logger.debug)
57 @inlineCallbacks
58 def disable_files(self):
59 """Enable the files service."""
60 yield dbus_client.set_files_sync_enabled(False)
61+ self.file_sync_disabled = True
62
63 @log_call(logger.debug)
64 @inlineCallbacks
65
66=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
67--- ubuntuone/controlpanel/gtk/gui.py 2011-04-01 16:10:44 +0000
68+++ ubuntuone/controlpanel/gtk/gui.py 2011-04-04 18:22:45 +0000
69@@ -1051,7 +1051,8 @@
70 def on_file_sync_status_changed(self, status):
71 """File Sync status changed."""
72 enabled = status != backend.FILE_SYNC_DISABLED
73- logger.info('FileSyncService: enabled? %r', enabled)
74+ logger.info('FileSyncService: on_file_sync_status_changed: '
75+ 'status %r, enabled? %r', status, enabled)
76 self.check_button.set_active(enabled)
77 # if service is disabled, disable the action_button
78 self.action_button.set_sensitive(enabled)
79@@ -1327,6 +1328,10 @@
80 self.on_file_sync_status_error)
81 self.backend.connect_to_signal('FilesStartError',
82 self.on_files_start_error)
83+ self.backend.connect_to_signal('FilesEnabled',
84+ self.on_file_sync_status_starting)
85+ self.backend.connect_to_signal('FilesDisabled',
86+ self.on_file_sync_status_disabled)
87
88 self.backend.file_sync_status(reply_handler=NO_OP,
89 error_handler=error_handler)
90@@ -1355,42 +1360,42 @@
91 button.get_data('callback')(button)
92
93 @log_call(logger.info)
94- def on_file_sync_status_disabled(self, msg):
95+ def on_file_sync_status_disabled(self, msg=None):
96 """Backend notifies of file sync status being disabled."""
97 self._update_status(self.FILE_SYNC_DISABLED,
98 self.ENABLE, self.on_enable_clicked,
99 '✘', 'red', self.ENABLE_TOOLTIP)
100
101 @log_call(logger.info)
102- def on_file_sync_status_starting(self, msg):
103+ def on_file_sync_status_starting(self, msg=None):
104 """Backend notifies of file sync status being starting."""
105 self._update_status(self.FILE_SYNC_STARTING,
106 self.STOP, self.on_stop_clicked,
107 '⇅', ORANGE, self.STOP_TOOLTIP)
108
109 @log_call(logger.info)
110- def on_file_sync_status_stopped(self, msg):
111+ def on_file_sync_status_stopped(self, msg=None):
112 """Backend notifies of file sync being stopped."""
113 self._update_status(self.FILE_SYNC_STOPPED,
114 self.START, self.on_start_clicked,
115 '✘', 'red', self.START_TOOLTIP)
116
117 @log_call(logger.info)
118- def on_file_sync_status_disconnected(self, msg):
119+ def on_file_sync_status_disconnected(self, msg=None):
120 """Backend notifies of file sync status being ready."""
121 self._update_status(self.FILE_SYNC_DISCONNECTED,
122 self.CONNECT, self.on_connect_clicked,
123 '✘', 'red', self.CONNECT_TOOLTIP,)
124
125 @log_call(logger.info)
126- def on_file_sync_status_syncing(self, msg):
127+ def on_file_sync_status_syncing(self, msg=None):
128 """Backend notifies of file sync status being syncing."""
129 self._update_status(self.FILE_SYNC_SYNCING,
130 self.DISCONNECT, self.on_disconnect_clicked,
131 '⇅', ORANGE, self.DISCONNECT_TOOLTIP)
132
133 @log_call(logger.info)
134- def on_file_sync_status_idle(self, msg):
135+ def on_file_sync_status_idle(self, msg=None):
136 """Backend notifies of file sync status being idle."""
137 self._update_status(self.FILE_SYNC_IDLE,
138 self.DISCONNECT, self.on_disconnect_clicked,
139@@ -1522,6 +1527,11 @@
140 self.services_button.set_tooltip_text(self.SERVICES_BUTTON_TOOLTIP)
141 self.services.load()
142
143+ self.enable_volumes = lambda: self.volumes_button.set_sensitive(True)
144+ self.disable_volumes = lambda: self.volumes_button.set_sensitive(False)
145+ self.backend.connect_to_signal('FilesEnabled', self.enable_volumes)
146+ self.backend.connect_to_signal('FilesDisabled', self.disable_volumes)
147+
148 def _update_quota(self, msg, data=None):
149 """Update the quota info."""
150 fraction = 0.0
151
152=== modified file 'ubuntuone/controlpanel/gtk/tests/test_gui.py'
153--- ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-03-04 21:43:19 +0000
154+++ ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-04-04 18:22:45 +0000
155@@ -1646,6 +1646,8 @@
156 ('FileSyncStatusIdle', [self.ui.on_file_sync_status_idle]),
157 ('FileSyncStatusError', [self.ui.on_file_sync_status_error]),
158 ('FilesStartError', [self.ui.on_files_start_error]),
159+ ('FilesDisabled', [self.ui.on_file_sync_status_disabled]),
160+ ('FilesEnabled', [self.ui.on_file_sync_status_starting]),
161 )
162 for sig, handlers in matches:
163 self.assertEqual(self.ui.backend._signals[sig], handlers)
164@@ -1999,6 +2001,23 @@
165 self.assertIsInstance(self.ui.status_label, gui.FileSyncStatus)
166 self.assertIn(self.ui.status_label, self.ui.status_box.get_children())
167
168+ def test_backend_file_sync_signals(self):
169+ """The proper signals are connected to the backend."""
170+ self.assertEqual(self.ui.backend._signals['FilesEnabled'],
171+ [self.ui.enable_volumes])
172+ self.assertEqual(self.ui.backend._signals['FilesDisabled'],
173+ [self.ui.disable_volumes])
174+
175+ def test_enable_volumes(self):
176+ """The volumes tab is properly enabled."""
177+ self.ui.enable_volumes()
178+ self.assertTrue(self.ui.volumes_button.get_sensitive())
179+
180+ def test_disable_volumes(self):
181+ """The volumes tab is properly disabled."""
182+ self.ui.disable_volumes()
183+ self.assertFalse(self.ui.volumes_button.get_sensitive())
184+
185 def test_local_device_removed_is_emitted(self):
186 """Signal local-device-removed is sent when DevicesPanel emits it."""
187 self.ui.connect('local-device-removed', self._set_called)
188
189=== modified file 'ubuntuone/controlpanel/tests/test_backend.py'
190--- ubuntuone/controlpanel/tests/test_backend.py 2011-03-31 18:40:33 +0000
191+++ ubuntuone/controlpanel/tests/test_backend.py 2011-04-04 18:22:45 +0000
192@@ -683,6 +683,12 @@
193 class BackendSyncStatusTestCase(BackendBasicTestCase):
194 """Syncdaemon state for the backend."""
195
196+ was_disabled = False
197+
198+ def setUp(self):
199+ super(BackendSyncStatusTestCase, self).setUp()
200+ self.be.file_sync_disabled = self.was_disabled
201+
202 def _build_msg(self):
203 """Build expected message regarding file sync status."""
204 return '%s (%s)' % (MockDBusClient.status['description'],
205@@ -701,6 +707,7 @@
206 """The syncdaemon status is processed and emitted."""
207 self.patch(MockDBusClient, 'file_sync', False)
208 yield self.assert_correct_status(FILE_SYNC_DISABLED, msg='')
209+ self.assertTrue(self.be.file_sync_disabled)
210
211 @inlineCallbacks
212 def test_error(self):
213@@ -712,6 +719,8 @@
214 'description': 'auth failed',
215 }
216 yield self.assert_correct_status(FILE_SYNC_ERROR)
217+ # self.be.file_sync_disabled does not change
218+ self.assertEqual(self.was_disabled, self.be.file_sync_disabled)
219
220 @inlineCallbacks
221 def test_starting_when_init_not_user(self):
222@@ -722,6 +731,7 @@
223 'name': 'INIT', 'description': 'something new',
224 }
225 yield self.assert_correct_status(FILE_SYNC_STARTING)
226+ self.assertFalse(self.be.file_sync_disabled)
227
228 @inlineCallbacks
229 def test_starting_when_init_with_user(self):
230@@ -732,6 +742,7 @@
231 'name': 'INIT', 'description': 'something new',
232 }
233 yield self.assert_correct_status(FILE_SYNC_STARTING)
234+ self.assertFalse(self.be.file_sync_disabled)
235
236 @inlineCallbacks
237 def test_starting_when_local_rescan_not_user(self):
238@@ -742,6 +753,7 @@
239 'name': 'LOCAL_RESCAN', 'description': 'something new',
240 }
241 yield self.assert_correct_status(FILE_SYNC_STARTING)
242+ self.assertFalse(self.be.file_sync_disabled)
243
244 @inlineCallbacks
245 def test_starting_when_local_rescan_with_user(self):
246@@ -752,6 +764,7 @@
247 'name': 'LOCAL_RESCAN', 'description': 'something new',
248 }
249 yield self.assert_correct_status(FILE_SYNC_STARTING)
250+ self.assertFalse(self.be.file_sync_disabled)
251
252 @inlineCallbacks
253 def test_starting_when_ready_with_user(self):
254@@ -762,6 +775,7 @@
255 'name': 'READY', 'description': 'something nicer',
256 }
257 yield self.assert_correct_status(FILE_SYNC_STARTING)
258+ self.assertFalse(self.be.file_sync_disabled)
259
260 @inlineCallbacks
261 def test_disconnected(self):
262@@ -774,6 +788,9 @@
263 }
264 yield self.assert_correct_status(FILE_SYNC_DISCONNECTED)
265
266+ # self.be.file_sync_disabled does not change
267+ self.assertEqual(self.was_disabled, self.be.file_sync_disabled)
268+
269 @inlineCallbacks
270 def test_disconnected_when_waiting(self):
271 """The syncdaemon status is processed and emitted."""
272@@ -784,6 +801,9 @@
273 }
274 yield self.assert_correct_status(FILE_SYNC_DISCONNECTED)
275
276+ # self.be.file_sync_disabled does not change
277+ self.assertEqual(self.was_disabled, self.be.file_sync_disabled)
278+
279 @inlineCallbacks
280 def test_syncing_if_online(self):
281 """The syncdaemon status is processed and emitted."""
282@@ -795,6 +815,9 @@
283 }
284 yield self.assert_correct_status(FILE_SYNC_SYNCING)
285
286+ # self.be.file_sync_disabled does not change
287+ self.assertEqual(self.was_disabled, self.be.file_sync_disabled)
288+
289 @inlineCallbacks
290 def test_syncing_even_if_not_online(self):
291 """The syncdaemon status is processed and emitted."""
292@@ -806,6 +829,9 @@
293 }
294 yield self.assert_correct_status(FILE_SYNC_SYNCING)
295
296+ # self.be.file_sync_disabled does not change
297+ self.assertEqual(self.was_disabled, self.be.file_sync_disabled)
298+
299 @inlineCallbacks
300 def test_idle(self):
301 """The syncdaemon status is processed and emitted."""
302@@ -817,6 +843,9 @@
303 }
304 yield self.assert_correct_status(FILE_SYNC_IDLE)
305
306+ # self.be.file_sync_disabled does not change
307+ self.assertEqual(self.was_disabled, self.be.file_sync_disabled)
308+
309 @inlineCallbacks
310 def test_stopped(self):
311 """The syncdaemon status is processed and emitted."""
312@@ -828,6 +857,9 @@
313 }
314 yield self.assert_correct_status(FILE_SYNC_STOPPED)
315
316+ # self.be.file_sync_disabled does not change
317+ self.assertEqual(self.was_disabled, self.be.file_sync_disabled)
318+
319 @inlineCallbacks
320 def test_unknown(self):
321 """The syncdaemon status is processed and emitted."""
322@@ -842,6 +874,9 @@
323 repr(MockDBusClient.status))
324 self.assertTrue(has_warning)
325
326+ # self.be.file_sync_disabled does not change
327+ self.assertEqual(self.was_disabled, self.be.file_sync_disabled)
328+
329 def test_status_changed(self):
330 """The file_sync_status is the status changed handler."""
331 self.be.status_changed_handler = self._set_called
332@@ -856,6 +891,21 @@
333 self.assertEqual(self._called, ((expected_status,), {}))
334
335
336+class BackendSyncStatusIfDisabledTestCase(BackendSyncStatusTestCase):
337+ """Syncdaemon state for the backend when file sync is disabled."""
338+
339+ was_disabled = True
340+
341+ @inlineCallbacks
342+ def assert_correct_status(self, status, msg=None):
343+ """Check that the resulting status is correct."""
344+ sup = super(BackendSyncStatusIfDisabledTestCase, self)
345+ if status != FILE_SYNC_STARTING:
346+ yield sup.assert_correct_status(FILE_SYNC_DISABLED, msg='')
347+ else:
348+ yield sup.assert_correct_status(status, msg=msg)
349+
350+
351 class BackendFileSyncOpsTestCase(BackendBasicTestCase):
352 """Syncdaemon operations for the backend."""
353
354@@ -870,6 +920,7 @@
355
356 yield self.be.enable_files()
357 self.assertTrue(MockDBusClient.file_sync)
358+ self.assertFalse(self.be.file_sync_disabled)
359
360 @inlineCallbacks
361 def test_disable_files(self):
362@@ -878,6 +929,7 @@
363
364 yield self.be.disable_files()
365 self.assertFalse(MockDBusClient.file_sync)
366+ self.assertTrue(self.be.file_sync_disabled)
367
368 @inlineCallbacks
369 def test_connect_files(self):
370@@ -885,6 +937,7 @@
371 yield self.be.connect_files()
372
373 self.assertEqual(MockDBusClient.actions, ['connect'])
374+ self.assertFalse(self.be.file_sync_disabled)
375
376 @inlineCallbacks
377 def test_disconnect_files(self):
378@@ -892,6 +945,7 @@
379 yield self.be.disconnect_files()
380
381 self.assertEqual(MockDBusClient.actions, ['disconnect'])
382+ self.assertFalse(self.be.file_sync_disabled)
383
384 @inlineCallbacks
385 def test_restart_files(self):
386@@ -899,6 +953,7 @@
387 yield self.be.restart_files()
388
389 self.assertEqual(MockDBusClient.actions, ['stop', 'start'])
390+ self.assertFalse(self.be.file_sync_disabled)
391
392 @inlineCallbacks
393 def test_start_files(self):
394@@ -906,6 +961,7 @@
395 yield self.be.start_files()
396
397 self.assertEqual(MockDBusClient.actions, ['start'])
398+ self.assertFalse(self.be.file_sync_disabled)
399
400 @inlineCallbacks
401 def test_stop_files(self):
402@@ -913,6 +969,7 @@
403 yield self.be.stop_files()
404
405 self.assertEqual(MockDBusClient.actions, ['stop'])
406+ self.assertFalse(self.be.file_sync_disabled)
407
408
409 class BackendReplicationsTestCase(BackendBasicTestCase):

Subscribers

People subscribed via source and target branches