Merge lp:~nataliabidart/ubuntuone-control-panel/preferences into lp:ubuntuone-control-panel
- preferences
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||
Approved revision: | 169 | ||||
Merged at revision: | 163 | ||||
Proposed branch: | lp:~nataliabidart/ubuntuone-control-panel/preferences | ||||
Merge into: | lp:ubuntuone-control-panel | ||||
Diff against target: |
1391 lines (+839/-131) 13 files modified
data/qt/preferences.ui (+89/-63) ubuntuone/controlpanel/backend.py (+109/-15) ubuntuone/controlpanel/gui/qt/folders.py (+3/-2) ubuntuone/controlpanel/gui/qt/main/linux.py (+8/-0) ubuntuone/controlpanel/gui/qt/preferences.py (+107/-1) ubuntuone/controlpanel/gui/qt/tests/__init__.py (+14/-7) ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py (+1/-1) ubuntuone/controlpanel/gui/qt/tests/test_folders.py (+2/-2) ubuntuone/controlpanel/gui/qt/tests/test_preferences.py (+165/-0) ubuntuone/controlpanel/integrationtests/test_sd_client/test_linux.py (+84/-25) ubuntuone/controlpanel/sd_client/linux.py (+45/-0) ubuntuone/controlpanel/tests/__init__.py (+3/-0) ubuntuone/controlpanel/tests/test_backend.py (+209/-15) |
||||
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-control-panel/preferences | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Review via email: mp+64883@code.launchpad.net |
Commit message
- Implemented the "Preferences" tab (LP: #797294).
Description of the change
To test this branch, please run the tests for both widget sets:
./run-tests
./run-tests -qt
To test IRL, please run from within this branch:
DEBUG=True PYTHONPATH=. ./bin/ubuntuone
then go to the preferences tab and play with the settings (please note that initial settings are fake). When clicking apply, you should see in the terminal something like:
2011-06-16 15:23:58,688 - ubuntuone.
When restoring to defaults, you should get autoconnect and show notifications enabled, autosubscribe disabled x 2 and no limit for throttling.
John Lenton (chipaca) : | # |
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
- 169. By Natalia Bidart
-
Merged trunk in.
Preview Diff
1 | === modified file 'data/qt/preferences.ui' | |||
2 | --- data/qt/preferences.ui 2011-05-23 21:24:08 +0000 | |||
3 | +++ data/qt/preferences.ui 2011-06-17 14:51:05 +0000 | |||
4 | @@ -15,64 +15,90 @@ | |||
5 | 15 | </property> | 15 | </property> |
6 | 16 | <layout class="QVBoxLayout" name="verticalLayout_2"> | 16 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
7 | 17 | <item> | 17 | <item> |
66 | 18 | <widget class="QLabel" name="tab_header_label"> | 18 | <widget class="QGroupBox" name="verticalGroupBox"> |
67 | 19 | <property name="text"> | 19 | <layout class="QVBoxLayout" name="verticalLayout_4"> |
68 | 20 | <string>(empty)</string> | 20 | <item> |
69 | 21 | </property> | 21 | <widget class="QGroupBox" name="groupBox"> |
70 | 22 | </widget> | 22 | <property name="title"> |
71 | 23 | </item> | 23 | <string>Bandwidth settings</string> |
72 | 24 | <item> | 24 | </property> |
73 | 25 | <widget class="QGroupBox" name="groupBox"> | 25 | <layout class="QGridLayout" name="gridLayout"> |
74 | 26 | <property name="title"> | 26 | <item row="0" column="0"> |
75 | 27 | <string>Bandwidth settings</string> | 27 | <widget class="QCheckBox" name="limit_uploads_checkbox"> |
76 | 28 | </property> | 28 | <property name="text"> |
77 | 29 | <layout class="QGridLayout" name="gridLayout"> | 29 | <string>Limit upload speed to</string> |
78 | 30 | <item row="0" column="0"> | 30 | </property> |
79 | 31 | <widget class="QCheckBox" name="limit_uploads_checkbox"> | 31 | </widget> |
80 | 32 | <property name="text"> | 32 | </item> |
81 | 33 | <string>Limit upload speed to</string> | 33 | <item row="0" column="1"> |
82 | 34 | </property> | 34 | <widget class="QSpinBox" name="upload_speed_spinbox"> |
83 | 35 | </widget> | 35 | <property name="minimum"> |
84 | 36 | </item> | 36 | <number>-1</number> |
85 | 37 | <item row="0" column="1"> | 37 | </property> |
86 | 38 | <widget class="QSpinBox" name="upload_speed_spinbox"/> | 38 | <property name="maximum"> |
87 | 39 | </item> | 39 | <number>999999999</number> |
88 | 40 | <item row="0" column="2"> | 40 | </property> |
89 | 41 | <widget class="QLabel" name="kbps_label_1"> | 41 | </widget> |
90 | 42 | <property name="text"> | 42 | </item> |
91 | 43 | <string>Kilobits per second</string> | 43 | <item row="0" column="2"> |
92 | 44 | </property> | 44 | <widget class="QLabel" name="kbps_label_1"> |
93 | 45 | </widget> | 45 | <property name="text"> |
94 | 46 | </item> | 46 | <string>Kilobits per second</string> |
95 | 47 | <item row="1" column="0"> | 47 | </property> |
96 | 48 | <widget class="QCheckBox" name="limit_downloads_checkbox"> | 48 | </widget> |
97 | 49 | <property name="text"> | 49 | </item> |
98 | 50 | <string>Limit download speed to</string> | 50 | <item row="2" column="0"> |
99 | 51 | </property> | 51 | <widget class="QCheckBox" name="limit_downloads_checkbox"> |
100 | 52 | </widget> | 52 | <property name="text"> |
101 | 53 | </item> | 53 | <string>Limit download speed to</string> |
102 | 54 | <item row="1" column="1"> | 54 | </property> |
103 | 55 | <widget class="QSpinBox" name="download_speed_spinbox"/> | 55 | </widget> |
104 | 56 | </item> | 56 | </item> |
105 | 57 | <item row="1" column="2"> | 57 | <item row="2" column="1"> |
106 | 58 | <widget class="QLabel" name="kbps_label_2"> | 58 | <widget class="QSpinBox" name="download_speed_spinbox"> |
107 | 59 | <property name="text"> | 59 | <property name="minimum"> |
108 | 60 | <string>Kilobits per second</string> | 60 | <number>-1</number> |
109 | 61 | </property> | 61 | </property> |
110 | 62 | </widget> | 62 | <property name="maximum"> |
111 | 63 | </item> | 63 | <number>999999999</number> |
112 | 64 | <item row="0" column="3"> | 64 | </property> |
113 | 65 | <spacer name="horizontalSpacer_2"> | 65 | </widget> |
114 | 66 | <property name="orientation"> | 66 | </item> |
115 | 67 | <enum>Qt::Horizontal</enum> | 67 | <item row="2" column="2"> |
116 | 68 | </property> | 68 | <widget class="QLabel" name="kbps_label_2"> |
117 | 69 | <property name="sizeHint" stdset="0"> | 69 | <property name="text"> |
118 | 70 | <size> | 70 | <string>Kilobits per second</string> |
119 | 71 | <width>40</width> | 71 | </property> |
120 | 72 | <height>20</height> | 72 | </widget> |
121 | 73 | </size> | 73 | </item> |
122 | 74 | </property> | 74 | <item row="0" column="3"> |
123 | 75 | </spacer> | 75 | <spacer name="horizontalSpacer_2"> |
124 | 76 | <property name="orientation"> | ||
125 | 77 | <enum>Qt::Horizontal</enum> | ||
126 | 78 | </property> | ||
127 | 79 | <property name="sizeHint" stdset="0"> | ||
128 | 80 | <size> | ||
129 | 81 | <width>40</width> | ||
130 | 82 | <height>20</height> | ||
131 | 83 | </size> | ||
132 | 84 | </property> | ||
133 | 85 | </spacer> | ||
134 | 86 | </item> | ||
135 | 87 | <item row="3" column="0" colspan="3"> | ||
136 | 88 | <widget class="QLabel" name="label_2"> | ||
137 | 89 | <property name="text"> | ||
138 | 90 | <string>Please note that your files will not sync if you set bandwidth to 0</string> | ||
139 | 91 | </property> | ||
140 | 92 | <property name="scaledContents"> | ||
141 | 93 | <bool>false</bool> | ||
142 | 94 | </property> | ||
143 | 95 | <property name="wordWrap"> | ||
144 | 96 | <bool>false</bool> | ||
145 | 97 | </property> | ||
146 | 98 | </widget> | ||
147 | 99 | </item> | ||
148 | 100 | </layout> | ||
149 | 101 | </widget> | ||
150 | 76 | </item> | 102 | </item> |
151 | 77 | </layout> | 103 | </layout> |
152 | 78 | </widget> | 104 | </widget> |
153 | @@ -80,32 +106,32 @@ | |||
154 | 80 | <item> | 106 | <item> |
155 | 81 | <widget class="QGroupBox" name="groupBox_2"> | 107 | <widget class="QGroupBox" name="groupBox_2"> |
156 | 82 | <property name="title"> | 108 | <property name="title"> |
158 | 83 | <string>Application Settings</string> | 109 | <string>File Sync Settings</string> |
159 | 84 | </property> | 110 | </property> |
160 | 85 | <layout class="QVBoxLayout" name="verticalLayout"> | 111 | <layout class="QVBoxLayout" name="verticalLayout"> |
161 | 86 | <item> | 112 | <item> |
163 | 87 | <widget class="QCheckBox" name="auto_connect_checkbox"> | 113 | <widget class="QCheckBox" name="autoconnect_checkbox"> |
164 | 88 | <property name="text"> | 114 | <property name="text"> |
165 | 89 | <string>Connect automatically when computer starts</string> | 115 | <string>Connect automatically when computer starts</string> |
166 | 90 | </property> | 116 | </property> |
167 | 91 | </widget> | 117 | </widget> |
168 | 92 | </item> | 118 | </item> |
169 | 93 | <item> | 119 | <item> |
171 | 94 | <widget class="QCheckBox" name="auto_sync_local_folders_checkbox"> | 120 | <widget class="QCheckBox" name="udf_autosubscribe_checkbox"> |
172 | 95 | <property name="text"> | 121 | <property name="text"> |
173 | 96 | <string>Automatically sync all selected folders on this computer to the cloud</string> | 122 | <string>Automatically sync all selected folders on this computer to the cloud</string> |
174 | 97 | </property> | 123 | </property> |
175 | 98 | </widget> | 124 | </widget> |
176 | 99 | </item> | 125 | </item> |
177 | 100 | <item> | 126 | <item> |
179 | 101 | <widget class="QCheckBox" name="auto_sync_shares_to_me_checkbox"> | 127 | <widget class="QCheckBox" name="share_autosubscribe_checkbox"> |
180 | 102 | <property name="text"> | 128 | <property name="text"> |
181 | 103 | <string>Automatically sync all folders shared with me by other to this computer</string> | 129 | <string>Automatically sync all folders shared with me by other to this computer</string> |
182 | 104 | </property> | 130 | </property> |
183 | 105 | </widget> | 131 | </widget> |
184 | 106 | </item> | 132 | </item> |
185 | 107 | <item> | 133 | <item> |
187 | 108 | <widget class="QCheckBox" name="show_notifications_checkbox"> | 134 | <widget class="QCheckBox" name="show_all_notifications_checkbox"> |
188 | 109 | <property name="text"> | 135 | <property name="text"> |
189 | 110 | <string>Allow all notifications to this device</string> | 136 | <string>Allow all notifications to this device</string> |
190 | 111 | </property> | 137 | </property> |
191 | 112 | 138 | ||
192 | === modified file 'ubuntuone/controlpanel/backend.py' | |||
193 | --- ubuntuone/controlpanel/backend.py 2011-06-02 03:58:53 +0000 | |||
194 | +++ ubuntuone/controlpanel/backend.py 2011-06-17 14:51:05 +0000 | |||
195 | @@ -42,6 +42,10 @@ | |||
196 | 42 | DEVICE_REMOVE_API = "1.0/devices/remove/%s/%s" | 42 | DEVICE_REMOVE_API = "1.0/devices/remove/%s/%s" |
197 | 43 | DEVICE_TYPE_PHONE = "Phone" | 43 | DEVICE_TYPE_PHONE = "Phone" |
198 | 44 | DEVICE_TYPE_COMPUTER = "Computer" | 44 | DEVICE_TYPE_COMPUTER = "Computer" |
199 | 45 | AUTOCONNECT_KEY = 'autoconnect' | ||
200 | 46 | SHOW_ALL_NOTIFICATIONS_KEY = 'show_all_notifications' | ||
201 | 47 | SHARE_AUTOSUBSCRIBE_KEY = 'share_autosubscribe' | ||
202 | 48 | UDF_AUTOSUBSCRIBE_KEY = 'udf_autosubscribe' | ||
203 | 45 | UPLOAD_KEY = "max_upload_speed" | 49 | UPLOAD_KEY = "max_upload_speed" |
204 | 46 | DOWNLOAD_KEY = "max_download_speed" | 50 | DOWNLOAD_KEY = "max_download_speed" |
205 | 47 | 51 | ||
206 | @@ -99,6 +103,14 @@ | |||
207 | 99 | NAME_NOT_SET = u'ENAMENOTSET' | 103 | NAME_NOT_SET = u'ENAMENOTSET' |
208 | 100 | FREE_BYTES_NOT_AVAILABLE = u'EFREEBYTESNOTAVAILABLE' | 104 | FREE_BYTES_NOT_AVAILABLE = u'EFREEBYTESNOTAVAILABLE' |
209 | 101 | STATUS_DISABLED = {MSG_KEY: '', STATUS_KEY: FILE_SYNC_DISABLED} | 105 | STATUS_DISABLED = {MSG_KEY: '', STATUS_KEY: FILE_SYNC_DISABLED} |
210 | 106 | DEFAULT_FILE_SYNC_SETTINGS = { | ||
211 | 107 | AUTOCONNECT_KEY: True, | ||
212 | 108 | SHOW_ALL_NOTIFICATIONS_KEY: True, | ||
213 | 109 | SHARE_AUTOSUBSCRIBE_KEY: False, | ||
214 | 110 | UDF_AUTOSUBSCRIBE_KEY: False, | ||
215 | 111 | DOWNLOAD_KEY: -1, # no limit | ||
216 | 112 | UPLOAD_KEY: -1, # no limit | ||
217 | 113 | } | ||
218 | 102 | 114 | ||
219 | 103 | def __init__(self, shutdown_func=None): | 115 | def __init__(self, shutdown_func=None): |
220 | 104 | """Initialize the web_client.""" | 116 | """Initialize the web_client.""" |
221 | @@ -180,7 +192,8 @@ | |||
222 | 180 | 192 | ||
223 | 181 | @inlineCallbacks | 193 | @inlineCallbacks |
224 | 182 | def _process_device_web_info(self, devices, enabled, limit_bw, limits, | 194 | def _process_device_web_info(self, devices, enabled, limit_bw, limits, |
226 | 183 | show_notifs): | 195 | autoconnect, show_notifs, |
227 | 196 | share_autosubscribe, udf_autosubscribe): | ||
228 | 184 | """Return a lis of processed devices.""" | 197 | """Return a lis of processed devices.""" |
229 | 185 | result = [] | 198 | result = [] |
230 | 186 | for d in devices: | 199 | for d in devices: |
231 | @@ -202,7 +215,10 @@ | |||
232 | 202 | 215 | ||
233 | 203 | if di["configurable"]: | 216 | if di["configurable"]: |
234 | 204 | di["limit_bandwidth"] = limit_bw | 217 | di["limit_bandwidth"] = limit_bw |
236 | 205 | di["show_all_notifications"] = show_notifs | 218 | di[AUTOCONNECT_KEY] = autoconnect |
237 | 219 | di[SHOW_ALL_NOTIFICATIONS_KEY] = show_notifs | ||
238 | 220 | di[SHARE_AUTOSUBSCRIBE_KEY] = share_autosubscribe | ||
239 | 221 | di[UDF_AUTOSUBSCRIBE_KEY] = udf_autosubscribe | ||
240 | 206 | di[UPLOAD_KEY] = limits["upload"] | 222 | di[UPLOAD_KEY] = limits["upload"] |
241 | 207 | di[DOWNLOAD_KEY] = limits["download"] | 223 | di[DOWNLOAD_KEY] = limits["download"] |
242 | 208 | 224 | ||
243 | @@ -273,19 +289,35 @@ | |||
244 | 273 | @inlineCallbacks | 289 | @inlineCallbacks |
245 | 274 | def devices_info(self): | 290 | def devices_info(self): |
246 | 275 | """Get the user devices info.""" | 291 | """Get the user devices info.""" |
248 | 276 | result = limit_bw = limits = show_notifs = None | 292 | result = limit_bw = limits = None |
249 | 293 | autoconnect = show_notifs = None | ||
250 | 294 | share_autosubscribe = udf_autosubscribe = None | ||
251 | 295 | |||
252 | 277 | enabled = yield sd_client.files_sync_enabled() | 296 | enabled = yield sd_client.files_sync_enabled() |
253 | 278 | enabled = bool(enabled) | 297 | enabled = bool(enabled) |
254 | 279 | if enabled: | 298 | if enabled: |
259 | 280 | limit_bw = yield sd_client.bandwidth_throttling_enabled() | 299 | sd_res = yield sd_client.autoconnect_enabled() |
260 | 281 | limit_bw = bool(limit_bw) | 300 | autoconnect = bool(sd_res) |
261 | 282 | show_notifs = yield sd_client.show_all_notifications_enabled() | 301 | |
262 | 283 | show_notifs = bool(show_notifs) | 302 | sd_res = yield sd_client.show_all_notifications_enabled() |
263 | 303 | show_notifs = bool(sd_res) | ||
264 | 304 | |||
265 | 305 | sd_res = yield sd_client.share_autosubscribe_enabled() | ||
266 | 306 | share_autosubscribe = bool(sd_res) | ||
267 | 307 | |||
268 | 308 | sd_res = yield sd_client.udf_autosubscribe_enabled() | ||
269 | 309 | udf_autosubscribe = bool(sd_res) | ||
270 | 310 | |||
271 | 311 | sd_res = yield sd_client.bandwidth_throttling_enabled() | ||
272 | 312 | limit_bw = bool(sd_res) | ||
273 | 313 | |||
274 | 284 | limits = yield sd_client.get_throttling_limits() | 314 | limits = yield sd_client.get_throttling_limits() |
275 | 285 | 315 | ||
276 | 286 | logger.debug('devices_info: file sync enabled? %s limit_bw %s, limits ' | 316 | logger.debug('devices_info: file sync enabled? %s limit_bw %s, limits ' |
279 | 287 | '%s, show_notifs %s', | 317 | '%s, autoconnect %s, show_notifs %s, ' |
280 | 288 | enabled, limit_bw, limits, show_notifs) | 318 | 'share_autosubscribe %s, udf_autosubscribe %s', |
281 | 319 | enabled, limit_bw, limits, autoconnect, show_notifs, | ||
282 | 320 | share_autosubscribe, udf_autosubscribe) | ||
283 | 289 | 321 | ||
284 | 290 | try: | 322 | try: |
285 | 291 | devices = yield self.wc.call_api(DEVICES_API) | 323 | devices = yield self.wc.call_api(DEVICES_API) |
286 | @@ -295,8 +327,8 @@ | |||
287 | 295 | logger.exception('devices_info: web client failure:') | 327 | logger.exception('devices_info: web client failure:') |
288 | 296 | else: | 328 | else: |
289 | 297 | result = yield self._process_device_web_info(devices, enabled, | 329 | result = yield self._process_device_web_info(devices, enabled, |
292 | 298 | limit_bw, limits, | 330 | limit_bw, limits, autoconnect, show_notifs, |
293 | 299 | show_notifs) | 331 | share_autosubscribe, udf_autosubscribe) |
294 | 300 | if result is None: | 332 | if result is None: |
295 | 301 | logger.info('devices_info: result is None after calling ' | 333 | logger.info('devices_info: result is None after calling ' |
296 | 302 | 'devices/ API, building the local device.') | 334 | 'devices/ API, building the local device.') |
297 | @@ -310,12 +342,15 @@ | |||
298 | 310 | local_device["configurable"] = enabled | 342 | local_device["configurable"] = enabled |
299 | 311 | if local_device["configurable"]: | 343 | if local_device["configurable"]: |
300 | 312 | local_device["limit_bandwidth"] = limit_bw | 344 | local_device["limit_bandwidth"] = limit_bw |
303 | 313 | show_notifs = show_notifs | 345 | local_device[AUTOCONNECT_KEY] = autoconnect |
304 | 314 | local_device["show_all_notifications"] = show_notifs | 346 | local_device[SHOW_ALL_NOTIFICATIONS_KEY] = show_notifs |
305 | 347 | local_device[SHARE_AUTOSUBSCRIBE_KEY] = share_autosubscribe | ||
306 | 348 | local_device[UDF_AUTOSUBSCRIBE_KEY] = udf_autosubscribe | ||
307 | 315 | upload = limits["upload"] | 349 | upload = limits["upload"] |
308 | 316 | download = limits["download"] | 350 | download = limits["download"] |
309 | 317 | local_device[UPLOAD_KEY] = upload | 351 | local_device[UPLOAD_KEY] = upload |
310 | 318 | local_device[DOWNLOAD_KEY] = download | 352 | local_device[DOWNLOAD_KEY] = download |
311 | 353 | logger.debug('devices_info: local device built: %r.', local_device) | ||
312 | 319 | result = [local_device] | 354 | result = [local_device] |
313 | 320 | else: | 355 | else: |
314 | 321 | logger.info('devices_info: result is not None after calling ' | 356 | logger.info('devices_info: result is not None after calling ' |
315 | @@ -338,8 +373,8 @@ | |||
316 | 338 | """Change the settings for the given device.""" | 373 | """Change the settings for the given device.""" |
317 | 339 | is_local = yield self.device_is_local(device_id) | 374 | is_local = yield self.device_is_local(device_id) |
318 | 340 | 375 | ||
321 | 341 | if is_local and "show_all_notifications" in settings: | 376 | if is_local and SHOW_ALL_NOTIFICATIONS_KEY in settings: |
322 | 342 | if not settings["show_all_notifications"]: | 377 | if not settings[SHOW_ALL_NOTIFICATIONS_KEY]: |
323 | 343 | yield sd_client.disable_show_all_notifications() | 378 | yield sd_client.disable_show_all_notifications() |
324 | 344 | else: | 379 | else: |
325 | 345 | yield sd_client.enable_show_all_notifications() | 380 | yield sd_client.enable_show_all_notifications() |
326 | @@ -597,6 +632,65 @@ | |||
327 | 597 | # still pending (LP: #673673) | 632 | # still pending (LP: #673673) |
328 | 598 | returnValue(None) | 633 | returnValue(None) |
329 | 599 | 634 | ||
330 | 635 | @log_call(logger.debug) | ||
331 | 636 | @inlineCallbacks | ||
332 | 637 | def file_sync_settings_info(self): | ||
333 | 638 | """Get the file sync settings info.""" | ||
334 | 639 | result = {} | ||
335 | 640 | |||
336 | 641 | for name in (AUTOCONNECT_KEY, SHOW_ALL_NOTIFICATIONS_KEY, | ||
337 | 642 | SHARE_AUTOSUBSCRIBE_KEY, UDF_AUTOSUBSCRIBE_KEY): | ||
338 | 643 | sd_method = getattr(sd_client, '%s_enabled' % name) | ||
339 | 644 | value = yield sd_method() | ||
340 | 645 | result[name] = bool(value) | ||
341 | 646 | |||
342 | 647 | limits = yield sd_client.get_throttling_limits() | ||
343 | 648 | result[DOWNLOAD_KEY] = limits['download'] | ||
344 | 649 | result[UPLOAD_KEY] = limits['upload'] | ||
345 | 650 | |||
346 | 651 | returnValue(result) | ||
347 | 652 | |||
348 | 653 | @inlineCallbacks | ||
349 | 654 | def _change_boolean_file_sync_setting(self, setting_name, settings): | ||
350 | 655 | """Change the value for 'setting_name' to be 'new_value'.""" | ||
351 | 656 | if setting_name in settings: | ||
352 | 657 | new_value = settings[setting_name] | ||
353 | 658 | sd_method_name = 'enable_%s' if new_value else 'disable_%s' | ||
354 | 659 | sd_method = getattr(sd_client, sd_method_name % setting_name) | ||
355 | 660 | yield sd_method() | ||
356 | 661 | |||
357 | 662 | @log_call(logger.info) | ||
358 | 663 | @inlineCallbacks | ||
359 | 664 | def change_file_sync_settings(self, settings): | ||
360 | 665 | """Change the file sync settings.""" | ||
361 | 666 | for name in (AUTOCONNECT_KEY, SHOW_ALL_NOTIFICATIONS_KEY, | ||
362 | 667 | SHARE_AUTOSUBSCRIBE_KEY, UDF_AUTOSUBSCRIBE_KEY): | ||
363 | 668 | yield self._change_boolean_file_sync_setting(name, settings) | ||
364 | 669 | |||
365 | 670 | if DOWNLOAD_KEY in settings or UPLOAD_KEY in settings: | ||
366 | 671 | current_limits = yield sd_client.get_throttling_limits() | ||
367 | 672 | limits = { | ||
368 | 673 | "download": current_limits["download"], | ||
369 | 674 | "upload": current_limits["upload"], | ||
370 | 675 | } | ||
371 | 676 | if UPLOAD_KEY in settings: | ||
372 | 677 | limits["upload"] = settings[UPLOAD_KEY] | ||
373 | 678 | if DOWNLOAD_KEY in settings: | ||
374 | 679 | limits["download"] = settings[DOWNLOAD_KEY] | ||
375 | 680 | yield sd_client.set_throttling_limits(limits) | ||
376 | 681 | |||
377 | 682 | throttling_disabled = sum(limits.itervalues()) == -2 | ||
378 | 683 | if throttling_disabled: | ||
379 | 684 | yield sd_client.disable_bandwidth_throttling() | ||
380 | 685 | else: | ||
381 | 686 | yield sd_client.enable_bandwidth_throttling() | ||
382 | 687 | |||
383 | 688 | @log_call(logger.info) | ||
384 | 689 | @inlineCallbacks | ||
385 | 690 | def restore_file_sync_settings(self): | ||
386 | 691 | """Restore the file sync settings.""" | ||
387 | 692 | yield self.change_file_sync_settings(self.DEFAULT_FILE_SYNC_SETTINGS) | ||
388 | 693 | |||
389 | 600 | @log_call(logger.info) | 694 | @log_call(logger.info) |
390 | 601 | def shutdown(self): | 695 | def shutdown(self): |
391 | 602 | """Stop this service.""" | 696 | """Stop this service.""" |
392 | 603 | 697 | ||
393 | === modified file 'ubuntuone/controlpanel/gui/qt/folders.py' | |||
394 | --- ubuntuone/controlpanel/gui/qt/folders.py 2011-06-16 20:33:39 +0000 | |||
395 | +++ ubuntuone/controlpanel/gui/qt/folders.py 2011-06-17 14:51:05 +0000 | |||
396 | @@ -34,6 +34,7 @@ | |||
397 | 34 | FILE_URI_PREFIX, | 34 | FILE_URI_PREFIX, |
398 | 35 | FOLDER_ICON_NAME, | 35 | FOLDER_ICON_NAME, |
399 | 36 | FOLDERS_CONFIRM_MERGE, | 36 | FOLDERS_CONFIRM_MERGE, |
400 | 37 | KILOBYTES, | ||
401 | 37 | MANAGE_FILES_LINK, | 38 | MANAGE_FILES_LINK, |
402 | 38 | MUSIC_ICON_NAME, | 39 | MUSIC_ICON_NAME, |
403 | 39 | MUSIC_DISPLAY_NAME, | 40 | MUSIC_DISPLAY_NAME, |
404 | @@ -102,8 +103,8 @@ | |||
405 | 102 | units = {0: 'bytes', 1: 'KiB', 2: 'MiB', 3: 'GiB', 4: 'TiB', | 103 | units = {0: 'bytes', 1: 'KiB', 2: 'MiB', 3: 'GiB', 4: 'TiB', |
406 | 103 | 5: 'PiB', 6: 'Eib', 7: 'ZiB', 8: 'YiB'} | 104 | 5: 'PiB', 6: 'Eib', 7: 'ZiB', 8: 'YiB'} |
407 | 104 | unit = 0 | 105 | unit = 0 |
410 | 105 | while int_bytes >= 1024: | 106 | while int_bytes >= KILOBYTES: |
411 | 106 | int_bytes = int_bytes / 1024 | 107 | int_bytes = int_bytes / KILOBYTES |
412 | 107 | unit += 1 | 108 | unit += 1 |
413 | 108 | return '%.1f %s' % (int_bytes, units[unit]) | 109 | return '%.1f %s' % (int_bytes, units[unit]) |
414 | 109 | 110 | ||
415 | 110 | 111 | ||
416 | === modified file 'ubuntuone/controlpanel/gui/qt/main/linux.py' | |||
417 | --- ubuntuone/controlpanel/gui/qt/main/linux.py 2011-06-14 11:41:11 +0000 | |||
418 | +++ ubuntuone/controlpanel/gui/qt/main/linux.py 2011-06-17 14:51:05 +0000 | |||
419 | @@ -55,6 +55,14 @@ | |||
420 | 55 | class SDTool(FakedSyncDaemonTool): | 55 | class SDTool(FakedSyncDaemonTool): |
421 | 56 | """A custom SDTool.""" | 56 | """A custom SDTool.""" |
422 | 57 | 57 | ||
423 | 58 | settings = { | ||
424 | 59 | 'autoconnect': True, | ||
425 | 60 | 'show_all_notifications': True, | ||
426 | 61 | 'share_autosubscribe': False, | ||
427 | 62 | 'udf_autosubscribe': False, | ||
428 | 63 | 'throttling_enabled': True, | ||
429 | 64 | 'limits': {'download': 100000, 'upload': 1000}, | ||
430 | 65 | } | ||
431 | 58 | shares = [ | 66 | shares = [ |
432 | 59 | {u'accepted': u'True', | 67 | {u'accepted': u'True', |
433 | 60 | u'access_level': u'Modify', | 68 | u'access_level': u'Modify', |
434 | 61 | 69 | ||
435 | === modified file 'ubuntuone/controlpanel/gui/qt/preferences.py' | |||
436 | --- ubuntuone/controlpanel/gui/qt/preferences.py 2011-05-24 14:20:18 +0000 | |||
437 | +++ ubuntuone/controlpanel/gui/qt/preferences.py 2011-06-17 14:51:05 +0000 | |||
438 | @@ -18,10 +18,24 @@ | |||
439 | 18 | 18 | ||
440 | 19 | """The user interface for the control panel for Ubuntu One.""" | 19 | """The user interface for the control panel for Ubuntu One.""" |
441 | 20 | 20 | ||
443 | 21 | from PyQt4 import QtGui | 21 | from PyQt4 import QtGui, QtCore |
444 | 22 | from twisted.internet import defer | ||
445 | 22 | 23 | ||
446 | 24 | from ubuntuone.controlpanel import backend | ||
447 | 25 | from ubuntuone.controlpanel.logger import setup_logging, log_call | ||
448 | 26 | from ubuntuone.controlpanel.gui import KILOBYTES | ||
449 | 23 | from ubuntuone.controlpanel.gui.qt.ui import preferences_ui | 27 | from ubuntuone.controlpanel.gui.qt.ui import preferences_ui |
450 | 24 | 28 | ||
451 | 29 | logger = setup_logging('qt.preferences') | ||
452 | 30 | |||
453 | 31 | CHECKED = QtCore.Qt.Checked | ||
454 | 32 | UNCHECKED = QtCore.Qt.Unchecked | ||
455 | 33 | |||
456 | 34 | |||
457 | 35 | def check_state(checked): | ||
458 | 36 | """Return the QCheckBox check state according the value of 'checked'.""" | ||
459 | 37 | return CHECKED if checked else UNCHECKED | ||
460 | 38 | |||
461 | 25 | 39 | ||
462 | 26 | class PreferencesPanel(QtGui.QWidget): | 40 | class PreferencesPanel(QtGui.QWidget): |
463 | 27 | """The Preferences Tab Panel widget""" | 41 | """The Preferences Tab Panel widget""" |
464 | @@ -31,3 +45,95 @@ | |||
465 | 31 | QtGui.QWidget.__init__(self, *args) | 45 | QtGui.QWidget.__init__(self, *args) |
466 | 32 | self.ui = preferences_ui.Ui_Form() | 46 | self.ui = preferences_ui.Ui_Form() |
467 | 33 | self.ui.setupUi(self) | 47 | self.ui.setupUi(self) |
468 | 48 | |||
469 | 49 | self.backend = backend.ControlBackend() | ||
470 | 50 | logger.debug('%s: started.', self.__class__.__name__) | ||
471 | 51 | |||
472 | 52 | # Invalid name "showEvent" | ||
473 | 53 | # pylint: disable=C0103 | ||
474 | 54 | |||
475 | 55 | def showEvent(self, event): | ||
476 | 56 | """Load info.""" | ||
477 | 57 | d = defer.maybeDeferred(self.backend.file_sync_settings_info) | ||
478 | 58 | d.addCallback(self.process_settings) | ||
479 | 59 | event.accept() | ||
480 | 60 | |||
481 | 61 | @log_call(logger.debug) | ||
482 | 62 | def process_settings(self, info): | ||
483 | 63 | """Load settings info into the view.""" | ||
484 | 64 | if not info: | ||
485 | 65 | return | ||
486 | 66 | |||
487 | 67 | autoconnect = check_state(info[backend.AUTOCONNECT_KEY]) | ||
488 | 68 | show_all_notifs = \ | ||
489 | 69 | check_state(info[backend.SHOW_ALL_NOTIFICATIONS_KEY]) | ||
490 | 70 | share_autosubscribe = \ | ||
491 | 71 | check_state(info[backend.SHARE_AUTOSUBSCRIBE_KEY]) | ||
492 | 72 | udf_autosubscribe = \ | ||
493 | 73 | check_state(info[backend.UDF_AUTOSUBSCRIBE_KEY]) | ||
494 | 74 | download_speed = info[backend.DOWNLOAD_KEY] // KILOBYTES | ||
495 | 75 | upload_speed = info[backend.UPLOAD_KEY] // KILOBYTES | ||
496 | 76 | |||
497 | 77 | self.ui.autoconnect_checkbox.setCheckState(autoconnect) | ||
498 | 78 | self.ui.show_all_notifications_checkbox.setCheckState(show_all_notifs) | ||
499 | 79 | self.ui.share_autosubscribe_checkbox.setCheckState(share_autosubscribe) | ||
500 | 80 | self.ui.udf_autosubscribe_checkbox.setCheckState(udf_autosubscribe) | ||
501 | 81 | self.ui.download_speed_spinbox.setValue(download_speed) | ||
502 | 82 | self.ui.upload_speed_spinbox.setValue(upload_speed) | ||
503 | 83 | |||
504 | 84 | def process_speed_settings(self, new_value, checkbox): | ||
505 | 85 | """A new speed limit was set.""" | ||
506 | 86 | if new_value < 0: | ||
507 | 87 | checkbox.setCheckState(UNCHECKED) | ||
508 | 88 | else: | ||
509 | 89 | checkbox.setCheckState(CHECKED) | ||
510 | 90 | |||
511 | 91 | @QtCore.pyqtSlot(int) | ||
512 | 92 | def on_download_speed_spinbox_valueChanged(self, new_value): | ||
513 | 93 | """A new download speed was set.""" | ||
514 | 94 | self.process_speed_settings(new_value, | ||
515 | 95 | self.ui.limit_downloads_checkbox) | ||
516 | 96 | |||
517 | 97 | @QtCore.pyqtSlot(int) | ||
518 | 98 | def on_upload_speed_spinbox_valueChanged(self, new_value): | ||
519 | 99 | """A new upload speed was set.""" | ||
520 | 100 | self.process_speed_settings(new_value, | ||
521 | 101 | self.ui.limit_uploads_checkbox) | ||
522 | 102 | |||
523 | 103 | @QtCore.pyqtSlot() | ||
524 | 104 | @defer.inlineCallbacks | ||
525 | 105 | def on_apply_changes_button_clicked(self): | ||
526 | 106 | """The apply changes button was clicked.""" | ||
527 | 107 | autoconnect = self.ui.autoconnect_checkbox.checkState() | ||
528 | 108 | notifications = self.ui.show_all_notifications_checkbox.checkState() | ||
529 | 109 | share_autosubscribe = self.ui.share_autosubscribe_checkbox.checkState() | ||
530 | 110 | udf_autosubscribe = self.ui.udf_autosubscribe_checkbox.checkState() | ||
531 | 111 | download_speed = self.ui.download_speed_spinbox.value() * KILOBYTES | ||
532 | 112 | upload_speed = self.ui.upload_speed_spinbox.value() * KILOBYTES | ||
533 | 113 | |||
534 | 114 | settings = { | ||
535 | 115 | backend.AUTOCONNECT_KEY: autoconnect == CHECKED, | ||
536 | 116 | backend.SHOW_ALL_NOTIFICATIONS_KEY: notifications == CHECKED, | ||
537 | 117 | backend.SHARE_AUTOSUBSCRIBE_KEY: share_autosubscribe == CHECKED, | ||
538 | 118 | backend.UDF_AUTOSUBSCRIBE_KEY: udf_autosubscribe == CHECKED, | ||
539 | 119 | backend.DOWNLOAD_KEY: download_speed, | ||
540 | 120 | backend.UPLOAD_KEY: upload_speed, | ||
541 | 121 | } | ||
542 | 122 | |||
543 | 123 | # set is_processing | ||
544 | 124 | # TODO: handle errors | ||
545 | 125 | yield self.backend.change_file_sync_settings(settings) | ||
546 | 126 | # unset is_processing | ||
547 | 127 | |||
548 | 128 | @QtCore.pyqtSlot() | ||
549 | 129 | @defer.inlineCallbacks | ||
550 | 130 | def on_restore_defaults_button_clicked(self): | ||
551 | 131 | """The restore defaults button was clicked.""" | ||
552 | 132 | # set is_processing | ||
553 | 133 | # TODO: handle errors | ||
554 | 134 | yield self.backend.restore_file_sync_settings() | ||
555 | 135 | settings = yield self.backend.file_sync_settings_info() | ||
556 | 136 | |||
557 | 137 | self.process_settings(settings) | ||
558 | 138 | |||
559 | 139 | # unset is_processing | ||
560 | 34 | 140 | ||
561 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/__init__.py' | |||
562 | --- ubuntuone/controlpanel/gui/qt/tests/__init__.py 2011-06-16 20:31:27 +0000 | |||
563 | +++ ubuntuone/controlpanel/gui/qt/tests/__init__.py 2011-06-17 14:51:05 +0000 | |||
564 | @@ -93,6 +93,14 @@ | |||
565 | 93 | SHARE_TYPE = u'SHARE' | 93 | SHARE_TYPE = u'SHARE' |
566 | 94 | NAME_NOT_SET = u'ENAMENOTSET' | 94 | NAME_NOT_SET = u'ENAMENOTSET' |
567 | 95 | FREE_BYTES_NOT_AVAILABLE = u'EFREEBYTESNOTAVAILABLE' | 95 | FREE_BYTES_NOT_AVAILABLE = u'EFREEBYTESNOTAVAILABLE' |
568 | 96 | DEFAULT_FILE_SYNC_SETTINGS = { | ||
569 | 97 | backend.AUTOCONNECT_KEY: True, | ||
570 | 98 | backend.SHOW_ALL_NOTIFICATIONS_KEY: True, | ||
571 | 99 | backend.SHARE_AUTOSUBSCRIBE_KEY: False, | ||
572 | 100 | backend.UDF_AUTOSUBSCRIBE_KEY: False, | ||
573 | 101 | backend.DOWNLOAD_KEY: -1, # no limit | ||
574 | 102 | backend.UPLOAD_KEY: -1, # no limit | ||
575 | 103 | } | ||
576 | 96 | 104 | ||
577 | 97 | exposed_methods = [ | 105 | exposed_methods = [ |
578 | 98 | 'account_info', # account | 106 | 'account_info', # account |
579 | @@ -101,7 +109,11 @@ | |||
580 | 101 | 'replications_info', 'change_replication_settings', # replications | 109 | 'replications_info', 'change_replication_settings', # replications |
581 | 102 | 'file_sync_status', 'enable_files', 'disable_files', # files | 110 | 'file_sync_status', 'enable_files', 'disable_files', # files |
582 | 103 | 'connect_files', 'disconnect_files', | 111 | 'connect_files', 'disconnect_files', |
584 | 104 | 'restart_files', 'start_files', 'stop_files', 'shutdown', | 112 | 'restart_files', 'start_files', 'stop_files', |
585 | 113 | 'file_sync_settings_info', | ||
586 | 114 | 'change_file_sync_settings', | ||
587 | 115 | 'restore_file_sync_settings', | ||
588 | 116 | 'shutdown', | ||
589 | 105 | ] | 117 | ] |
590 | 106 | 118 | ||
591 | 107 | 119 | ||
592 | @@ -140,13 +152,8 @@ | |||
593 | 140 | 152 | ||
594 | 141 | self.ui.show() | 153 | self.ui.show() |
595 | 142 | 154 | ||
597 | 143 | def assert_backend_called(self, method_name, args=None, kwargs=None): | 155 | def assert_backend_called(self, method_name, *args, **kwargs): |
598 | 144 | """Check that the control panel backend 'method_name' was called.""" | 156 | """Check that the control panel backend 'method_name' was called.""" |
599 | 145 | if args is None: | ||
600 | 146 | args = () | ||
601 | 147 | if kwargs is None: | ||
602 | 148 | kwargs = {} | ||
603 | 149 | |||
604 | 150 | self.assertIn(method_name, self.ui.backend._called) | 157 | self.assertIn(method_name, self.ui.backend._called) |
605 | 151 | self.assertEqual(self.ui.backend._called[method_name], (args, kwargs)) | 158 | self.assertEqual(self.ui.backend._called[method_name], (args, kwargs)) |
606 | 152 | 159 | ||
607 | 153 | 160 | ||
608 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py' | |||
609 | --- ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2011-06-01 18:10:22 +0000 | |||
610 | +++ ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2011-06-17 14:51:05 +0000 | |||
611 | @@ -87,7 +87,7 @@ | |||
612 | 87 | 87 | ||
613 | 88 | def test_file_sync_status_is_requested_on_show(self): | 88 | def test_file_sync_status_is_requested_on_show(self): |
614 | 89 | """The file sync status is requested to the backend.""" | 89 | """The file sync status is requested to the backend.""" |
616 | 90 | self.assert_backend_called('file_sync_status', ()) | 90 | self.assert_backend_called('file_sync_status') |
617 | 91 | 91 | ||
618 | 92 | def test_process_status_disabled(self): | 92 | def test_process_status_disabled(self): |
619 | 93 | """File sync status disabled update the label.""" | 93 | """File sync status disabled update the label.""" |
620 | 94 | 94 | ||
621 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_folders.py' | |||
622 | --- ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2011-06-16 20:33:39 +0000 | |||
623 | +++ ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2011-06-17 14:51:05 +0000 | |||
624 | @@ -77,7 +77,7 @@ | |||
625 | 77 | 77 | ||
626 | 78 | def test_volumes_info_is_requested_on_show(self): | 78 | def test_volumes_info_is_requested_on_show(self): |
627 | 79 | """The volumes info is requested to the backend.""" | 79 | """The volumes info is requested to the backend.""" |
629 | 80 | self.assert_backend_called('volumes_info', ()) | 80 | self.assert_backend_called('volumes_info') |
630 | 81 | 81 | ||
631 | 82 | def test_process_folders(self): | 82 | def test_process_folders(self): |
632 | 83 | """The volumes info is processed when ready.""" | 83 | """The volumes info is processed when ready.""" |
633 | @@ -333,7 +333,7 @@ | |||
634 | 333 | 333 | ||
635 | 334 | # backend was called | 334 | # backend was called |
636 | 335 | self.assert_backend_called('change_volume_settings', | 335 | self.assert_backend_called('change_volume_settings', |
638 | 336 | (fid, {'subscribed': subscribed})) | 336 | fid, {'subscribed': subscribed}) |
639 | 337 | 337 | ||
640 | 338 | value = self.item.checkState(gui.SUBSCRIPTION_COL) == gui.CHECKED | 338 | value = self.item.checkState(gui.SUBSCRIPTION_COL) == gui.CHECKED |
641 | 339 | self.assertEqual(value, bool(subscribed)) | 339 | self.assertEqual(value, bool(subscribed)) |
642 | 340 | 340 | ||
643 | === added file 'ubuntuone/controlpanel/gui/qt/tests/test_preferences.py' | |||
644 | --- ubuntuone/controlpanel/gui/qt/tests/test_preferences.py 1970-01-01 00:00:00 +0000 | |||
645 | +++ ubuntuone/controlpanel/gui/qt/tests/test_preferences.py 2011-06-17 14:51:05 +0000 | |||
646 | @@ -0,0 +1,165 @@ | |||
647 | 1 | # -*- coding: utf-8 -*- | ||
648 | 2 | |||
649 | 3 | # Authors: Natalia B Bidart <natalia.bidart@canonical.com> | ||
650 | 4 | # | ||
651 | 5 | # Copyright 2011 Canonical Ltd. | ||
652 | 6 | # | ||
653 | 7 | # This program is free software: you can redistribute it and/or modify it | ||
654 | 8 | # under the terms of the GNU General Public License version 3, as published | ||
655 | 9 | # by the Free Software Foundation. | ||
656 | 10 | # | ||
657 | 11 | # This program is distributed in the hope that it will be useful, but | ||
658 | 12 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
659 | 13 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
660 | 14 | # PURPOSE. See the GNU General Public License for more details. | ||
661 | 15 | # | ||
662 | 16 | # You should have received a copy of the GNU General Public License along | ||
663 | 17 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
664 | 18 | |||
665 | 19 | """Tests for the Control Panel.""" | ||
666 | 20 | |||
667 | 21 | from __future__ import division | ||
668 | 22 | |||
669 | 23 | from ubuntuone.controlpanel.gui.qt import preferences as gui | ||
670 | 24 | from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase | ||
671 | 25 | |||
672 | 26 | # Access to a protected member | ||
673 | 27 | # pylint: disable=W0212 | ||
674 | 28 | |||
675 | 29 | |||
676 | 30 | class PreferencesPanelTestCase(BaseTestCase): | ||
677 | 31 | """Test the qt cloud preferences tab.""" | ||
678 | 32 | |||
679 | 33 | innerclass_ui = gui.preferences_ui | ||
680 | 34 | innerclass_name = "Ui_Form" | ||
681 | 35 | class_ui = gui.PreferencesPanel | ||
682 | 36 | |||
683 | 37 | def test_backend(self): | ||
684 | 38 | """Backend is created.""" | ||
685 | 39 | self.assertIsInstance(self.ui.backend, | ||
686 | 40 | gui.backend.ControlBackend) | ||
687 | 41 | |||
688 | 42 | def test_file_sync_settings_info_is_requested(self): | ||
689 | 43 | """The file_sync_settings info is requested to the backend.""" | ||
690 | 44 | self.assert_backend_called('file_sync_settings_info') | ||
691 | 45 | |||
692 | 46 | def _test_update_ui_from_settings_info(self, settings): | ||
693 | 47 | """The ui is correctly updated when the backend info is received.""" | ||
694 | 48 | autoconnect = self.ui.ui.autoconnect_checkbox.checkState() | ||
695 | 49 | self.assertEqual(autoconnect == gui.CHECKED, | ||
696 | 50 | settings[gui.backend.AUTOCONNECT_KEY]) | ||
697 | 51 | |||
698 | 52 | show_all_notifications = \ | ||
699 | 53 | self.ui.ui.show_all_notifications_checkbox.checkState() | ||
700 | 54 | self.assertEqual(show_all_notifications == gui.CHECKED, | ||
701 | 55 | settings[gui.backend.SHOW_ALL_NOTIFICATIONS_KEY]) | ||
702 | 56 | |||
703 | 57 | share_autosubscribe = \ | ||
704 | 58 | self.ui.ui.share_autosubscribe_checkbox.checkState() | ||
705 | 59 | self.assertEqual(share_autosubscribe == gui.CHECKED, | ||
706 | 60 | settings[gui.backend.SHARE_AUTOSUBSCRIBE_KEY]) | ||
707 | 61 | |||
708 | 62 | udf_autosubscribe = self.ui.ui.udf_autosubscribe_checkbox.checkState() | ||
709 | 63 | self.assertEqual(udf_autosubscribe == gui.CHECKED, | ||
710 | 64 | settings[gui.backend.UDF_AUTOSUBSCRIBE_KEY]) | ||
711 | 65 | |||
712 | 66 | download_speed = self.ui.ui.download_speed_spinbox.value() | ||
713 | 67 | self.assertEqual(download_speed, | ||
714 | 68 | settings[gui.backend.DOWNLOAD_KEY] // gui.KILOBYTES) | ||
715 | 69 | |||
716 | 70 | upload_speed = self.ui.ui.upload_speed_spinbox.value() | ||
717 | 71 | self.assertEqual(upload_speed, | ||
718 | 72 | settings[gui.backend.UPLOAD_KEY] // gui.KILOBYTES) | ||
719 | 73 | |||
720 | 74 | def test_update_ui_from_backed_info(self): | ||
721 | 75 | """The ui is correctly updated when the backend info is received.""" | ||
722 | 76 | settings = { | ||
723 | 77 | gui.backend.AUTOCONNECT_KEY: True, | ||
724 | 78 | gui.backend.SHOW_ALL_NOTIFICATIONS_KEY: True, | ||
725 | 79 | gui.backend.SHARE_AUTOSUBSCRIBE_KEY: True, | ||
726 | 80 | gui.backend.UDF_AUTOSUBSCRIBE_KEY: True, | ||
727 | 81 | gui.backend.DOWNLOAD_KEY: 20480, | ||
728 | 82 | gui.backend.UPLOAD_KEY: 2048, | ||
729 | 83 | } | ||
730 | 84 | self.ui.process_settings(settings) | ||
731 | 85 | self._test_update_ui_from_settings_info(settings) | ||
732 | 86 | |||
733 | 87 | def _test_speed_checkbox_value_changed_to_positive(self, speed_spinbox, | ||
734 | 88 | limit_checkbox): | ||
735 | 89 | """When the speed is set to a positive value, enable the checkbox.""" | ||
736 | 90 | limit_checkbox.setCheckState(gui.UNCHECKED) | ||
737 | 91 | speed_spinbox.setValue(33) | ||
738 | 92 | |||
739 | 93 | self.assertEqual(gui.CHECKED, limit_checkbox.checkState()) | ||
740 | 94 | |||
741 | 95 | def _test_speed_checkbox_value_changed_to_negative(self, speed_spinbox, | ||
742 | 96 | limit_checkbox): | ||
743 | 97 | """When the speed is set to a negative value, disable the checkbox.""" | ||
744 | 98 | limit_checkbox.setCheckState(gui.UNCHECKED) | ||
745 | 99 | speed_spinbox.setValue(-1) | ||
746 | 100 | |||
747 | 101 | self.assertEqual(gui.UNCHECKED, limit_checkbox.checkState()) | ||
748 | 102 | |||
749 | 103 | def test_download_speed_checkbox_value_changed_to_positive(self): | ||
750 | 104 | """When the download speed is set, enable the checkbox.""" | ||
751 | 105 | self._test_speed_checkbox_value_changed_to_positive( | ||
752 | 106 | self.ui.ui.download_speed_spinbox, | ||
753 | 107 | self.ui.ui.limit_downloads_checkbox) | ||
754 | 108 | |||
755 | 109 | def test_download_speed_checkbox_value_changed_to_negative(self): | ||
756 | 110 | """When the download speed is set, enable the checkbox.""" | ||
757 | 111 | self._test_speed_checkbox_value_changed_to_negative( | ||
758 | 112 | self.ui.ui.download_speed_spinbox, | ||
759 | 113 | self.ui.ui.limit_downloads_checkbox) | ||
760 | 114 | |||
761 | 115 | def test_upload_speed_checkbox_value_changed_to_positive(self): | ||
762 | 116 | """When the upload speed is set, enable the checkbox.""" | ||
763 | 117 | self._test_speed_checkbox_value_changed_to_positive( | ||
764 | 118 | self.ui.ui.upload_speed_spinbox, | ||
765 | 119 | self.ui.ui.limit_uploads_checkbox) | ||
766 | 120 | |||
767 | 121 | def test_upload_speed_checkbox_value_changed_to_negative(self): | ||
768 | 122 | """When the upload speed is set, enable the checkbox.""" | ||
769 | 123 | self._test_speed_checkbox_value_changed_to_negative( | ||
770 | 124 | self.ui.ui.upload_speed_spinbox, | ||
771 | 125 | self.ui.ui.limit_uploads_checkbox) | ||
772 | 126 | |||
773 | 127 | def test_apply_changes_button_clicked(self): | ||
774 | 128 | """When the apply button is clicked, the backend is called.""" | ||
775 | 129 | self.ui.ui.autoconnect_checkbox.setCheckState(gui.CHECKED) | ||
776 | 130 | self.ui.ui.show_all_notifications_checkbox.setCheckState(gui.CHECKED) | ||
777 | 131 | self.ui.ui.share_autosubscribe_checkbox.setCheckState(gui.CHECKED) | ||
778 | 132 | self.ui.ui.udf_autosubscribe_checkbox.setCheckState(gui.CHECKED) | ||
779 | 133 | self.ui.ui.download_speed_spinbox.setValue(20) | ||
780 | 134 | self.ui.ui.upload_speed_spinbox.setValue(2) | ||
781 | 135 | |||
782 | 136 | self.ui.ui.apply_changes_button.click() | ||
783 | 137 | |||
784 | 138 | expected_dict = { | ||
785 | 139 | gui.backend.AUTOCONNECT_KEY: True, | ||
786 | 140 | gui.backend.SHOW_ALL_NOTIFICATIONS_KEY: True, | ||
787 | 141 | gui.backend.SHARE_AUTOSUBSCRIBE_KEY: True, | ||
788 | 142 | gui.backend.UDF_AUTOSUBSCRIBE_KEY: True, | ||
789 | 143 | gui.backend.DOWNLOAD_KEY: 20 * gui.KILOBYTES, | ||
790 | 144 | gui.backend.UPLOAD_KEY: 2 * gui.KILOBYTES, | ||
791 | 145 | } | ||
792 | 146 | self.assert_backend_called('change_file_sync_settings', expected_dict) | ||
793 | 147 | |||
794 | 148 | def test_restore_defaults_button_clicked(self): | ||
795 | 149 | """When the restore button is clicked, the backend is called.""" | ||
796 | 150 | settings = gui.backend.ControlBackend.DEFAULT_FILE_SYNC_SETTINGS | ||
797 | 151 | self.patch(self.ui.backend, 'file_sync_settings_info', | ||
798 | 152 | lambda: settings) | ||
799 | 153 | # modify the state a bit to ensure defaults are applied | ||
800 | 154 | self.ui.ui.autoconnect_checkbox.setCheckState(gui.UNCHECKED) | ||
801 | 155 | self.ui.ui.show_all_notifications_checkbox.setCheckState(gui.UNCHECKED) | ||
802 | 156 | self.ui.ui.share_autosubscribe_checkbox.setCheckState(gui.CHECKED) | ||
803 | 157 | self.ui.ui.udf_autosubscribe_checkbox.setCheckState(gui.CHECKED) | ||
804 | 158 | self.ui.ui.download_speed_spinbox.setValue(20) | ||
805 | 159 | self.ui.ui.upload_speed_spinbox.setValue(2) | ||
806 | 160 | |||
807 | 161 | self.ui.ui.restore_defaults_button.click() | ||
808 | 162 | |||
809 | 163 | self.assert_backend_called('restore_file_sync_settings') | ||
810 | 164 | |||
811 | 165 | self._test_update_ui_from_settings_info(settings) | ||
812 | 0 | 166 | ||
813 | === modified file 'ubuntuone/controlpanel/integrationtests/test_sd_client/test_linux.py' | |||
814 | --- ubuntuone/controlpanel/integrationtests/test_sd_client/test_linux.py 2011-06-02 17:19:37 +0000 | |||
815 | +++ ubuntuone/controlpanel/integrationtests/test_sd_client/test_linux.py 2011-06-17 14:51:05 +0000 | |||
816 | @@ -51,7 +51,10 @@ | |||
817 | 51 | """Fake the SyncDaemonTool.""" | 51 | """Fake the SyncDaemonTool.""" |
818 | 52 | 52 | ||
819 | 53 | settings = { | 53 | settings = { |
820 | 54 | 'autoconnect': True, | ||
821 | 54 | 'show_all_notifications': True, | 55 | 'show_all_notifications': True, |
822 | 56 | 'share_autosubscribe': True, | ||
823 | 57 | 'udf_autosubscribe': True, | ||
824 | 55 | 'file_sync_enabled': True, | 58 | 'file_sync_enabled': True, |
825 | 56 | 'throttling_enabled': False, | 59 | 'throttling_enabled': False, |
826 | 57 | 'limits': {'download': -1, 'upload': -1}, | 60 | 'limits': {'download': -1, 'upload': -1}, |
827 | @@ -264,6 +267,14 @@ | |||
828 | 264 | """Enable/disable file sync.""" | 267 | """Enable/disable file sync.""" |
829 | 265 | self.settings['file_sync_enabled'] = enabled | 268 | self.settings['file_sync_enabled'] = enabled |
830 | 266 | 269 | ||
831 | 270 | def is_autoconnect_enabled(self): | ||
832 | 271 | """Check if autoconnect is enabled.""" | ||
833 | 272 | return self.settings['autoconnect'] | ||
834 | 273 | |||
835 | 274 | def enable_autoconnect(self, enabled): | ||
836 | 275 | """Enable/disable autoconnect.""" | ||
837 | 276 | self.settings['autoconnect'] = enabled | ||
838 | 277 | |||
839 | 267 | def is_show_all_notifications_enabled(self): | 278 | def is_show_all_notifications_enabled(self): |
840 | 268 | """Check if show_all_notifications is enabled.""" | 279 | """Check if show_all_notifications is enabled.""" |
841 | 269 | return self.settings['show_all_notifications'] | 280 | return self.settings['show_all_notifications'] |
842 | @@ -272,6 +283,22 @@ | |||
843 | 272 | """Enable/disable show_all_notifications.""" | 283 | """Enable/disable show_all_notifications.""" |
844 | 273 | self.settings['show_all_notifications'] = enabled | 284 | self.settings['show_all_notifications'] = enabled |
845 | 274 | 285 | ||
846 | 286 | def is_share_autosubscribe_enabled(self): | ||
847 | 287 | """Check if share_autosubscribe is enabled.""" | ||
848 | 288 | return self.settings['share_autosubscribe'] | ||
849 | 289 | |||
850 | 290 | def enable_share_autosubscribe(self, enabled): | ||
851 | 291 | """Enable/disable share_autosubscribe.""" | ||
852 | 292 | self.settings['share_autosubscribe'] = enabled | ||
853 | 293 | |||
854 | 294 | def is_udf_autosubscribe_enabled(self): | ||
855 | 295 | """Check if udf_autosubscribe is enabled.""" | ||
856 | 296 | return self.settings['udf_autosubscribe'] | ||
857 | 297 | |||
858 | 298 | def enable_udf_autosubscribe(self, enabled): | ||
859 | 299 | """Enable/disable udf_autosubscribe.""" | ||
860 | 300 | self.settings['udf_autosubscribe'] = enabled | ||
861 | 301 | |||
862 | 275 | def refresh_volumes(self): | 302 | def refresh_volumes(self): |
863 | 276 | """Request the volumes list to the server.""" | 303 | """Request the volumes list to the server.""" |
864 | 277 | self.called['refresh_volumes'] = None | 304 | self.called['refresh_volumes'] = None |
865 | @@ -393,54 +420,86 @@ | |||
866 | 393 | class NotificationsTestCase(BaseTestCase): | 420 | class NotificationsTestCase(BaseTestCase): |
867 | 394 | """Test for the show_all_notifications syncdaemon client methods.""" | 421 | """Test for the show_all_notifications syncdaemon client methods.""" |
868 | 395 | 422 | ||
869 | 423 | # No value passed for parameter '_' in function call | ||
870 | 424 | # pylint: disable=E1120 | ||
871 | 425 | |||
872 | 426 | name = 'show_all_notifications' | ||
873 | 427 | getter = lambda _: sd_client.show_all_notifications_enabled() | ||
874 | 428 | enabler = lambda _: sd_client.enable_show_all_notifications() | ||
875 | 429 | disabler = lambda _: sd_client.disable_show_all_notifications() | ||
876 | 430 | |||
877 | 396 | @inlineCallbacks | 431 | @inlineCallbacks |
879 | 397 | def test_notifications_get(self): | 432 | def test_get_value(self): |
880 | 398 | """Getting the show_all_notifications state.""" | 433 | """Getting the show_all_notifications state.""" |
883 | 399 | FakedSyncDaemonTool.settings['show_all_notifications'] = False | 434 | FakedSyncDaemonTool.settings[self.name] = False |
884 | 400 | state = yield sd_client.show_all_notifications_enabled() | 435 | state = yield self.getter() |
885 | 401 | self.assertEqual(state, False) | 436 | self.assertEqual(state, False) |
888 | 402 | FakedSyncDaemonTool.settings['show_all_notifications'] = True | 437 | FakedSyncDaemonTool.settings[self.name] = True |
889 | 403 | state = yield sd_client.show_all_notifications_enabled() | 438 | state = yield self.getter() |
890 | 404 | self.assertEqual(state, True) | 439 | self.assertEqual(state, True) |
891 | 405 | 440 | ||
892 | 406 | @inlineCallbacks | 441 | @inlineCallbacks |
894 | 407 | def test_notifications_get_throws_an_error(self): | 442 | def test_get_value_throws_an_error(self): |
895 | 408 | """Handle error when getting the show_all_notifications state.""" | 443 | """Handle error when getting the show_all_notifications state.""" |
897 | 409 | self.patch(FakedSyncDaemonTool, 'is_show_all_notifications_enabled', | 444 | self.patch(FakedSyncDaemonTool, 'is_%s_enabled' % self.name, |
898 | 410 | self.fake_fail) | 445 | self.fake_fail) |
901 | 411 | yield self.assertFailure(sd_client.show_all_notifications_enabled(), | 446 | yield self.assertFailure(self.getter(), CustomError) |
900 | 412 | CustomError) | ||
902 | 413 | 447 | ||
903 | 414 | @inlineCallbacks | 448 | @inlineCallbacks |
905 | 415 | def test_notifications_enable(self): | 449 | def test_enable(self): |
906 | 416 | """Enabling show_all_notifications.""" | 450 | """Enabling show_all_notifications.""" |
910 | 417 | FakedSyncDaemonTool.settings['show_all_notifications'] = False | 451 | FakedSyncDaemonTool.settings[self.name] = False |
911 | 418 | yield sd_client.enable_show_all_notifications() | 452 | yield self.enabler() |
912 | 419 | self.assertTrue(FakedSyncDaemonTool.settings['show_all_notifications']) | 453 | self.assertTrue(FakedSyncDaemonTool.settings[self.name]) |
913 | 420 | 454 | ||
914 | 421 | @inlineCallbacks | 455 | @inlineCallbacks |
916 | 422 | def test_notifications_enable_throws_an_error(self): | 456 | def test_enable_throws_an_error(self): |
917 | 423 | """Handle error when enabling show_all_notifications.""" | 457 | """Handle error when enabling show_all_notifications.""" |
919 | 424 | self.patch(FakedSyncDaemonTool, 'enable_show_all_notifications', | 458 | self.patch(FakedSyncDaemonTool, 'enable_%s' % self.name, |
920 | 425 | self.fake_fail) | 459 | self.fake_fail) |
923 | 426 | yield self.assertFailure(sd_client.enable_show_all_notifications(), | 460 | yield self.assertFailure(self.enabler(), CustomError) |
922 | 427 | CustomError) | ||
924 | 428 | 461 | ||
925 | 429 | @inlineCallbacks | 462 | @inlineCallbacks |
927 | 430 | def test_notifications_disable(self): | 463 | def test_disable(self): |
928 | 431 | """Disabling show_all_notifications.""" | 464 | """Disabling show_all_notifications.""" |
932 | 432 | FakedSyncDaemonTool.settings['show_all_notifications'] = True | 465 | FakedSyncDaemonTool.settings[self.name] = True |
933 | 433 | yield sd_client.disable_show_all_notifications() | 466 | yield self.disabler() |
934 | 434 | value = FakedSyncDaemonTool.settings['show_all_notifications'] | 467 | value = FakedSyncDaemonTool.settings[self.name] |
935 | 435 | self.assertFalse(value) | 468 | self.assertFalse(value) |
936 | 436 | 469 | ||
937 | 437 | @inlineCallbacks | 470 | @inlineCallbacks |
939 | 438 | def test_notifications_disable_throws_an_error(self): | 471 | def test_disable_throws_an_error(self): |
940 | 439 | """Handle error when disabling show_all_notifications.""" | 472 | """Handle error when disabling show_all_notifications.""" |
942 | 440 | self.patch(FakedSyncDaemonTool, 'enable_show_all_notifications', | 473 | self.patch(FakedSyncDaemonTool, 'enable_%s' % self.name, |
943 | 441 | self.fake_fail) | 474 | self.fake_fail) |
946 | 442 | yield self.assertFailure(sd_client.disable_show_all_notifications(), | 475 | yield self.assertFailure(self.disabler(), CustomError) |
947 | 443 | CustomError) | 476 | |
948 | 477 | |||
949 | 478 | class AutoconnectTestCase(NotificationsTestCase): | ||
950 | 479 | """Test for the autoconnect syncdaemon client methods.""" | ||
951 | 480 | |||
952 | 481 | name = 'autoconnect' | ||
953 | 482 | getter = lambda _: sd_client.autoconnect_enabled() | ||
954 | 483 | enabler = lambda _: sd_client.enable_autoconnect() | ||
955 | 484 | disabler = lambda _: sd_client.disable_autoconnect() | ||
956 | 485 | |||
957 | 486 | |||
958 | 487 | class ShareAutosubscribeTestCase(NotificationsTestCase): | ||
959 | 488 | """Test for the share_autosubscribe syncdaemon client methods.""" | ||
960 | 489 | |||
961 | 490 | name = 'share_autosubscribe' | ||
962 | 491 | getter = lambda _: sd_client.share_autosubscribe_enabled() | ||
963 | 492 | enabler = lambda _: sd_client.enable_share_autosubscribe() | ||
964 | 493 | disabler = lambda _: sd_client.disable_share_autosubscribe() | ||
965 | 494 | |||
966 | 495 | |||
967 | 496 | class UDFAutosubscribeTestCase(NotificationsTestCase): | ||
968 | 497 | """Test for the udf_autosubscribe syncdaemon client methods.""" | ||
969 | 498 | |||
970 | 499 | name = 'udf_autosubscribe' | ||
971 | 500 | getter = lambda _: sd_client.udf_autosubscribe_enabled() | ||
972 | 501 | enabler = lambda _: sd_client.enable_udf_autosubscribe() | ||
973 | 502 | disabler = lambda _: sd_client.disable_udf_autosubscribe() | ||
974 | 444 | 503 | ||
975 | 445 | 504 | ||
976 | 446 | class FoldersTestCase(BaseTestCase): | 505 | class FoldersTestCase(BaseTestCase): |
977 | 447 | 506 | ||
978 | === modified file 'ubuntuone/controlpanel/sd_client/linux.py' | |||
979 | --- ubuntuone/controlpanel/sd_client/linux.py 2011-05-26 22:08:32 +0000 | |||
980 | +++ ubuntuone/controlpanel/sd_client/linux.py 2011-06-17 14:51:05 +0000 | |||
981 | @@ -77,6 +77,21 @@ | |||
982 | 77 | return get_syncdaemon_tool().enable_throttling(False) | 77 | return get_syncdaemon_tool().enable_throttling(False) |
983 | 78 | 78 | ||
984 | 79 | 79 | ||
985 | 80 | def autoconnect_enabled(): | ||
986 | 81 | """Get the state of autoconnect in the syncdaemon.""" | ||
987 | 82 | return get_syncdaemon_tool().is_autoconnect_enabled() | ||
988 | 83 | |||
989 | 84 | |||
990 | 85 | def enable_autoconnect(): | ||
991 | 86 | """Enable autoconnect in the syncdaemon.""" | ||
992 | 87 | return get_syncdaemon_tool().enable_autoconnect(True) | ||
993 | 88 | |||
994 | 89 | |||
995 | 90 | def disable_autoconnect(): | ||
996 | 91 | """Disable autoconnect in the syncdaemon.""" | ||
997 | 92 | return get_syncdaemon_tool().enable_autoconnect(False) | ||
998 | 93 | |||
999 | 94 | |||
1000 | 80 | def show_all_notifications_enabled(): | 95 | def show_all_notifications_enabled(): |
1001 | 81 | """Get the state of show_all_notifications in the syncdaemon.""" | 96 | """Get the state of show_all_notifications in the syncdaemon.""" |
1002 | 82 | return get_syncdaemon_tool().is_show_all_notifications_enabled() | 97 | return get_syncdaemon_tool().is_show_all_notifications_enabled() |
1003 | @@ -92,6 +107,36 @@ | |||
1004 | 92 | return get_syncdaemon_tool().enable_show_all_notifications(False) | 107 | return get_syncdaemon_tool().enable_show_all_notifications(False) |
1005 | 93 | 108 | ||
1006 | 94 | 109 | ||
1007 | 110 | def share_autosubscribe_enabled(): | ||
1008 | 111 | """Get the state of share_autosubscribe in the syncdaemon.""" | ||
1009 | 112 | return get_syncdaemon_tool().is_share_autosubscribe_enabled() | ||
1010 | 113 | |||
1011 | 114 | |||
1012 | 115 | def enable_share_autosubscribe(): | ||
1013 | 116 | """Enable share_autosubscribe in the syncdaemon.""" | ||
1014 | 117 | return get_syncdaemon_tool().enable_share_autosubscribe(True) | ||
1015 | 118 | |||
1016 | 119 | |||
1017 | 120 | def disable_share_autosubscribe(): | ||
1018 | 121 | """Disable share_autosubscribe in the syncdaemon.""" | ||
1019 | 122 | return get_syncdaemon_tool().enable_share_autosubscribe(False) | ||
1020 | 123 | |||
1021 | 124 | |||
1022 | 125 | def udf_autosubscribe_enabled(): | ||
1023 | 126 | """Get the state of udf_autosubscribe in the syncdaemon.""" | ||
1024 | 127 | return get_syncdaemon_tool().is_udf_autosubscribe_enabled() | ||
1025 | 128 | |||
1026 | 129 | |||
1027 | 130 | def enable_udf_autosubscribe(): | ||
1028 | 131 | """Enable udf_autosubscribe in the syncdaemon.""" | ||
1029 | 132 | return get_syncdaemon_tool().enable_udf_autosubscribe(True) | ||
1030 | 133 | |||
1031 | 134 | |||
1032 | 135 | def disable_udf_autosubscribe(): | ||
1033 | 136 | """Disable udf_autosubscribe in the syncdaemon.""" | ||
1034 | 137 | return get_syncdaemon_tool().enable_udf_autosubscribe(False) | ||
1035 | 138 | |||
1036 | 139 | |||
1037 | 95 | def get_root_dir(): | 140 | def get_root_dir(): |
1038 | 96 | """Retrieve the root information from syncdaemon.""" | 141 | """Retrieve the root information from syncdaemon.""" |
1039 | 97 | return get_syncdaemon_tool().get_root_dir() | 142 | return get_syncdaemon_tool().get_root_dir() |
1040 | 98 | 143 | ||
1041 | === modified file 'ubuntuone/controlpanel/tests/__init__.py' | |||
1042 | --- ubuntuone/controlpanel/tests/__init__.py 2011-05-19 17:57:56 +0000 | |||
1043 | +++ ubuntuone/controlpanel/tests/__init__.py 2011-06-17 14:51:05 +0000 | |||
1044 | @@ -125,7 +125,10 @@ | |||
1045 | 125 | 'configurable': True, | 125 | 'configurable': True, |
1046 | 126 | 'device_id': 'ComputerABCDEF01234-localtoken', | 126 | 'device_id': 'ComputerABCDEF01234-localtoken', |
1047 | 127 | 'limit_bandwidth': False, | 127 | 'limit_bandwidth': False, |
1048 | 128 | 'autoconnect': True, | ||
1049 | 128 | 'show_all_notifications': True, | 129 | 'show_all_notifications': True, |
1050 | 130 | 'share_autosubscribe': False, | ||
1051 | 131 | 'udf_autosubscribe': False, | ||
1052 | 129 | 'max_download_speed': -1, | 132 | 'max_download_speed': -1, |
1053 | 130 | 'max_upload_speed': -1, | 133 | 'max_upload_speed': -1, |
1054 | 131 | 'name': 'Ubuntu One @ localhost', | 134 | 'name': 'Ubuntu One @ localhost', |
1055 | 132 | 135 | ||
1056 | === modified file 'ubuntuone/controlpanel/tests/test_backend.py' | |||
1057 | --- ubuntuone/controlpanel/tests/test_backend.py 2011-06-02 03:58:53 +0000 | |||
1058 | +++ ubuntuone/controlpanel/tests/test_backend.py 2011-06-17 14:51:05 +0000 | |||
1059 | @@ -63,6 +63,9 @@ | |||
1060 | 63 | ) | 63 | ) |
1061 | 64 | 64 | ||
1062 | 65 | 65 | ||
1063 | 66 | # pylint: disable=E1101 | ||
1064 | 67 | |||
1065 | 68 | |||
1066 | 66 | class MockWebClient(object): | 69 | class MockWebClient(object): |
1067 | 67 | """A mock webclient.""" | 70 | """A mock webclient.""" |
1068 | 68 | 71 | ||
1069 | @@ -104,6 +107,9 @@ | |||
1070 | 104 | 107 | ||
1071 | 105 | throttling = False | 108 | throttling = False |
1072 | 106 | show_all_notifications = True | 109 | show_all_notifications = True |
1073 | 110 | autoconnect = True | ||
1074 | 111 | udf_autosubscribe = False | ||
1075 | 112 | share_autosubscribe = False | ||
1076 | 107 | limits = {"download": -1, "upload": -1} | 113 | limits = {"download": -1, "upload": -1} |
1077 | 108 | file_sync = True | 114 | file_sync = True |
1078 | 109 | status = { | 115 | status = { |
1079 | @@ -151,6 +157,42 @@ | |||
1080 | 151 | """Disable show_all_notifications.""" | 157 | """Disable show_all_notifications.""" |
1081 | 152 | self.show_all_notifications = False | 158 | self.show_all_notifications = False |
1082 | 153 | 159 | ||
1083 | 160 | def autoconnect_enabled(self): | ||
1084 | 161 | """Return the state of autoconnect.""" | ||
1085 | 162 | return self.autoconnect | ||
1086 | 163 | |||
1087 | 164 | def enable_autoconnect(self): | ||
1088 | 165 | """Enable autoconnect.""" | ||
1089 | 166 | self.autoconnect = True | ||
1090 | 167 | |||
1091 | 168 | def disable_autoconnect(self): | ||
1092 | 169 | """Disable autoconnect.""" | ||
1093 | 170 | self.autoconnect = False | ||
1094 | 171 | |||
1095 | 172 | def udf_autosubscribe_enabled(self): | ||
1096 | 173 | """Return the state of udf_autosubscribe.""" | ||
1097 | 174 | return self.udf_autosubscribe | ||
1098 | 175 | |||
1099 | 176 | def enable_udf_autosubscribe(self): | ||
1100 | 177 | """Enable udf_autosubscribe.""" | ||
1101 | 178 | self.udf_autosubscribe = True | ||
1102 | 179 | |||
1103 | 180 | def disable_udf_autosubscribe(self): | ||
1104 | 181 | """Disable udf_autosubscribe.""" | ||
1105 | 182 | self.udf_autosubscribe = False | ||
1106 | 183 | |||
1107 | 184 | def share_autosubscribe_enabled(self): | ||
1108 | 185 | """Return the state of share_autosubscribe.""" | ||
1109 | 186 | return self.share_autosubscribe | ||
1110 | 187 | |||
1111 | 188 | def enable_share_autosubscribe(self): | ||
1112 | 189 | """Enable share_autosubscribe.""" | ||
1113 | 190 | self.share_autosubscribe = True | ||
1114 | 191 | |||
1115 | 192 | def disable_share_autosubscribe(self): | ||
1116 | 193 | """Disable share_autosubscribe.""" | ||
1117 | 194 | self.share_autosubscribe = False | ||
1118 | 195 | |||
1119 | 154 | def files_sync_enabled(self): | 196 | def files_sync_enabled(self): |
1120 | 155 | """Get if file sync service is enabled.""" | 197 | """Get if file sync service is enabled.""" |
1121 | 156 | return MockSDClient.file_sync | 198 | return MockSDClient.file_sync |
1122 | @@ -319,7 +361,6 @@ | |||
1123 | 319 | @inlineCallbacks | 361 | @inlineCallbacks |
1124 | 320 | def test_account_info(self): | 362 | def test_account_info(self): |
1125 | 321 | """The account_info method exercises its callback.""" | 363 | """The account_info method exercises its callback.""" |
1126 | 322 | # pylint: disable=E1101 | ||
1127 | 323 | self.be.wc.results[ACCOUNT_API] = SAMPLE_ACCOUNT_NO_CURRENT_PLAN | 364 | self.be.wc.results[ACCOUNT_API] = SAMPLE_ACCOUNT_NO_CURRENT_PLAN |
1128 | 324 | self.be.wc.results[QUOTA_API] = SAMPLE_QUOTA_JSON | 365 | self.be.wc.results[QUOTA_API] = SAMPLE_QUOTA_JSON |
1129 | 325 | result = yield self.be.account_info() | 366 | result = yield self.be.account_info() |
1130 | @@ -328,7 +369,6 @@ | |||
1131 | 328 | @inlineCallbacks | 369 | @inlineCallbacks |
1132 | 329 | def test_account_info_with_current_plan(self): | 370 | def test_account_info_with_current_plan(self): |
1133 | 330 | """The account_info method exercises its callback.""" | 371 | """The account_info method exercises its callback.""" |
1134 | 331 | # pylint: disable=E1101 | ||
1135 | 332 | self.be.wc.results[ACCOUNT_API] = SAMPLE_ACCOUNT_WITH_CURRENT_PLAN | 372 | self.be.wc.results[ACCOUNT_API] = SAMPLE_ACCOUNT_WITH_CURRENT_PLAN |
1136 | 333 | self.be.wc.results[QUOTA_API] = SAMPLE_QUOTA_JSON | 373 | self.be.wc.results[QUOTA_API] = SAMPLE_QUOTA_JSON |
1137 | 334 | result = yield self.be.account_info() | 374 | result = yield self.be.account_info() |
1138 | @@ -359,7 +399,6 @@ | |||
1139 | 359 | @inlineCallbacks | 399 | @inlineCallbacks |
1140 | 360 | def test_devices_info(self): | 400 | def test_devices_info(self): |
1141 | 361 | """The devices_info method exercises its callback.""" | 401 | """The devices_info method exercises its callback.""" |
1142 | 362 | # pylint: disable=E1101 | ||
1143 | 363 | self.be.wc.results[DEVICES_API] = SAMPLE_DEVICES_JSON | 402 | self.be.wc.results[DEVICES_API] = SAMPLE_DEVICES_JSON |
1144 | 364 | result = yield self.be.devices_info() | 403 | result = yield self.be.devices_info() |
1145 | 365 | self.assertEqual(result, EXPECTED_DEVICES_INFO) | 404 | self.assertEqual(result, EXPECTED_DEVICES_INFO) |
1146 | @@ -402,23 +441,24 @@ | |||
1147 | 402 | status = yield self.be.file_sync_status() | 441 | status = yield self.be.file_sync_status() |
1148 | 403 | assert status['status'] == backend.FILE_SYNC_DISABLED, status | 442 | assert status['status'] == backend.FILE_SYNC_DISABLED, status |
1149 | 404 | 443 | ||
1150 | 405 | # pylint: disable=E1101 | ||
1151 | 406 | self.be.wc.results[DEVICES_API] = SAMPLE_DEVICES_JSON | 444 | self.be.wc.results[DEVICES_API] = SAMPLE_DEVICES_JSON |
1152 | 407 | result = yield self.be.devices_info() | 445 | result = yield self.be.devices_info() |
1153 | 408 | 446 | ||
1154 | 409 | expected = EXPECTED_DEVICES_INFO[:] | 447 | expected = EXPECTED_DEVICES_INFO[:] |
1155 | 410 | for device in expected: | 448 | for device in expected: |
1156 | 411 | device.pop('limit_bandwidth', None) | 449 | device.pop('limit_bandwidth', None) |
1160 | 412 | device.pop('max_download_speed', None) | 450 | device.pop(backend.DOWNLOAD_KEY, None) |
1161 | 413 | device.pop('max_upload_speed', None) | 451 | device.pop(backend.UPLOAD_KEY, None) |
1162 | 414 | device.pop('show_all_notifications', None) | 452 | device.pop(backend.AUTOCONNECT_KEY, None) |
1163 | 453 | device.pop(backend.SHOW_ALL_NOTIFICATIONS_KEY, None) | ||
1164 | 454 | device.pop(backend.SHARE_AUTOSUBSCRIBE_KEY, None) | ||
1165 | 455 | device.pop(backend.UDF_AUTOSUBSCRIBE_KEY, None) | ||
1166 | 415 | device['configurable'] = False | 456 | device['configurable'] = False |
1167 | 416 | self.assertEqual(result, expected) | 457 | self.assertEqual(result, expected) |
1168 | 417 | 458 | ||
1169 | 418 | @inlineCallbacks | 459 | @inlineCallbacks |
1170 | 419 | def test_devices_info_when_token_name_is_empty(self): | 460 | def test_devices_info_when_token_name_is_empty(self): |
1171 | 420 | """The devices_info can handle empty token names.""" | 461 | """The devices_info can handle empty token names.""" |
1172 | 421 | # pylint: disable=E1101 | ||
1173 | 422 | self.be.wc.results[DEVICES_API] = EMPTY_DESCRIPTION_JSON | 462 | self.be.wc.results[DEVICES_API] = EMPTY_DESCRIPTION_JSON |
1174 | 423 | result = yield self.be.devices_info() | 463 | result = yield self.be.devices_info() |
1175 | 424 | expected = {'configurable': False, | 464 | expected = {'configurable': False, |
1176 | @@ -430,7 +470,6 @@ | |||
1177 | 430 | @inlineCallbacks | 470 | @inlineCallbacks |
1178 | 431 | def test_devices_info_does_not_log_device_id(self): | 471 | def test_devices_info_does_not_log_device_id(self): |
1179 | 432 | """The devices_info does not log the device_id.""" | 472 | """The devices_info does not log the device_id.""" |
1180 | 433 | # pylint: disable=E1101 | ||
1181 | 434 | self.be.wc.results[DEVICES_API] = SAMPLE_DEVICES_JSON | 473 | self.be.wc.results[DEVICES_API] = SAMPLE_DEVICES_JSON |
1182 | 435 | yield self.be.devices_info() | 474 | yield self.be.devices_info() |
1183 | 436 | 475 | ||
1184 | @@ -446,7 +485,6 @@ | |||
1185 | 446 | dtype, did = DEVICE_TYPE_COMPUTER, "SAMPLE-TOKEN" | 485 | dtype, did = DEVICE_TYPE_COMPUTER, "SAMPLE-TOKEN" |
1186 | 447 | device_id = dtype + did | 486 | device_id = dtype + did |
1187 | 448 | apiurl = DEVICE_REMOVE_API % (dtype.lower(), did) | 487 | apiurl = DEVICE_REMOVE_API % (dtype.lower(), did) |
1188 | 449 | # pylint: disable=E1101 | ||
1189 | 450 | self.be.wc.results[apiurl] = SAMPLE_DEVICES_JSON | 488 | self.be.wc.results[apiurl] = SAMPLE_DEVICES_JSON |
1190 | 451 | result = yield self.be.remove_device(device_id) | 489 | result = yield self.be.remove_device(device_id) |
1191 | 452 | self.assertEqual(result, device_id) | 490 | self.assertEqual(result, device_id) |
1192 | @@ -457,7 +495,6 @@ | |||
1193 | 457 | def test_remove_device_clear_credentials_if_local_device(self): | 495 | def test_remove_device_clear_credentials_if_local_device(self): |
1194 | 458 | """The remove_device method clears the credentials if is local.""" | 496 | """The remove_device method clears the credentials if is local.""" |
1195 | 459 | apiurl = DEVICE_REMOVE_API % ('computer', TOKEN['token']) | 497 | apiurl = DEVICE_REMOVE_API % ('computer', TOKEN['token']) |
1196 | 460 | # pylint: disable=E1101 | ||
1197 | 461 | self.be.wc.results[apiurl] = SAMPLE_DEVICES_JSON | 498 | self.be.wc.results[apiurl] = SAMPLE_DEVICES_JSON |
1198 | 462 | yield self.be.remove_device(self.local_token) | 499 | yield self.be.remove_device(self.local_token) |
1199 | 463 | # credentials were cleared | 500 | # credentials were cleared |
1200 | @@ -496,10 +533,10 @@ | |||
1201 | 496 | """The device settings are updated.""" | 533 | """The device settings are updated.""" |
1202 | 497 | backend.sd_client.show_all_notifications = False | 534 | backend.sd_client.show_all_notifications = False |
1203 | 498 | yield self.be.change_device_settings(self.local_token, | 535 | yield self.be.change_device_settings(self.local_token, |
1205 | 499 | {"show_all_notifications": True}) | 536 | {backend.SHOW_ALL_NOTIFICATIONS_KEY: True}) |
1206 | 500 | self.assertEqual(backend.sd_client.show_all_notifications, True) | 537 | self.assertEqual(backend.sd_client.show_all_notifications, True) |
1207 | 501 | yield self.be.change_device_settings(self.local_token, | 538 | yield self.be.change_device_settings(self.local_token, |
1209 | 502 | {"show_all_notifications": False}) | 539 | {backend.SHOW_ALL_NOTIFICATIONS_KEY: False}) |
1210 | 503 | self.assertEqual(backend.sd_client.show_all_notifications, False) | 540 | self.assertEqual(backend.sd_client.show_all_notifications, False) |
1211 | 504 | 541 | ||
1212 | 505 | @inlineCallbacks | 542 | @inlineCallbacks |
1213 | @@ -566,7 +603,6 @@ | |||
1214 | 566 | def setUp(self): | 603 | def setUp(self): |
1215 | 567 | super(BackendVolumesTestCase, self).setUp() | 604 | super(BackendVolumesTestCase, self).setUp() |
1216 | 568 | # fake quota info and calculate free bytes | 605 | # fake quota info and calculate free bytes |
1217 | 569 | # pylint: disable=E1101 | ||
1218 | 570 | self.be.wc.results[ACCOUNT_API] = SAMPLE_ACCOUNT_NO_CURRENT_PLAN | 606 | self.be.wc.results[ACCOUNT_API] = SAMPLE_ACCOUNT_NO_CURRENT_PLAN |
1219 | 571 | self.be.wc.results[QUOTA_API] = SAMPLE_QUOTA_JSON | 607 | self.be.wc.results[QUOTA_API] = SAMPLE_QUOTA_JSON |
1220 | 572 | 608 | ||
1221 | @@ -1009,7 +1045,6 @@ | |||
1222 | 1009 | self.be.status_changed_handler = self._set_called | 1045 | self.be.status_changed_handler = self._set_called |
1223 | 1010 | status = {'name': 'foo', 'description': 'bar', 'is_error': '', | 1046 | status = {'name': 'foo', 'description': 'bar', 'is_error': '', |
1224 | 1011 | 'is_connected': '', 'is_online': '', 'queues': ''} | 1047 | 'is_connected': '', 'is_online': '', 'queues': ''} |
1225 | 1012 | # pylint: disable=E1101 | ||
1226 | 1013 | backend.sd_client.status_changed_handler(status) | 1048 | backend.sd_client.status_changed_handler(status) |
1227 | 1014 | 1049 | ||
1228 | 1015 | # pylint: disable=W0212 | 1050 | # pylint: disable=W0212 |
1229 | @@ -1158,3 +1193,162 @@ | |||
1230 | 1158 | yield self.be.change_replication_settings(rid, {}) | 1193 | yield self.be.change_replication_settings(rid, {}) |
1231 | 1159 | 1194 | ||
1232 | 1160 | self.assertEqual(MockReplicationClient.exclusions, prior) | 1195 | self.assertEqual(MockReplicationClient.exclusions, prior) |
1233 | 1196 | |||
1234 | 1197 | |||
1235 | 1198 | class BackendFileSyncSettingsTestCase(BackendBasicTestCase): | ||
1236 | 1199 | """File Sync Settings tests for the backend.""" | ||
1237 | 1200 | |||
1238 | 1201 | default_settings = backend.ControlBackend.DEFAULT_FILE_SYNC_SETTINGS | ||
1239 | 1202 | |||
1240 | 1203 | @inlineCallbacks | ||
1241 | 1204 | def setUp(self): | ||
1242 | 1205 | yield super(BackendFileSyncSettingsTestCase, self).setUp() | ||
1243 | 1206 | # restore default settings | ||
1244 | 1207 | yield self.be.change_file_sync_settings(self.default_settings) | ||
1245 | 1208 | |||
1246 | 1209 | @inlineCallbacks | ||
1247 | 1210 | def assert_boolean_setting_is_correct(self, setting_name): | ||
1248 | 1211 | """The 'setting_name' can be successfully changed.""" | ||
1249 | 1212 | new_value = not self.default_settings[setting_name] | ||
1250 | 1213 | yield self.be.change_file_sync_settings({setting_name: new_value}) | ||
1251 | 1214 | |||
1252 | 1215 | self.assertEqual(getattr(backend.sd_client, setting_name), new_value) | ||
1253 | 1216 | |||
1254 | 1217 | actual = yield self.be.file_sync_settings_info() | ||
1255 | 1218 | expected = self.default_settings.copy() | ||
1256 | 1219 | expected[setting_name] = new_value | ||
1257 | 1220 | self.assertEqual(expected, actual) | ||
1258 | 1221 | |||
1259 | 1222 | @inlineCallbacks | ||
1260 | 1223 | def test_file_sync_settings_info(self): | ||
1261 | 1224 | """The settings_info method exercises its callback.""" | ||
1262 | 1225 | backend.sd_client.limits = {"download": 1000, "upload": 100} | ||
1263 | 1226 | expected = { | ||
1264 | 1227 | backend.AUTOCONNECT_KEY: backend.sd_client.autoconnect, | ||
1265 | 1228 | backend.SHOW_ALL_NOTIFICATIONS_KEY: | ||
1266 | 1229 | backend.sd_client.show_all_notifications, | ||
1267 | 1230 | backend.SHARE_AUTOSUBSCRIBE_KEY: | ||
1268 | 1231 | backend.sd_client.share_autosubscribe, | ||
1269 | 1232 | backend.UDF_AUTOSUBSCRIBE_KEY: | ||
1270 | 1233 | backend.sd_client.udf_autosubscribe, | ||
1271 | 1234 | backend.DOWNLOAD_KEY: backend.sd_client.limits['download'], | ||
1272 | 1235 | backend.UPLOAD_KEY: backend.sd_client.limits['upload'], | ||
1273 | 1236 | } | ||
1274 | 1237 | result = yield self.be.file_sync_settings_info() | ||
1275 | 1238 | self.assertEqual(expected, result) | ||
1276 | 1239 | |||
1277 | 1240 | @inlineCallbacks | ||
1278 | 1241 | def test_change_file_sync_setting_autoconnect(self): | ||
1279 | 1242 | """The settings can be changed for autoconnect.""" | ||
1280 | 1243 | yield self.assert_boolean_setting_is_correct(backend.AUTOCONNECT_KEY) | ||
1281 | 1244 | |||
1282 | 1245 | @inlineCallbacks | ||
1283 | 1246 | def test_change_file_sync_setting_show_all_notifications(self): | ||
1284 | 1247 | """The settings can be changed for show_all_notifications.""" | ||
1285 | 1248 | yield self.assert_boolean_setting_is_correct( | ||
1286 | 1249 | backend.SHOW_ALL_NOTIFICATIONS_KEY) | ||
1287 | 1250 | |||
1288 | 1251 | @inlineCallbacks | ||
1289 | 1252 | def test_change_file_sync_setting_share_autosubscribe(self): | ||
1290 | 1253 | """The settings can be changed for share_autosubscribe.""" | ||
1291 | 1254 | yield self.assert_boolean_setting_is_correct( | ||
1292 | 1255 | backend.SHARE_AUTOSUBSCRIBE_KEY) | ||
1293 | 1256 | |||
1294 | 1257 | @inlineCallbacks | ||
1295 | 1258 | def test_change_file_sync_setting_udf_autosubscribe(self): | ||
1296 | 1259 | """The settings can be changed for udf_autosubscribe.""" | ||
1297 | 1260 | yield self.assert_boolean_setting_is_correct( | ||
1298 | 1261 | backend.UDF_AUTOSUBSCRIBE_KEY) | ||
1299 | 1262 | |||
1300 | 1263 | @inlineCallbacks | ||
1301 | 1264 | def test_change_file_sync_setting_download_bandwidth_limit(self): | ||
1302 | 1265 | """The settings can be changed for download_bandwidth_limit.""" | ||
1303 | 1266 | new_value = 834 | ||
1304 | 1267 | setting_name = backend.DOWNLOAD_KEY | ||
1305 | 1268 | yield self.be.change_file_sync_settings({setting_name: new_value}) | ||
1306 | 1269 | |||
1307 | 1270 | self.assertEqual(backend.sd_client.throttling, True) | ||
1308 | 1271 | self.assertEqual(backend.sd_client.limits, | ||
1309 | 1272 | {'download': new_value, 'upload': -1}) | ||
1310 | 1273 | |||
1311 | 1274 | @inlineCallbacks | ||
1312 | 1275 | def test_change_file_sync_setting_upload_bandwidth_limit(self): | ||
1313 | 1276 | """The settings can be changed for upload_bandwidth_limit.""" | ||
1314 | 1277 | new_value = 932 | ||
1315 | 1278 | setting_name = backend.UPLOAD_KEY | ||
1316 | 1279 | yield self.be.change_file_sync_settings({setting_name: new_value}) | ||
1317 | 1280 | |||
1318 | 1281 | self.assertEqual(backend.sd_client.throttling, True) | ||
1319 | 1282 | self.assertEqual(backend.sd_client.limits, | ||
1320 | 1283 | {'download': -1, 'upload': new_value}) | ||
1321 | 1284 | |||
1322 | 1285 | @inlineCallbacks | ||
1323 | 1286 | def test_no_download_limit_and_upload_change_to_no_limit(self): | ||
1324 | 1287 | """The settings can be changed for download_bandwidth_limit. | ||
1325 | 1288 | |||
1326 | 1289 | If the download limit was not set and the upload was set, when | ||
1327 | 1290 | unsetting the upload limit the bandwidth_throttling_enabled is False. | ||
1328 | 1291 | |||
1329 | 1292 | """ | ||
1330 | 1293 | only_one_limit_set = { | ||
1331 | 1294 | backend.DOWNLOAD_KEY: -1, | ||
1332 | 1295 | backend.UPLOAD_KEY: 52, | ||
1333 | 1296 | } | ||
1334 | 1297 | yield self.be.change_file_sync_settings(only_one_limit_set) | ||
1335 | 1298 | |||
1336 | 1299 | # unset upload_bandwidth_limit | ||
1337 | 1300 | setting_name = backend.UPLOAD_KEY | ||
1338 | 1301 | yield self.be.change_file_sync_settings({setting_name: -1}) | ||
1339 | 1302 | |||
1340 | 1303 | self.assertEqual(backend.sd_client.throttling, False) | ||
1341 | 1304 | self.assertEqual(backend.sd_client.limits, | ||
1342 | 1305 | {'download': -1, 'upload': -1}) | ||
1343 | 1306 | |||
1344 | 1307 | @inlineCallbacks | ||
1345 | 1308 | def test_no_upload_limit_and_download_change_to_no_limit(self): | ||
1346 | 1309 | """The settings can be changed for upload_bandwidth_limit. | ||
1347 | 1310 | |||
1348 | 1311 | If the upload limit was not set and the download was set, when | ||
1349 | 1312 | unsetting the download limit the bandwidth_throttling_enabled is False. | ||
1350 | 1313 | |||
1351 | 1314 | """ | ||
1352 | 1315 | only_one_limit_set = { | ||
1353 | 1316 | backend.DOWNLOAD_KEY: 33, | ||
1354 | 1317 | backend.UPLOAD_KEY: -1, | ||
1355 | 1318 | } | ||
1356 | 1319 | yield self.be.change_file_sync_settings(only_one_limit_set) | ||
1357 | 1320 | |||
1358 | 1321 | # unset download_bandwidth_limit | ||
1359 | 1322 | setting_name = backend.DOWNLOAD_KEY | ||
1360 | 1323 | yield self.be.change_file_sync_settings({setting_name: -1}) | ||
1361 | 1324 | |||
1362 | 1325 | self.assertEqual(backend.sd_client.throttling, False) | ||
1363 | 1326 | self.assertEqual(backend.sd_client.limits, | ||
1364 | 1327 | {'download': -1, 'upload': -1}) | ||
1365 | 1328 | |||
1366 | 1329 | @inlineCallbacks | ||
1367 | 1330 | def test_restore_defaults(self): | ||
1368 | 1331 | """The defaults can be restored.""" | ||
1369 | 1332 | not_defaults = { | ||
1370 | 1333 | backend.AUTOCONNECT_KEY: False, | ||
1371 | 1334 | backend.SHOW_ALL_NOTIFICATIONS_KEY: False, | ||
1372 | 1335 | backend.SHARE_AUTOSUBSCRIBE_KEY: True, | ||
1373 | 1336 | backend.UDF_AUTOSUBSCRIBE_KEY: True, | ||
1374 | 1337 | backend.DOWNLOAD_KEY: 204800, | ||
1375 | 1338 | backend.UPLOAD_KEY: 2048, | ||
1376 | 1339 | } | ||
1377 | 1340 | yield self.be.change_file_sync_settings(not_defaults) | ||
1378 | 1341 | |||
1379 | 1342 | # the call we want to test | ||
1380 | 1343 | yield self.be.restore_file_sync_settings() | ||
1381 | 1344 | |||
1382 | 1345 | self.assertEqual(backend.sd_client.autoconnect, True) | ||
1383 | 1346 | self.assertEqual(backend.sd_client.show_all_notifications, True) | ||
1384 | 1347 | self.assertEqual(backend.sd_client.share_autosubscribe, False) | ||
1385 | 1348 | self.assertEqual(backend.sd_client.udf_autosubscribe, False) | ||
1386 | 1349 | self.assertEqual(backend.sd_client.throttling, False) | ||
1387 | 1350 | self.assertEqual(backend.sd_client.limits, | ||
1388 | 1351 | {'download': -1, 'upload': -1}) | ||
1389 | 1352 | |||
1390 | 1353 | result = yield self.be.file_sync_settings_info() | ||
1391 | 1354 | self.assertEqual(self.default_settings, result) |
Attempt to merge into lp:ubuntuone-control-panel failed due to conflicts:
text conflict in ubuntuone/ controlpanel/ gui/qt/ folders. py