Merge lp:~nataliabidart/ubuntuone-control-panel/refactor-devices into lp:ubuntuone-control-panel
- refactor-devices
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||
Approved revision: | 170 | ||||
Merged at revision: | 168 | ||||
Proposed branch: | lp:~nataliabidart/ubuntuone-control-panel/refactor-devices | ||||
Merge into: | lp:ubuntuone-control-panel | ||||
Diff against target: |
1183 lines (+272/-216) 22 files modified
data/qt/controlpanel.ui (+3/-3) data/qt/devices.ui (+6/-17) data/qt/filesyncstatus.ui (+2/-2) data/qt/services.ui (+6/-6) ubuntuone/controlpanel/gui/qt/controlpanel.py (+20/-47) ubuntuone/controlpanel/gui/qt/devices.py (+42/-15) ubuntuone/controlpanel/gui/qt/filesyncstatus.py (+4/-6) ubuntuone/controlpanel/gui/qt/folders.py (+2/-5) ubuntuone/controlpanel/gui/qt/preferences.py (+3/-6) ubuntuone/controlpanel/gui/qt/profile.py (+16/-5) ubuntuone/controlpanel/gui/qt/services.py (+14/-4) ubuntuone/controlpanel/gui/qt/tests/__init__.py (+3/-1) ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py (+1/-32) ubuntuone/controlpanel/gui/qt/tests/test_devices.py (+48/-9) ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py (+12/-12) ubuntuone/controlpanel/gui/qt/tests/test_folders.py (+23/-20) ubuntuone/controlpanel/gui/qt/tests/test_gui.py (+1/-6) ubuntuone/controlpanel/gui/qt/tests/test_preferences.py (+14/-12) ubuntuone/controlpanel/gui/qt/tests/test_profile.py (+22/-2) ubuntuone/controlpanel/gui/qt/tests/test_services.py (+22/-2) ubuntuone/controlpanel/gui/qt/tests/test_ubuntuonebin.py (+6/-4) ubuntuone/controlpanel/gui/tests/__init__.py (+2/-0) |
||||
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-control-panel/refactor-devices | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Roberto Alsina (community) | Approve | ||
John Lenton (community) | Approve | ||
Review via email: mp+65425@code.launchpad.net |
Commit message
- Device and account info is now loaded just like other widgets (independently from their parents).
- Device info is no longer faked, and local device is also a DeviceWidget (LP: #800362).
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/qt/controlpanel.ui' |
2 | --- data/qt/controlpanel.ui 2011-06-20 22:21:30 +0000 |
3 | +++ data/qt/controlpanel.ui 2011-06-21 22:49:26 +0000 |
4 | @@ -25,7 +25,7 @@ |
5 | <item> |
6 | <widget class="QLabel" name="greeting_label"> |
7 | <property name="text"> |
8 | - <string>Hello Lisette!</string> |
9 | + <string notr="true"/> |
10 | </property> |
11 | </widget> |
12 | </item> |
13 | @@ -43,9 +43,9 @@ |
14 | </spacer> |
15 | </item> |
16 | <item> |
17 | - <widget class="QLabel" name="usage_label"> |
18 | + <widget class="QLabel" name="quota_usage_label"> |
19 | <property name="text"> |
20 | - <string>39% of 22 GB in use</string> |
21 | + <string notr="true"/> |
22 | </property> |
23 | </widget> |
24 | </item> |
25 | |
26 | === modified file 'data/qt/devices.ui' |
27 | --- data/qt/devices.ui 2011-06-20 22:21:30 +0000 |
28 | +++ data/qt/devices.ui 2011-06-21 22:49:26 +0000 |
29 | @@ -6,8 +6,8 @@ |
30 | <rect> |
31 | <x>0</x> |
32 | <y>0</y> |
33 | - <width>558</width> |
34 | - <height>156</height> |
35 | + <width>692</width> |
36 | + <height>539</height> |
37 | </rect> |
38 | </property> |
39 | <property name="windowTitle"> |
40 | @@ -30,8 +30,8 @@ |
41 | <rect> |
42 | <x>0</x> |
43 | <y>0</y> |
44 | - <width>535</width> |
45 | - <height>136</height> |
46 | + <width>657</width> |
47 | + <height>519</height> |
48 | </rect> |
49 | </property> |
50 | <layout class="QGridLayout" name="gridLayout_2"> |
51 | @@ -82,18 +82,7 @@ |
52 | <item row="1" column="0"> |
53 | <layout class="QHBoxLayout" name="horizontalLayout_2"> |
54 | <item> |
55 | - <widget class="QLabel" name="device_icon_label"> |
56 | - <property name="pixmap"> |
57 | - <pixmap resource="images.qrc">:/computer.png</pixmap> |
58 | - </property> |
59 | - </widget> |
60 | - </item> |
61 | - <item> |
62 | - <widget class="QLabel" name="device_name_label"> |
63 | - <property name="text"> |
64 | - <string>This device</string> |
65 | - </property> |
66 | - </widget> |
67 | + <layout class="QVBoxLayout" name="local_device_box"/> |
68 | </item> |
69 | <item> |
70 | <spacer name="horizontalSpacer_2"> |
71 | @@ -118,7 +107,7 @@ |
72 | </layout> |
73 | </item> |
74 | <item row="7" column="0"> |
75 | - <layout class="QVBoxLayout" name="devices_list_verticallayout"/> |
76 | + <layout class="QVBoxLayout" name="remote_devices_box"/> |
77 | </item> |
78 | </layout> |
79 | </widget> |
80 | |
81 | === modified file 'data/qt/filesyncstatus.ui' |
82 | --- data/qt/filesyncstatus.ui 2011-06-20 22:21:30 +0000 |
83 | +++ data/qt/filesyncstatus.ui 2011-06-21 22:49:26 +0000 |
84 | @@ -19,7 +19,7 @@ |
85 | <item> |
86 | <widget class="QLabel" name="sync_status_label"> |
87 | <property name="text"> |
88 | - <string>Status unknown</string> |
89 | + <string notr="true"/> |
90 | </property> |
91 | <property name="buddy"> |
92 | <cstring>sync_status_button</cstring> |
93 | @@ -32,7 +32,7 @@ |
94 | <string>test</string> |
95 | </property> |
96 | <property name="text"> |
97 | - <string>Action unknown</string> |
98 | + <string notr="true"/> |
99 | </property> |
100 | </widget> |
101 | </item> |
102 | |
103 | === modified file 'data/qt/services.ui' |
104 | --- data/qt/services.ui 2011-06-20 22:21:30 +0000 |
105 | +++ data/qt/services.ui 2011-06-21 22:49:26 +0000 |
106 | @@ -21,7 +21,7 @@ |
107 | <item> |
108 | <widget class="QLabel" name="mobile_plan_title_label"> |
109 | <property name="text"> |
110 | - <string>Ubuntu One Mobile</string> |
111 | + <string notr="true"/> |
112 | </property> |
113 | </widget> |
114 | </item> |
115 | @@ -41,7 +41,7 @@ |
116 | <item> |
117 | <widget class="QLabel" name="mobile_plan_trial_label"> |
118 | <property name="text"> |
119 | - <string>14 days free trial left</string> |
120 | + <string notr="true"/> |
121 | </property> |
122 | </widget> |
123 | </item> |
124 | @@ -57,7 +57,7 @@ |
125 | <item> |
126 | <widget class="QLabel" name="mobile_plan_billing_label"> |
127 | <property name="text"> |
128 | - <string>Billed Monthly - $3.99 per month</string> |
129 | + <string notr="true"/> |
130 | </property> |
131 | </widget> |
132 | </item> |
133 | @@ -107,7 +107,7 @@ |
134 | <item> |
135 | <widget class="QLabel" name="storage_plan_total_label"> |
136 | <property name="text"> |
137 | - <string>22 GB in total</string> |
138 | + <string notr="true"/> |
139 | </property> |
140 | </widget> |
141 | </item> |
142 | @@ -127,7 +127,7 @@ |
143 | <item> |
144 | <widget class="QLabel" name="storage_plan_usage_label"> |
145 | <property name="text"> |
146 | - <string>39% in use</string> |
147 | + <string notr="true"/> |
148 | </property> |
149 | </widget> |
150 | </item> |
151 | @@ -143,7 +143,7 @@ |
152 | <item> |
153 | <widget class="QLabel" name="storage_plan_label"> |
154 | <property name="text"> |
155 | - <string>2 GB from your free account</string> |
156 | + <string notr="true"/> |
157 | </property> |
158 | <property name="textFormat"> |
159 | <enum>Qt::PlainText</enum> |
160 | |
161 | === modified file 'ubuntuone/controlpanel/gui/qt/controlpanel.py' |
162 | --- ubuntuone/controlpanel/gui/qt/controlpanel.py 2011-06-20 23:23:45 +0000 |
163 | +++ ubuntuone/controlpanel/gui/qt/controlpanel.py 2011-06-21 22:49:26 +0000 |
164 | @@ -20,6 +20,7 @@ |
165 | """The user interface for the control panel for Ubuntu One.""" |
166 | |
167 | from PyQt4 import QtGui, QtCore |
168 | +from twisted.internet import defer |
169 | |
170 | from ubuntuone.controlpanel import backend |
171 | from ubuntuone.controlpanel.logger import setup_logging, log_call |
172 | @@ -27,26 +28,6 @@ |
173 | from ubuntuone.controlpanel.gui.qt import uri_hook |
174 | from ubuntuone.controlpanel.gui.qt.ui import controlpanel_ui |
175 | |
176 | -SAMPLE_DEVICES_INFO = [ |
177 | - { |
178 | - "type": "Computer", |
179 | - "name": "toshiba laptop", |
180 | - "is_local": True, |
181 | - "configurable": False, |
182 | - }, |
183 | - { |
184 | - "type": "Computer", |
185 | - "name": "desktop i5", |
186 | - "is_local": False, |
187 | - "configurable": False, |
188 | - }, |
189 | - { |
190 | - "type": "Phone", |
191 | - "name": "nokia 1100", |
192 | - "is_local": False, |
193 | - "configurable": False, |
194 | - }, |
195 | -] |
196 | |
197 | logger = setup_logging('qt.controlpanel') |
198 | |
199 | @@ -61,34 +42,26 @@ |
200 | self.ui.setupUi(self) |
201 | |
202 | self.backend = backend.ControlBackend() |
203 | - |
204 | logger.debug('%s: started.', self.__class__.__name__) |
205 | - self.get_account_info() |
206 | - self.get_devices_info() |
207 | - |
208 | - def get_account_info(self): |
209 | - """Get and update the account info from the webservice.""" |
210 | - d = self.backend.account_info() |
211 | - d.addCallback(self.got_account_info) |
212 | - |
213 | - def get_devices_info(self): |
214 | - """Get and update the list of devices.""" |
215 | - # TODO: get the info from the backend |
216 | - # this should be changed when have a working dbus replacement on win32 |
217 | - #d = self.backend.devices_info() |
218 | - #d.addCallback(self.got_devices_info) |
219 | - self.got_devices_info(SAMPLE_DEVICES_INFO) |
220 | - |
221 | - @log_call(logger.debug) |
222 | - def got_devices_info(self, devices_info): |
223 | - """Set the account info in all tabs.""" |
224 | - self.ui.devices_tab.update_devices_info(devices_info) |
225 | - |
226 | - @log_call(logger.debug) |
227 | - def got_account_info(self, account_info): |
228 | - """Set the account info in all tabs.""" |
229 | - self.ui.profile_tab.update_account_info(account_info) |
230 | - self.ui.services_tab.update_account_info(account_info) |
231 | + |
232 | + # Invalid name "showEvent" |
233 | + # pylint: disable=C0103 |
234 | + |
235 | + def showEvent(self, event): |
236 | + """Load info.""" |
237 | + self.load() |
238 | + event.accept() |
239 | + |
240 | + @defer.inlineCallbacks |
241 | + def load(self): |
242 | + """Load info.""" |
243 | + info = yield self.backend.account_info() |
244 | + self.process_info(info) |
245 | + |
246 | + @log_call(logger.debug) |
247 | + def process_info(self, info): |
248 | + """Process and display the account info.""" |
249 | + # TODO: update storage usage |
250 | |
251 | @QtCore.pyqtSlot() |
252 | def on_get_more_space_button_clicked(self): |
253 | |
254 | === modified file 'ubuntuone/controlpanel/gui/qt/devices.py' |
255 | --- ubuntuone/controlpanel/gui/qt/devices.py 2011-06-20 22:21:30 +0000 |
256 | +++ ubuntuone/controlpanel/gui/qt/devices.py 2011-06-21 22:49:26 +0000 |
257 | @@ -24,7 +24,9 @@ |
258 | # pylint: disable=W0611 |
259 | from PyQt4 import QtGui, QtCore |
260 | # pylint: enable=W0611 |
261 | +from twisted.internet import defer |
262 | |
263 | +from ubuntuone.controlpanel.logger import setup_logging, log_call |
264 | from ubuntuone.controlpanel.gui import EDIT_DEVICES_LINK |
265 | from ubuntuone.controlpanel.gui.qt import uri_hook |
266 | from ubuntuone.controlpanel.gui.qt.ui import devices_ui |
267 | @@ -32,25 +34,43 @@ |
268 | from ubuntuone.controlpanel.gui.qt.device import DeviceWidget |
269 | |
270 | |
271 | +logger = setup_logging('qt.devices') |
272 | + |
273 | + |
274 | class DevicesPanel(UbuntuOneBin): |
275 | """The DevicesFolders Tab Panel widget""" |
276 | |
277 | title = _('All cloud-connected devices') |
278 | ui_class = devices_ui |
279 | |
280 | + @defer.inlineCallbacks |
281 | def load(self): |
282 | """Load info.""" |
283 | - # request devices info |
284 | - |
285 | - def update_local_device(self, device_info): |
286 | - """Update the info for the local device.""" |
287 | - self.ui.device_name_label.setText(device_info["name"]) |
288 | - |
289 | - def create_remote_device(self, device_info): |
290 | - """Add a remote device to the list.""" |
291 | - device_widget = DeviceWidget() |
292 | - device_widget.update_device_info(device_info) |
293 | - self.ui.devices_list_verticallayout.addWidget(device_widget) |
294 | + self.is_processing = True |
295 | + info = yield self.backend.device_names_info() |
296 | + self.process_info(info) |
297 | + |
298 | + @log_call(logger.debug) |
299 | + def process_info(self, info): |
300 | + """Process and display the devices info.""" |
301 | + self.clear_device_info(self.ui.local_device_box) |
302 | + self.clear_device_info(self.ui.remote_devices_box) |
303 | + |
304 | + for device_info in info: |
305 | + self.update_device_info(device_info) |
306 | + |
307 | + self.is_processing = False |
308 | + |
309 | + def clear_device_info(self, box): |
310 | + """Clear all the device info.""" |
311 | + children = box.count() |
312 | + # we need to reverse the index list to remove children because: |
313 | + # "Items are numbered consecutively from 0. If an item is deleted, |
314 | + # other items will be renumbered." |
315 | + # http://doc.qt.nokia.com/latest/qlayout.html#itemAt |
316 | + for i in reversed(range(children)): |
317 | + widget = box.itemAt(i).widget() |
318 | + box.removeWidget(widget) |
319 | |
320 | def update_device_info(self, device_info): |
321 | """Update one device.""" |
322 | @@ -59,10 +79,17 @@ |
323 | else: |
324 | self.create_remote_device(device_info) |
325 | |
326 | - def update_devices_info(self, devices_info): |
327 | - """Update the list of devices in this panel.""" |
328 | - for device_info in devices_info: |
329 | - self.update_device_info(device_info) |
330 | + def update_local_device(self, device_info): |
331 | + """Update the info for the local device.""" |
332 | + device_widget = DeviceWidget() |
333 | + device_widget.update_device_info(device_info) |
334 | + self.ui.local_device_box.addWidget(device_widget) |
335 | + |
336 | + def create_remote_device(self, device_info): |
337 | + """Add a remote device to the list.""" |
338 | + device_widget = DeviceWidget() |
339 | + device_widget.update_device_info(device_info) |
340 | + self.ui.remote_devices_box.addWidget(device_widget) |
341 | |
342 | @QtCore.pyqtSlot() |
343 | def on_manage_devices_button_clicked(self): |
344 | |
345 | === modified file 'ubuntuone/controlpanel/gui/qt/filesyncstatus.py' |
346 | --- ubuntuone/controlpanel/gui/qt/filesyncstatus.py 2011-06-20 23:23:45 +0000 |
347 | +++ ubuntuone/controlpanel/gui/qt/filesyncstatus.py 2011-06-21 22:49:26 +0000 |
348 | @@ -111,7 +111,7 @@ |
349 | |
350 | self._backend_method = None |
351 | self.backend = backend.ControlBackend() |
352 | - self.backend.status_changed_handler = self.process_status |
353 | + self.backend.status_changed_handler = self.process_info |
354 | |
355 | logger.debug('%s: started.', self.__class__.__name__) |
356 | |
357 | @@ -127,18 +127,16 @@ |
358 | def load(self): |
359 | """Load specific tab info.""" |
360 | info = yield self.backend.file_sync_status() |
361 | - self.process_status(info) |
362 | + self.process_info(info) |
363 | |
364 | @log_call(logger.debug) |
365 | - def process_status(self, status): |
366 | + def process_info(self, status): |
367 | """Match status with signals.""" |
368 | - logger.debug('process_status: new status received %r', status) |
369 | - |
370 | try: |
371 | status_key = status[backend.STATUS_KEY] |
372 | data = FILE_SYNC_STATUS[status_key] |
373 | except (KeyError, TypeError): |
374 | - logger.exception('process_status: received unknown status dict %r', |
375 | + logger.exception('process_info: received unknown status dict %r', |
376 | status) |
377 | return |
378 | |
379 | |
380 | === modified file 'ubuntuone/controlpanel/gui/qt/folders.py' |
381 | --- ubuntuone/controlpanel/gui/qt/folders.py 2011-06-20 22:59:31 +0000 |
382 | +++ ubuntuone/controlpanel/gui/qt/folders.py 2011-06-21 22:49:26 +0000 |
383 | @@ -102,7 +102,7 @@ |
384 | """Load specific tab info.""" |
385 | self.is_processing = True |
386 | info = yield self.backend.volumes_info() |
387 | - self.process_folders(info) |
388 | + self.process_info(info) |
389 | |
390 | def humanize(self, int_bytes): |
391 | """Return a human readable representation of 'int_bytes'. |
392 | @@ -128,15 +128,12 @@ |
393 | return result |
394 | |
395 | @log_call(logger.debug) |
396 | - def process_folders(self, info): |
397 | + def process_info(self, info): |
398 | """Load folders info into the tree view.""" |
399 | self.ui.folders.clear() |
400 | self._backend_folders = [] |
401 | self.is_processing = False |
402 | |
403 | - if not info: |
404 | - return |
405 | - |
406 | for name, free_bytes, volumes in info: |
407 | if self.backend.NAME_NOT_SET in name: |
408 | name = NAME_NOT_SET |
409 | |
410 | === modified file 'ubuntuone/controlpanel/gui/qt/preferences.py' |
411 | --- ubuntuone/controlpanel/gui/qt/preferences.py 2011-06-20 22:59:31 +0000 |
412 | +++ ubuntuone/controlpanel/gui/qt/preferences.py 2011-06-21 22:49:26 +0000 |
413 | @@ -51,14 +51,11 @@ |
414 | def load(self): |
415 | """Load info.""" |
416 | info = yield self.backend.file_sync_settings_info() |
417 | - self.process_settings(info) |
418 | + self.process_info(info) |
419 | |
420 | @log_call(logger.debug) |
421 | - def process_settings(self, info): |
422 | + def process_info(self, info): |
423 | """Load settings info into the view.""" |
424 | - if not info: |
425 | - return |
426 | - |
427 | autoconnect = check_state(info[backend.AUTOCONNECT_KEY]) |
428 | show_all_notifs = \ |
429 | check_state(info[backend.SHOW_ALL_NOTIFICATIONS_KEY]) |
430 | @@ -132,6 +129,6 @@ |
431 | yield self.backend.restore_file_sync_settings() |
432 | settings = yield self.backend.file_sync_settings_info() |
433 | |
434 | - self.process_settings(settings) |
435 | + self.process_info(settings) |
436 | |
437 | # unset is_processing |
438 | |
439 | === modified file 'ubuntuone/controlpanel/gui/qt/profile.py' |
440 | --- ubuntuone/controlpanel/gui/qt/profile.py 2011-06-20 22:21:30 +0000 |
441 | +++ ubuntuone/controlpanel/gui/qt/profile.py 2011-06-21 22:49:26 +0000 |
442 | @@ -22,28 +22,39 @@ |
443 | # pylint: disable=W0611 |
444 | from PyQt4 import QtGui, QtCore |
445 | # pylint: enable=W0611 |
446 | +from twisted.internet import defer |
447 | |
448 | +from ubuntuone.controlpanel.logger import setup_logging, log_call |
449 | from ubuntuone.controlpanel.gui import EDIT_PROFILE_LINK |
450 | from ubuntuone.controlpanel.gui.qt import uri_hook |
451 | from ubuntuone.controlpanel.gui.qt.ubuntuonebin import UbuntuOneBin |
452 | from ubuntuone.controlpanel.gui.qt.ui import profile_ui |
453 | |
454 | |
455 | +logger = setup_logging('qt.profile') |
456 | + |
457 | + |
458 | class ProfilePanel(UbuntuOneBin): |
459 | """The Profile Tab Panel widget""" |
460 | |
461 | ui_class = profile_ui |
462 | |
463 | + @defer.inlineCallbacks |
464 | def load(self): |
465 | """Load info.""" |
466 | - # request account info |
467 | + self.is_processing = True |
468 | + info = yield self.backend.account_info() |
469 | + self.process_info(info) |
470 | |
471 | - def update_account_info(self, account_info): |
472 | - """Update the widgets with the account info.""" |
473 | - self.ui.fullname_lineedit.setText(account_info["name"]) |
474 | - self.ui.email_lineedit.setText(account_info["email"]) |
475 | + @log_call(logger.debug) |
476 | + def process_info(self, info): |
477 | + """Process and display the account info.""" |
478 | + self.ui.fullname_lineedit.setText(info["name"]) |
479 | + self.ui.email_lineedit.setText(info["email"]) |
480 | self.ui.password_lineedit.setText("swordfish") |
481 | |
482 | + self.is_processing = False |
483 | + |
484 | @QtCore.pyqtSlot() |
485 | def on_edit_profile_button_clicked(self): |
486 | """The edit profile button was clicked.""" |
487 | |
488 | === modified file 'ubuntuone/controlpanel/gui/qt/services.py' |
489 | --- ubuntuone/controlpanel/gui/qt/services.py 2011-06-20 22:21:30 +0000 |
490 | +++ ubuntuone/controlpanel/gui/qt/services.py 2011-06-21 22:49:26 +0000 |
491 | @@ -19,31 +19,41 @@ |
492 | """The user interface for the control panel for Ubuntu One.""" |
493 | |
494 | from gettext import gettext as _ |
495 | +from twisted.internet import defer |
496 | |
497 | # Unused import QtGui |
498 | # pylint: disable=W0611 |
499 | from PyQt4 import QtGui, QtCore |
500 | # pylint: enable=W0611 |
501 | |
502 | +from ubuntuone.controlpanel.logger import setup_logging, log_call |
503 | from ubuntuone.controlpanel.gui import EDIT_ACCOUNT_LINK |
504 | from ubuntuone.controlpanel.gui.qt import uri_hook |
505 | from ubuntuone.controlpanel.gui.qt.ubuntuonebin import UbuntuOneBin |
506 | from ubuntuone.controlpanel.gui.qt.ui import services_ui |
507 | |
508 | |
509 | +logger = setup_logging('qt.services') |
510 | + |
511 | + |
512 | class ServicesPanel(UbuntuOneBin): |
513 | """The ServicesFolders Tab Panel widget""" |
514 | |
515 | title = _('Selected plans and storage') |
516 | ui_class = services_ui |
517 | |
518 | + @defer.inlineCallbacks |
519 | def load(self): |
520 | """Load info.""" |
521 | - # request account info |
522 | + self.is_processing = True |
523 | + info = yield self.backend.account_info() |
524 | + self.process_info(info) |
525 | |
526 | - def update_account_info(self, account_info): |
527 | - """Update the widgets with the account info.""" |
528 | - self.ui.storage_plan_label.setText(account_info["type"]) |
529 | + @log_call(logger.debug) |
530 | + def process_info(self, info): |
531 | + """Process and display the account info.""" |
532 | + self.ui.storage_plan_label.setText(info["type"]) |
533 | + self.is_processing = False |
534 | |
535 | @QtCore.pyqtSlot() |
536 | def on_mobile_plan_modify_button_clicked(self): |
537 | |
538 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/__init__.py' |
539 | --- ubuntuone/controlpanel/gui/qt/tests/__init__.py 2011-06-20 22:21:30 +0000 |
540 | +++ ubuntuone/controlpanel/gui/qt/tests/__init__.py 2011-06-21 22:49:26 +0000 |
541 | @@ -100,9 +100,11 @@ |
542 | backend.UPLOAD_KEY: -1, # no limit |
543 | } |
544 | |
545 | + next_result = object() |
546 | exposed_methods = [ |
547 | 'account_info', # account |
548 | - 'devices_info', 'change_device_settings', 'remove_device', # devices |
549 | + 'devices_info', 'device_names_info', # devices |
550 | + 'change_device_settings', 'remove_device', |
551 | 'volumes_info', 'change_volume_settings', # volumes |
552 | 'create_folder', |
553 | 'replications_info', 'change_replication_settings', # replications |
554 | |
555 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py' |
556 | --- ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2011-06-16 21:02:05 +0000 |
557 | +++ ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2011-06-21 22:49:26 +0000 |
558 | @@ -19,8 +19,7 @@ |
559 | """Tests for the Control Panel.""" |
560 | |
561 | from ubuntuone.controlpanel.gui.qt import controlpanel as gui |
562 | -from ubuntuone.controlpanel.gui.qt.tests import (BaseTestCase, NO_OP, |
563 | - SAMPLE_ACCOUNT_INFO, SAMPLE_DEVICES_INFO) |
564 | +from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase |
565 | |
566 | |
567 | class ControlPanelTestCase(BaseTestCase): |
568 | @@ -30,41 +29,11 @@ |
569 | innerclass_name = "Ui_Form" |
570 | class_ui = gui.ControlPanel |
571 | |
572 | - def setUp(self): |
573 | - """Initialize this test instance.""" |
574 | - self.patch(gui.ControlPanel, "get_account_info", NO_OP) |
575 | - self.patch(gui.ControlPanel, "get_devices_info", NO_OP) |
576 | - super(ControlPanelTestCase, self).setUp() |
577 | - |
578 | def test_backend(self): |
579 | """Backend is created.""" |
580 | self.assertIsInstance(self.ui.backend, |
581 | gui.backend.ControlBackend) |
582 | |
583 | - def test_got_account_info_updates_profile(self): |
584 | - """Test the got_account_info method.""" |
585 | - self.patch(self.ui.ui.profile_tab, "update_account_info", |
586 | - self._set_called) |
587 | - self.ui.got_account_info(SAMPLE_ACCOUNT_INFO) |
588 | - expected = ((SAMPLE_ACCOUNT_INFO,), {}) |
589 | - self.assertEqual(self._called, expected) |
590 | - |
591 | - def test_got_account_info_updates_services(self): |
592 | - """Test the got_account_info method.""" |
593 | - self.patch(self.ui.ui.services_tab, "update_account_info", |
594 | - self._set_called) |
595 | - self.ui.got_account_info(SAMPLE_ACCOUNT_INFO) |
596 | - expected = ((SAMPLE_ACCOUNT_INFO,), {}) |
597 | - self.assertEqual(self._called, expected) |
598 | - |
599 | - def test_got_devices_info_updates_devices(self): |
600 | - """Test the got_device_info method.""" |
601 | - self.patch(self.ui.ui.devices_tab, "update_devices_info", |
602 | - self._set_called) |
603 | - self.ui.got_devices_info(SAMPLE_DEVICES_INFO) |
604 | - expected = ((SAMPLE_DEVICES_INFO,), {}) |
605 | - self.assertEqual(self._called, expected) |
606 | - |
607 | def test_get_more_space_button(self): |
608 | """When clicking the get more GB button, the proper url is opened.""" |
609 | self.patch(gui, 'uri_hook', self._set_called) |
610 | |
611 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_devices.py' |
612 | --- ubuntuone/controlpanel/gui/qt/tests/test_devices.py 2011-06-20 23:23:45 +0000 |
613 | +++ ubuntuone/controlpanel/gui/qt/tests/test_devices.py 2011-06-21 22:49:26 +0000 |
614 | @@ -18,6 +18,8 @@ |
615 | |
616 | """Tests for the devices tab.""" |
617 | |
618 | +from twisted.internet import defer |
619 | + |
620 | from ubuntuone.controlpanel.gui.qt import devices as gui |
621 | from ubuntuone.controlpanel.gui.qt.tests import ( |
622 | SAMPLE_DEVICES_INFO, |
623 | @@ -34,24 +36,61 @@ |
624 | innerclass_name = "Ui_Form" |
625 | class_ui = gui.DevicesPanel |
626 | |
627 | + @defer.inlineCallbacks |
628 | + def setUp(self): |
629 | + yield super(DevicesPanelTestCase, self).setUp() |
630 | + self.ui.backend.next_result = SAMPLE_DEVICES_INFO |
631 | + |
632 | def test_is_processing_while_asking_info(self): |
633 | """The ui is processing while the contents are loaded.""" |
634 | def check(): |
635 | """The ui must be is_processing.""" |
636 | self.assertTrue(self.ui.is_processing, 'ui must be processing') |
637 | + return SAMPLE_DEVICES_INFO |
638 | |
639 | - self.patch(self.ui.backend, 'devices_info', check) |
640 | + self.patch(self.ui.backend, 'device_names_info', check) |
641 | |
642 | return self.ui.load() # trigger the info request |
643 | |
644 | - def test_update_devices_info(self): |
645 | - """The widget is updated with the info.""" |
646 | - container = self.ui.ui.devices_list_verticallayout |
647 | - self.assertEqual(container.count(), 0) |
648 | - self.ui.update_devices_info(SAMPLE_DEVICES_INFO) |
649 | - expected_name = SAMPLE_DEVICES_INFO[0]["name"] |
650 | - self.assertEqual(self.ui.ui.device_name_label.text(), expected_name) |
651 | - self.assertEqual(container.count(), len(SAMPLE_DEVICES_INFO) - 1) |
652 | + def test_is_not_processing_after_info_ready(self): |
653 | + """The ui is not processing when contents are load.""" |
654 | + self.ui.process_info(SAMPLE_DEVICES_INFO) |
655 | + |
656 | + self.assertFalse(self.ui.is_processing) |
657 | + |
658 | + @defer.inlineCallbacks |
659 | + def test_info_is_requested_on_load(self): |
660 | + """The info is requested to the backend.""" |
661 | + yield self.ui.load() |
662 | + self.assert_backend_called('device_names_info') |
663 | + |
664 | + def test_no_devices_at_startup(self): |
665 | + """The UI is reset at startup.""" |
666 | + self.assertEqual(self.ui.ui.remote_devices_box.count(), 0) |
667 | + self.assertEqual(self.ui.ui.local_device_box.count(), 0) |
668 | + |
669 | + def test_process_info(self): |
670 | + """The widget is updated with the info.""" |
671 | + self.ui.process_info(SAMPLE_DEVICES_INFO) |
672 | + |
673 | + local, remote = SAMPLE_DEVICES_INFO[0], SAMPLE_DEVICES_INFO[1:] |
674 | + |
675 | + self.assertEqual(self.ui.ui.local_device_box.count(), 1) |
676 | + local_device = self.ui.ui.local_device_box.itemAt(0) |
677 | + self.assertEqual(local_device.widget().ui.device_name_label.text(), |
678 | + local['name']) |
679 | + |
680 | + self.assertEqual(self.ui.ui.remote_devices_box.count(), |
681 | + len(remote)) |
682 | + for i, remote_device in enumerate(remote): |
683 | + device = self.ui.ui.remote_devices_box.itemAt(i) |
684 | + self.assertEqual(device.widget().ui.device_name_label.text(), |
685 | + remote_device['name']) |
686 | + |
687 | + def test_process_info_twice(self): |
688 | + """The widget is updated with the info.""" |
689 | + self.test_process_info() |
690 | + self.test_process_info() |
691 | |
692 | def test_manage_devices_button(self): |
693 | """Clicking the manage devices button opens the proper url.""" |
694 | |
695 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py' |
696 | --- ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2011-06-17 20:08:02 +0000 |
697 | +++ ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2011-06-21 22:49:26 +0000 |
698 | @@ -53,7 +53,7 @@ |
699 | expected_text = status_ui + ' (' + msg_bd + ')' |
700 | |
701 | status = {backend.STATUS_KEY: status_bd, backend.MSG_KEY: msg_bd} |
702 | - self.ui.process_status(status) |
703 | + self.ui.process_info(status) |
704 | |
705 | actual_text = self.ui.ui.sync_status_label.text() |
706 | msg = '%r does not end with %r' % (actual_text, expected_text) |
707 | @@ -76,16 +76,16 @@ |
708 | self.assertIsInstance(self.ui.backend, |
709 | backend.ControlBackend) |
710 | |
711 | - def test_process_status_changed(self): |
712 | + def test_process_info_changed(self): |
713 | """Backend's file sync status changed callback is connected.""" |
714 | self.assertEqual(self.ui.backend.status_changed_handler, |
715 | - self.ui.process_status) |
716 | + self.ui.process_info) |
717 | |
718 | - def test_file_sync_status_is_requested_on_show(self): |
719 | + def test_file_sync_status_is_requested_on_load(self): |
720 | """The file sync status is requested to the backend.""" |
721 | self.assert_backend_called('file_sync_status') |
722 | |
723 | - def test_process_status_disabled(self): |
724 | + def test_process_info_disabled(self): |
725 | """File sync status disabled update the label.""" |
726 | self.assert_status_correct(status_bd=backend.FILE_SYNC_DISABLED, |
727 | status_ui=gui.FILE_SYNC_DISABLED, |
728 | @@ -93,7 +93,7 @@ |
729 | callback='enable_files', |
730 | tooltip=gui.FILE_SYNC_ENABLE_TOOLTIP) |
731 | |
732 | - def test_process_status_disconnected(self): |
733 | + def test_process_info_disconnected(self): |
734 | """File sync status disconnected update the label.""" |
735 | self.assert_status_correct(status_bd=backend.FILE_SYNC_DISCONNECTED, |
736 | status_ui=gui.FILE_SYNC_DISCONNECTED, |
737 | @@ -101,7 +101,7 @@ |
738 | callback='connect_files', |
739 | tooltip=gui.FILE_SYNC_CONNECT_TOOLTIP) |
740 | |
741 | - def test_process_status_error(self): |
742 | + def test_process_info_error(self): |
743 | """File sync status error update the label.""" |
744 | msg = gui.WARNING_MARKUP % gui.FILE_SYNC_ERROR |
745 | self.assert_status_correct(status_bd=backend.FILE_SYNC_ERROR, |
746 | @@ -111,7 +111,7 @@ |
747 | callback='restart_files', |
748 | tooltip=gui.FILE_SYNC_RESTART_TOOLTIP) |
749 | |
750 | - def test_process_status_idle(self): |
751 | + def test_process_info_idle(self): |
752 | """File sync status idle update the label.""" |
753 | self.assert_status_correct(status_bd=backend.FILE_SYNC_IDLE, |
754 | status_ui=gui.FILE_SYNC_IDLE, |
755 | @@ -119,7 +119,7 @@ |
756 | callback='disconnect_files', |
757 | tooltip=gui.FILE_SYNC_DISCONNECT_TOOLTIP) |
758 | |
759 | - def test_process_status_starting(self): |
760 | + def test_process_info_starting(self): |
761 | """File sync status starting update the label.""" |
762 | self.assert_status_correct(status_bd=backend.FILE_SYNC_STARTING, |
763 | status_ui=gui.FILE_SYNC_STARTING, |
764 | @@ -127,7 +127,7 @@ |
765 | callback='stop_files', |
766 | tooltip=gui.FILE_SYNC_STOP_TOOLTIP) |
767 | |
768 | - def test_process_status_stopped(self): |
769 | + def test_process_info_stopped(self): |
770 | """File sync status stopped update the label.""" |
771 | self.assert_status_correct(status_bd=backend.FILE_SYNC_STOPPED, |
772 | status_ui=gui.FILE_SYNC_STOPPED, |
773 | @@ -135,7 +135,7 @@ |
774 | callback='start_files', |
775 | tooltip=gui.FILE_SYNC_START_TOOLTIP) |
776 | |
777 | - def test_process_status_syncing(self): |
778 | + def test_process_info_syncing(self): |
779 | """File sync status syncing update the label.""" |
780 | self.assert_status_correct(status_bd=backend.FILE_SYNC_SYNCING, |
781 | status_ui=gui.FILE_SYNC_SYNCING, |
782 | @@ -143,7 +143,7 @@ |
783 | callback='disconnect_files', |
784 | tooltip=gui.FILE_SYNC_DISCONNECT_TOOLTIP) |
785 | |
786 | - def test_process_status_unknown(self): |
787 | + def test_process_info_unknown(self): |
788 | """File sync status unknown update the label.""" |
789 | msg = gui.WARNING_MARKUP % gui.FILE_SYNC_ERROR |
790 | self.assert_status_correct(status_bd=backend.FILE_SYNC_UNKNOWN, |
791 | |
792 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_folders.py' |
793 | --- ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2011-06-21 14:43:31 +0000 |
794 | +++ ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2011-06-21 22:49:26 +0000 |
795 | @@ -55,6 +55,8 @@ |
796 | @defer.inlineCallbacks |
797 | def setUp(self): |
798 | yield super(FoldersPanelTestCase, self).setUp() |
799 | + self.ui.backend.next_result = FAKE_VOLUMES_MINIMAL_INFO |
800 | + |
801 | self.memento = MementoHandler() |
802 | self.memento.setLevel(logging.DEBUG) |
803 | gui.logger.addHandler(self.memento) |
804 | @@ -78,6 +80,7 @@ |
805 | def check(): |
806 | """The ui must be is_processing.""" |
807 | self.assertTrue(self.ui.is_processing, 'ui must be processing') |
808 | + return FAKE_VOLUMES_MINIMAL_INFO |
809 | |
810 | self.patch(self.ui.backend, 'volumes_info', check) |
811 | |
812 | @@ -85,17 +88,17 @@ |
813 | |
814 | def test_is_not_processing_after_info_ready(self): |
815 | """The ui is not processing when contents are load.""" |
816 | - self.ui.process_folders(FAKE_VOLUMES_INFO) |
817 | + self.ui.process_info(FAKE_VOLUMES_INFO) |
818 | |
819 | self.assertFalse(self.ui.is_processing) |
820 | |
821 | - def test_volumes_info_is_requested_on_show(self): |
822 | + def test_info_is_requested_on_load(self): |
823 | """The volumes info is requested to the backend.""" |
824 | self.assert_backend_called('volumes_info') |
825 | |
826 | - def test_process_folders(self): |
827 | + def test_process_info(self): |
828 | """The volumes info is processed when ready.""" |
829 | - self.ui.process_folders(FAKE_VOLUMES_INFO) |
830 | + self.ui.process_info(FAKE_VOLUMES_INFO) |
831 | folders = self.ui.ui.folders |
832 | |
833 | root = folders.invisibleRootItem() |
834 | @@ -166,24 +169,24 @@ |
835 | # skip the empty row |
836 | treeiter += 1 |
837 | |
838 | - def test_process_folders_clears_the_list(self): |
839 | + def test_process_info_clears_the_list(self): |
840 | """The old volumes info is cleared before updated.""" |
841 | - self.ui.process_folders(FAKE_VOLUMES_INFO) |
842 | - self.ui.process_folders(FAKE_VOLUMES_INFO) |
843 | + self.ui.process_info(FAKE_VOLUMES_INFO) |
844 | + self.ui.process_info(FAKE_VOLUMES_INFO) |
845 | |
846 | root = self.ui.ui.folders.invisibleRootItem() |
847 | self.assertEqual(len(FAKE_VOLUMES_INFO) + 1, root.childCount()) |
848 | |
849 | - def test_process_folders_with_no_volumes(self): |
850 | + def test_process_info_with_no_volumes(self): |
851 | """When there are no volumes, a notification is shown.""" |
852 | - self.ui.process_folders([]) |
853 | + self.ui.process_info([]) |
854 | |
855 | root = self.ui.ui.folders.invisibleRootItem() |
856 | self.assertEqual(root.childCount(), 0) |
857 | |
858 | - def test_process_folders_highlights_little_free_space(self): |
859 | + def test_process_info_highlights_little_free_space(self): |
860 | """The free space is red if is zero (or close to 0).""" |
861 | - self.ui.process_folders(FAKE_VOLUMES_NO_FREE_SPACE_INFO) |
862 | + self.ui.process_info(FAKE_VOLUMES_NO_FREE_SPACE_INFO) |
863 | folders = self.ui.ui.folders |
864 | |
865 | child_index = 0 |
866 | @@ -208,7 +211,7 @@ |
867 | self.assertTrue(item.is_empty) |
868 | child_index += 1 |
869 | |
870 | - def test_process_folders_handles_no_quota_info(self): |
871 | + def test_process_info_handles_no_quota_info(self): |
872 | """The lack of free space is handled.""" |
873 | info = [ |
874 | (u'', self.ui.backend.FREE_BYTES_NOT_AVAILABLE, [ROOT]), |
875 | @@ -218,7 +221,7 @@ |
876 | u'path': u'full-share', u'subscribed': u'', |
877 | u'type': self.ui.backend.SHARE_TYPE}]), |
878 | ] |
879 | - self.ui.process_folders(info) |
880 | + self.ui.process_info(info) |
881 | folders = self.ui.ui.folders |
882 | |
883 | child_index = 0 |
884 | @@ -279,9 +282,9 @@ |
885 | self.assertTrue(self.memento.check_warning(path, 'does not exist')) |
886 | self.assertEqual(self._called, False) |
887 | |
888 | - def test_process_folders_with_music_folder(self): |
889 | + def test_process_info_with_music_folder(self): |
890 | """The volumes info is processed when ready.""" |
891 | - self.ui.process_folders(FAKE_VOLUMES_MINIMAL_INFO) |
892 | + self.ui.process_info(FAKE_VOLUMES_MINIMAL_INFO) |
893 | folders = self.ui.ui.folders |
894 | |
895 | treeiter = gui.QtGui.QTreeWidgetItemIterator(folders) |
896 | @@ -323,7 +326,7 @@ |
897 | def setUp(self): |
898 | yield super(FoldersPanelAddFolderTestCase, self).setUp() |
899 | # simulate volumes info properly processed |
900 | - self.ui.process_folders([]) |
901 | + self.ui.process_info([]) |
902 | # reset backend state |
903 | self.ui.backend._called.clear() |
904 | |
905 | @@ -384,7 +387,7 @@ |
906 | @defer.inlineCallbacks |
907 | def test_opens_warning_if_folder_inside_root(self): |
908 | """If the user chooses a folder inside the root, show a warning.""" |
909 | - self.ui.process_folders(FAKE_VOLUMES_MINIMAL_INFO) |
910 | + self.ui.process_info(FAKE_VOLUMES_MINIMAL_INFO) |
911 | root_path = ROOT['path'] |
912 | # create a valid path inside the root |
913 | inside_root = os.path.abspath(os.path.join(root_path, 'test')) |
914 | @@ -403,7 +406,7 @@ |
915 | @defer.inlineCallbacks |
916 | def test_opens_warning_if_folder_inside_an_udf(self): |
917 | """If the user chooses a folder inside an UDF, show a warning.""" |
918 | - self.ui.process_folders(FAKE_VOLUMES_MINIMAL_INFO) |
919 | + self.ui.process_info(FAKE_VOLUMES_MINIMAL_INFO) |
920 | udf_path = MUSIC_FOLDER['path'] |
921 | # create a valid path inside an existing UDF |
922 | inside_udf = os.path.abspath(os.path.join(udf_path, 'test')) |
923 | @@ -427,7 +430,7 @@ |
924 | outside every UDF, do not show a warning and call backend. |
925 | |
926 | """ |
927 | - self.ui.process_folders(FAKE_VOLUMES_MINIMAL_INFO) |
928 | + self.ui.process_info(FAKE_VOLUMES_MINIMAL_INFO) |
929 | tricky_path = ROOT['path'] |
930 | assert not tricky_path.endswith(os.path.sep) |
931 | tricky_path += ' Suffix' |
932 | @@ -510,7 +513,7 @@ |
933 | FakedConfirmDialog.kwargs = None |
934 | self.patch(gui.QtGui, 'QMessageBox', FakedConfirmDialog) |
935 | |
936 | - self.ui.process_folders(FAKE_VOLUMES_MINIMAL_INFO) |
937 | + self.ui.process_info(FAKE_VOLUMES_MINIMAL_INFO) |
938 | # the music folder |
939 | self.item = self.ui.ui.folders.topLevelItem(0).child(1) |
940 | |
941 | |
942 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_gui.py' |
943 | --- ubuntuone/controlpanel/gui/qt/tests/test_gui.py 2011-05-28 00:45:18 +0000 |
944 | +++ ubuntuone/controlpanel/gui/qt/tests/test_gui.py 2011-06-21 22:49:26 +0000 |
945 | @@ -19,7 +19,7 @@ |
946 | """Tests for the Qt UI.""" |
947 | |
948 | from ubuntuone.controlpanel.gui.qt import gui |
949 | -from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase, NO_OP |
950 | +from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase |
951 | |
952 | |
953 | class MainWindowTestCase(BaseTestCase): |
954 | @@ -29,11 +29,6 @@ |
955 | innerclass_name = "Ui_MainWindow" |
956 | class_ui = gui.MainWindow |
957 | |
958 | - def setUp(self): |
959 | - """Initialize this test instance.""" |
960 | - self.patch(gui.mainwindow_ui.ControlPanel, "get_account_info", NO_OP) |
961 | - super(MainWindowTestCase, self).setUp() |
962 | - |
963 | def test_close_event_calls_custom_close_callback(self): |
964 | """When closing the window, close_callback is called.""" |
965 | self.ui.close_callback = self._set_called |
966 | |
967 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_preferences.py' |
968 | --- ubuntuone/controlpanel/gui/qt/tests/test_preferences.py 2011-06-20 23:23:45 +0000 |
969 | +++ ubuntuone/controlpanel/gui/qt/tests/test_preferences.py 2011-06-21 22:49:26 +0000 |
970 | @@ -30,6 +30,15 @@ |
971 | # Access to a protected member |
972 | # pylint: disable=W0212 |
973 | |
974 | +SAMPLE_SETTINGS = { |
975 | + gui.backend.AUTOCONNECT_KEY: True, |
976 | + gui.backend.SHOW_ALL_NOTIFICATIONS_KEY: True, |
977 | + gui.backend.SHARE_AUTOSUBSCRIBE_KEY: True, |
978 | + gui.backend.UDF_AUTOSUBSCRIBE_KEY: True, |
979 | + gui.backend.DOWNLOAD_KEY: 20480, |
980 | + gui.backend.UPLOAD_KEY: 2048, |
981 | +} |
982 | + |
983 | |
984 | class PreferencesPanelTestCase(UbuntuOneBinTestCase): |
985 | """Test the qt cloud preferences tab.""" |
986 | @@ -41,6 +50,7 @@ |
987 | @defer.inlineCallbacks |
988 | def setUp(self): |
989 | yield super(PreferencesPanelTestCase, self).setUp() |
990 | + self.ui.backend.next_result = SAMPLE_SETTINGS |
991 | yield self.ui.load() |
992 | |
993 | def test_is_processing_while_asking_info(self): |
994 | @@ -53,8 +63,8 @@ |
995 | |
996 | yield self.ui.load() # trigger the info request |
997 | |
998 | - def test_file_sync_settings_info_is_requested(self): |
999 | - """The file_sync_settings info is requested to the backend.""" |
1000 | + def test_info_is_requested_on_load(self): |
1001 | + """The info is requested to the backend.""" |
1002 | self.assert_backend_called('file_sync_settings_info') |
1003 | |
1004 | def _test_update_ui_from_settings_info(self, settings): |
1005 | @@ -87,16 +97,8 @@ |
1006 | |
1007 | def test_update_ui_from_backed_info(self): |
1008 | """The ui is correctly updated when the backend info is received.""" |
1009 | - settings = { |
1010 | - gui.backend.AUTOCONNECT_KEY: True, |
1011 | - gui.backend.SHOW_ALL_NOTIFICATIONS_KEY: True, |
1012 | - gui.backend.SHARE_AUTOSUBSCRIBE_KEY: True, |
1013 | - gui.backend.UDF_AUTOSUBSCRIBE_KEY: True, |
1014 | - gui.backend.DOWNLOAD_KEY: 20480, |
1015 | - gui.backend.UPLOAD_KEY: 2048, |
1016 | - } |
1017 | - self.ui.process_settings(settings) |
1018 | - self._test_update_ui_from_settings_info(settings) |
1019 | + self.ui.process_info(SAMPLE_SETTINGS) |
1020 | + self._test_update_ui_from_settings_info(SAMPLE_SETTINGS) |
1021 | |
1022 | def _test_speed_checkbox_value_changed_to_positive(self, speed_spinbox, |
1023 | limit_checkbox): |
1024 | |
1025 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_profile.py' |
1026 | --- ubuntuone/controlpanel/gui/qt/tests/test_profile.py 2011-06-20 23:23:45 +0000 |
1027 | +++ ubuntuone/controlpanel/gui/qt/tests/test_profile.py 2011-06-21 22:49:26 +0000 |
1028 | @@ -18,6 +18,8 @@ |
1029 | |
1030 | """Tests for the profile tab.""" |
1031 | |
1032 | +from twisted.internet import defer |
1033 | + |
1034 | from ubuntuone.controlpanel.gui.qt import profile as gui |
1035 | from ubuntuone.controlpanel.gui.qt.tests import ( |
1036 | SAMPLE_ACCOUNT_INFO, SAMPLE_EMAIL, SAMPLE_NAME, |
1037 | @@ -34,19 +36,37 @@ |
1038 | innerclass_name = "Ui_Form" |
1039 | class_ui = gui.ProfilePanel |
1040 | |
1041 | + @defer.inlineCallbacks |
1042 | + def setUp(self): |
1043 | + yield super(ProfilePanelTestCase, self).setUp() |
1044 | + self.ui.backend.next_result = SAMPLE_ACCOUNT_INFO |
1045 | + |
1046 | def test_is_processing_while_asking_info(self): |
1047 | """The ui is processing while the contents are loaded.""" |
1048 | def check(): |
1049 | """The ui must be is_processing.""" |
1050 | self.assertTrue(self.ui.is_processing, 'ui must be processing') |
1051 | + return SAMPLE_ACCOUNT_INFO |
1052 | |
1053 | self.patch(self.ui.backend, 'account_info', check) |
1054 | |
1055 | return self.ui.load() # trigger the info request |
1056 | |
1057 | - def test_update_account_info(self): |
1058 | + def test_is_not_processing_after_info_ready(self): |
1059 | + """The ui is not processing when contents are load.""" |
1060 | + self.ui.process_info(SAMPLE_ACCOUNT_INFO) |
1061 | + |
1062 | + self.assertFalse(self.ui.is_processing) |
1063 | + |
1064 | + @defer.inlineCallbacks |
1065 | + def test_info_is_requested_on_load(self): |
1066 | + """The info is requested to the backend.""" |
1067 | + yield self.ui.load() |
1068 | + self.assert_backend_called('account_info') |
1069 | + |
1070 | + def test_process_info(self): |
1071 | """Backend's file sync status changed callback is connected.""" |
1072 | - self.ui.update_account_info(SAMPLE_ACCOUNT_INFO) |
1073 | + self.ui.process_info(SAMPLE_ACCOUNT_INFO) |
1074 | self.assertEqual(self.ui.ui.fullname_lineedit.text(), SAMPLE_NAME) |
1075 | self.assertEqual(self.ui.ui.email_lineedit.text(), SAMPLE_EMAIL) |
1076 | self.assertEqual(self.ui.ui.password_lineedit.text(), "swordfish") |
1077 | |
1078 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_services.py' |
1079 | --- ubuntuone/controlpanel/gui/qt/tests/test_services.py 2011-06-20 23:23:45 +0000 |
1080 | +++ ubuntuone/controlpanel/gui/qt/tests/test_services.py 2011-06-21 22:49:26 +0000 |
1081 | @@ -18,6 +18,8 @@ |
1082 | |
1083 | """Tests for the services tab.""" |
1084 | |
1085 | +from twisted.internet import defer |
1086 | + |
1087 | from ubuntuone.controlpanel.gui.qt import services as gui |
1088 | from ubuntuone.controlpanel.gui.qt.tests import ( |
1089 | SAMPLE_ACCOUNT_INFO, SAMPLE_PLAN, |
1090 | @@ -34,19 +36,37 @@ |
1091 | innerclass_name = "Ui_Form" |
1092 | class_ui = gui.ServicesPanel |
1093 | |
1094 | + @defer.inlineCallbacks |
1095 | + def setUp(self): |
1096 | + yield super(ServicesPanelTestCase, self).setUp() |
1097 | + self.ui.backend.next_result = SAMPLE_ACCOUNT_INFO |
1098 | + |
1099 | def test_is_processing_while_asking_info(self): |
1100 | """The ui is processing while the contents are loaded.""" |
1101 | def check(): |
1102 | """The ui must be is_processing.""" |
1103 | self.assertTrue(self.ui.is_processing, 'ui must be processing') |
1104 | + return SAMPLE_ACCOUNT_INFO |
1105 | |
1106 | self.patch(self.ui.backend, 'account_info', check) |
1107 | |
1108 | return self.ui.load() # trigger the info request |
1109 | |
1110 | - def test_update_account_info(self): |
1111 | + def test_is_not_processing_after_info_ready(self): |
1112 | + """The ui is not processing when contents are load.""" |
1113 | + self.ui.process_info(SAMPLE_ACCOUNT_INFO) |
1114 | + |
1115 | + self.assertFalse(self.ui.is_processing) |
1116 | + |
1117 | + @defer.inlineCallbacks |
1118 | + def test_info_is_requested_on_load(self): |
1119 | + """The info is requested to the backend.""" |
1120 | + yield self.ui.load() |
1121 | + self.assert_backend_called('account_info') |
1122 | + |
1123 | + def test_process_info(self): |
1124 | """Backend's file sync status changed callback is connected.""" |
1125 | - self.ui.update_account_info(SAMPLE_ACCOUNT_INFO) |
1126 | + self.ui.process_info(SAMPLE_ACCOUNT_INFO) |
1127 | self.assertEqual(self.ui.ui.storage_plan_label.text(), SAMPLE_PLAN) |
1128 | |
1129 | def test_mobile_plan_modify_button(self): |
1130 | |
1131 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_ubuntuonebin.py' |
1132 | --- ubuntuone/controlpanel/gui/qt/tests/test_ubuntuonebin.py 2011-06-21 14:43:31 +0000 |
1133 | +++ ubuntuone/controlpanel/gui/qt/tests/test_ubuntuonebin.py 2011-06-21 22:49:26 +0000 |
1134 | @@ -30,10 +30,6 @@ |
1135 | |
1136 | class_ui = gui.UbuntuOneBin |
1137 | |
1138 | - def setUp(self): |
1139 | - super(UbuntuOneBinTestCase, self).setUp() |
1140 | - self.ui.show() # need to show to test widgets visibility |
1141 | - |
1142 | def test_backend(self): |
1143 | """Backend is created.""" |
1144 | self.assertIsInstance(self.ui.backend, |
1145 | @@ -61,13 +57,19 @@ |
1146 | |
1147 | def test_is_enabled_if_not_processing(self): |
1148 | """If not processing, the UI is enabled.""" |
1149 | + self.ui.show() # need to show to test widgets visibility |
1150 | + |
1151 | self.ui.is_processing = False |
1152 | + |
1153 | self.assertTrue(self.ui.isEnabled()) |
1154 | self.assertFalse(self.ui.bin_ui.spinner.isVisible()) |
1155 | |
1156 | def test_is_not_enabled_if_processing(self): |
1157 | """If processing, the UI is disabled.""" |
1158 | + self.ui.show() # need to show to test widgets visibility |
1159 | + |
1160 | self.ui.is_processing = True |
1161 | + |
1162 | self.assertFalse(self.ui.isEnabled()) |
1163 | self.assertTrue(self.ui.bin_ui.spinner.isVisible()) |
1164 | |
1165 | |
1166 | === modified file 'ubuntuone/controlpanel/gui/tests/__init__.py' |
1167 | --- ubuntuone/controlpanel/gui/tests/__init__.py 2011-06-01 21:18:46 +0000 |
1168 | +++ ubuntuone/controlpanel/gui/tests/__init__.py 2011-06-21 22:49:26 +0000 |
1169 | @@ -116,6 +116,7 @@ |
1170 | class FakedObject(object): |
1171 | """Fake an object, record every call.""" |
1172 | |
1173 | + next_result = None |
1174 | exposed_methods = [] |
1175 | |
1176 | def __init__(self, *args, **kwargs): |
1177 | @@ -131,5 +132,6 @@ |
1178 | def inner(*args, **kwargs): |
1179 | """Fake 'func_name'.""" |
1180 | self._called[func_name] = (args, kwargs) |
1181 | + return self.next_result |
1182 | |
1183 | return inner |
Works as advertised.