Merge lp:~elopio/ubuntuone-testing/stabilize-files into lp:ubuntuone-testing
- stabilize-files
- Merge into trunk
Proposed by
Leo Arias
Status: | Merged |
---|---|
Approved by: | Rick McBride |
Approved revision: | 81 |
Merged at revision: | 75 |
Proposed branch: | lp:~elopio/ubuntuone-testing/stabilize-files |
Merge into: | lp:ubuntuone-testing |
Diff against target: |
493 lines (+135/-133) 11 files modified
config-manager.txt (+1/-1) ubuntuone/web/tests/sst/files/u1webf001_uploadfile.py (+1/-1) ubuntuone/web/tests/sst/files/u1webf002_publishfile.py (+1/-1) ubuntuone/web/tests/sst/files/u1webf003_stoppublishingfile.py (+1/-1) ubuntuone/web/tests/sst/files/u1webf004_downloadfile.py (+1/-1) ubuntuone/web/tests/sst/files/u1webf005_deletefile.py (+1/-1) ubuntuone/web/tests/sst/files/u1webf006_createfolder.py (+3/-2) ubuntuone/web/tests/sst/files/u1webf007_sharefolder.py (+6/-5) ubuntuone/web/tests/sst/files/u1webf008_stopsharingfolder.py (+8/-7) ubuntuone/web/tests/sst/files/u1webf009_deletefolder.py (+3/-3) ubuntuone/web/tests/sst/shared/actions/files.py (+109/-110) |
To merge this branch: | bzr merge lp:~elopio/ubuntuone-testing/stabilize-files |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rick McBride (community) | Approve | ||
Review via email: mp+91189@code.launchpad.net |
Commit message
Stabilize files tests.
Description of the change
Fixes and clean-ups to stabilize the files tests.
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 'config-manager.txt' |
2 | --- config-manager.txt 2012-01-18 19:14:02 +0000 |
3 | +++ config-manager.txt 2012-02-02 00:21:17 +0000 |
4 | @@ -4,4 +4,4 @@ |
5 | # make clean-sourcedeps update-sourcedeps |
6 | # |
7 | |
8 | -./sourcecode/selenium-simple-test bzr+ssh://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk;revno=224 |
9 | +./sourcecode/selenium-simple-test bzr+ssh://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk;revno=256 |
10 | |
11 | === modified file 'ubuntuone/web/tests/sst/files/u1webf001_uploadfile.py' |
12 | --- ubuntuone/web/tests/sst/files/u1webf001_uploadfile.py 2011-12-14 00:27:17 +0000 |
13 | +++ ubuntuone/web/tests/sst/files/u1webf001_uploadfile.py 2012-02-02 00:21:17 +0000 |
14 | @@ -34,7 +34,7 @@ |
15 | file_uuid = str(uuid.uuid1()) |
16 | file_contents = 'This is test file %s' % file_uuid |
17 | file_name = None |
18 | -with tempfile.NamedTemporaryFile(mode='wr', prefix='Test upload from website', |
19 | +with tempfile.NamedTemporaryFile(mode='wr', prefix='New file ', |
20 | suffix=file_uuid + '.txt', |
21 | delete=False) as upload: |
22 | upload.write(file_contents) |
23 | |
24 | === modified file 'ubuntuone/web/tests/sst/files/u1webf002_publishfile.py' |
25 | --- ubuntuone/web/tests/sst/files/u1webf002_publishfile.py 2011-12-14 00:27:17 +0000 |
26 | +++ ubuntuone/web/tests/sst/files/u1webf002_publishfile.py 2012-02-02 00:21:17 +0000 |
27 | @@ -35,7 +35,7 @@ |
28 | file_contents = 'This is test file %s' % file_uuid |
29 | file_name = None |
30 | with tempfile.NamedTemporaryFile(mode='wr', |
31 | - prefix='Test publish from website', |
32 | + prefix='File to publish ', |
33 | suffix=file_uuid + '.txt', |
34 | delete=False) as upload: |
35 | upload.write(file_contents) |
36 | |
37 | === modified file 'ubuntuone/web/tests/sst/files/u1webf003_stoppublishingfile.py' |
38 | --- ubuntuone/web/tests/sst/files/u1webf003_stoppublishingfile.py 2011-12-14 00:27:17 +0000 |
39 | +++ ubuntuone/web/tests/sst/files/u1webf003_stoppublishingfile.py 2012-02-02 00:21:17 +0000 |
40 | @@ -35,7 +35,7 @@ |
41 | file_contents = 'This is test file %s' % file_uuid |
42 | file_name = None |
43 | with tempfile.NamedTemporaryFile(mode='wr', |
44 | - prefix='Test stop publishing from website', |
45 | + prefix='File to stop publishing ', |
46 | suffix=file_uuid + '.txt', |
47 | delete=False) as upload: |
48 | upload.write(file_contents) |
49 | |
50 | === modified file 'ubuntuone/web/tests/sst/files/u1webf004_downloadfile.py' |
51 | --- ubuntuone/web/tests/sst/files/u1webf004_downloadfile.py 2011-12-14 00:27:17 +0000 |
52 | +++ ubuntuone/web/tests/sst/files/u1webf004_downloadfile.py 2012-02-02 00:21:17 +0000 |
53 | @@ -36,7 +36,7 @@ |
54 | file_contents = 'This is test file %s' % file_uuid |
55 | file_name = None |
56 | with tempfile.NamedTemporaryFile(mode='wr', |
57 | - prefix='Test download from website', |
58 | + prefix='File to download ', |
59 | suffix=file_uuid + '.txt', |
60 | delete=False) as upload: |
61 | upload.write(file_contents) |
62 | |
63 | === modified file 'ubuntuone/web/tests/sst/files/u1webf005_deletefile.py' |
64 | --- ubuntuone/web/tests/sst/files/u1webf005_deletefile.py 2011-11-07 17:14:03 +0000 |
65 | +++ ubuntuone/web/tests/sst/files/u1webf005_deletefile.py 2012-02-02 00:21:17 +0000 |
66 | @@ -35,7 +35,7 @@ |
67 | file_contents = 'This is test file %s' % file_uuid |
68 | file_name = None |
69 | with tempfile.NamedTemporaryFile(mode='wr', |
70 | - prefix='Test delete from website', |
71 | + prefix='File to delete ', |
72 | suffix=file_uuid + '.txt', |
73 | delete=False) as upload: |
74 | upload.write(file_contents) |
75 | |
76 | === modified file 'ubuntuone/web/tests/sst/files/u1webf006_createfolder.py' |
77 | --- ubuntuone/web/tests/sst/files/u1webf006_createfolder.py 2011-10-03 08:50:46 +0000 |
78 | +++ ubuntuone/web/tests/sst/files/u1webf006_createfolder.py 2012-02-02 00:21:17 +0000 |
79 | @@ -25,11 +25,12 @@ |
80 | from sst.actions import * |
81 | import actions.setup as setup_actions |
82 | import actions.files as files_actions |
83 | -from random import random |
84 | +import uuid |
85 | |
86 | setup_actions.setup() |
87 | files_actions.open() |
88 | -folder_name = 'New Folder %f' % random() |
89 | +folder_uuid = str(uuid.uuid1()) |
90 | +folder_name = 'New folder %s' % folder_uuid |
91 | files_actions.create_new_folder(folder_name) |
92 | files_actions.assert_file_exists(folder_name) |
93 | assert files_actions.get_file_size(folder_name) == ' ' |
94 | |
95 | === modified file 'ubuntuone/web/tests/sst/files/u1webf007_sharefolder.py' |
96 | --- ubuntuone/web/tests/sst/files/u1webf007_sharefolder.py 2011-10-04 07:13:54 +0000 |
97 | +++ ubuntuone/web/tests/sst/files/u1webf007_sharefolder.py 2012-02-02 00:21:17 +0000 |
98 | @@ -25,17 +25,18 @@ |
99 | from sst.actions import * |
100 | import actions.setup as setup_actions |
101 | import actions.files as files_actions |
102 | -from random import random |
103 | -from datetime import date |
104 | +import uuid |
105 | +from datetime import datetime |
106 | |
107 | setup_actions.setup() |
108 | files_actions.open() |
109 | -folder_name = 'Shared Folder %f' % random() |
110 | +folder_uuid = str(uuid.uuid1()) |
111 | +folder_name = 'Folder to share %s' % folder_uuid |
112 | files_actions.create_new_folder(folder_name) |
113 | files_actions.assert_file_exists(folder_name) |
114 | -email_address = 'test@example.com' |
115 | +email_address = '%s@elopio.net' % folder_uuid |
116 | files_actions.share_folder(folder_name, email_address, folder_name) |
117 | files_actions.assert_folder_information_is_shown(folder_name) |
118 | files_actions.assert_folder_shared(folder_name, email_address, |
119 | - date=date.today()) |
120 | + date=datetime.utcnow()) |
121 | |
122 | |
123 | === modified file 'ubuntuone/web/tests/sst/files/u1webf008_stopsharingfolder.py' |
124 | --- ubuntuone/web/tests/sst/files/u1webf008_stopsharingfolder.py 2011-10-03 08:50:46 +0000 |
125 | +++ ubuntuone/web/tests/sst/files/u1webf008_stopsharingfolder.py 2012-02-02 00:21:17 +0000 |
126 | @@ -26,16 +26,17 @@ |
127 | from sst.actions import * |
128 | import actions.setup as setup_actions |
129 | import actions.files as files_actions |
130 | -from random import random |
131 | -from datetime import date |
132 | +import uuid |
133 | +from datetime import datetime |
134 | |
135 | setup_actions.setup() |
136 | files_actions.open() |
137 | -folder_name = 'Shared Folder %f' % random() |
138 | +folder_uuid = str(uuid.uuid1()) |
139 | +folder_name = 'Folder to stop sharing %s' % folder_uuid |
140 | files_actions.create_new_folder(folder_name) |
141 | files_actions.assert_file_exists(folder_name) |
142 | -email_address = 'test@example.com' |
143 | +email_address = '%s@elopio.net' % folder_uuid |
144 | files_actions.share_folder(folder_name, email_address, folder_name) |
145 | -files_actions.stop_sharing_folder(folder_name, email_address, date.today()) |
146 | -fails(files_actions.assert_folder_shared, folder_name, email_address, |
147 | - date.today()) |
148 | +today = datetime.utcnow() |
149 | +files_actions.stop_sharing_folder(folder_name, email_address, today) |
150 | +fails(files_actions.assert_folder_shared, folder_name, email_address, today) |
151 | |
152 | === modified file 'ubuntuone/web/tests/sst/files/u1webf009_deletefolder.py' |
153 | --- ubuntuone/web/tests/sst/files/u1webf009_deletefolder.py 2011-10-03 08:50:46 +0000 |
154 | +++ ubuntuone/web/tests/sst/files/u1webf009_deletefolder.py 2012-02-02 00:21:17 +0000 |
155 | @@ -25,12 +25,12 @@ |
156 | from sst.actions import * |
157 | import actions.setup as setup_actions |
158 | import actions.files as files_actions |
159 | -from random import random |
160 | -from datetime import date |
161 | +import uuid |
162 | |
163 | setup_actions.setup() |
164 | files_actions.open() |
165 | -folder_name = 'Deleted Folder %f' % random() |
166 | +folder_uuid = str(uuid.uuid1()) |
167 | +folder_name = 'Folder to delete %s' % folder_uuid |
168 | files_actions.create_new_folder(folder_name) |
169 | files_actions.assert_file_exists(folder_name) |
170 | files_actions.delete_file(folder_name) |
171 | |
172 | === modified file 'ubuntuone/web/tests/sst/shared/actions/files.py' |
173 | --- ubuntuone/web/tests/sst/shared/actions/files.py 2011-12-09 18:24:02 +0000 |
174 | +++ ubuntuone/web/tests/sst/shared/actions/files.py 2012-02-02 00:21:17 +0000 |
175 | @@ -37,24 +37,6 @@ |
176 | """Assert that the title of the page is the expected.""" |
177 | assert_title(u'Ubuntu One : My Storage') |
178 | |
179 | -def click_upload_file(): |
180 | - """Click the Upload file button and wait for the upload overlay |
181 | - to appear. |
182 | - |
183 | - """ |
184 | - click_element('upload-file-button', wait=False) |
185 | - upload_overlay = get_element(id='upload-overlay') |
186 | - wait_for(upload_overlay.is_displayed) |
187 | - |
188 | -def click_new_folder(): |
189 | - """Click the New folder link and wait for the new folder overlay |
190 | - to appear. |
191 | - |
192 | - """ |
193 | - click_element('new-folder-button', wait=False) |
194 | - new_folder_overlay = get_element(id='new-folder-overlay') |
195 | - wait_for(new_folder_overlay.is_displayed) |
196 | - |
197 | def upload_file(path): |
198 | """Upload a file. |
199 | |
200 | @@ -69,6 +51,15 @@ |
201 | # TODO set a waiting time proportional to the size of the file to upload. |
202 | wait_for_action_to_complete() |
203 | |
204 | +def click_upload_file(): |
205 | + """Click the Upload file button and wait for the upload overlay |
206 | + to appear. |
207 | + |
208 | + """ |
209 | + click_element('upload-file-button', wait=False) |
210 | + upload_overlay = get_element(id='upload-overlay') |
211 | + wait_for(upload_overlay.is_displayed) |
212 | + |
213 | def assert_file_exists(name): |
214 | """Assert that a file exists on the Ubuntu One storage. |
215 | |
216 | @@ -80,6 +71,29 @@ |
217 | get_element_by_xpath('//td[@class="files-td-name" and @id="%(name)s"]' |
218 | % {'name': name}) |
219 | |
220 | +def create_new_folder(name): |
221 | + """Create a new folder on the Ubuntu One storage service. |
222 | + |
223 | + The folder will be created as a child of the currently selected one. |
224 | + |
225 | + Keyword arguments: |
226 | + name -- The name of the folder. |
227 | + |
228 | + """ |
229 | + click_new_folder() |
230 | + write_textfield('new-folder-overlay-name', name) |
231 | + click_button('new-folder-overlay-create-button') |
232 | + wait_for_action_to_complete() |
233 | + |
234 | +def click_new_folder(): |
235 | + """Click the New folder link and wait for the new folder overlay |
236 | + to appear. |
237 | + |
238 | + """ |
239 | + click_element('new-folder-button', wait=False) |
240 | + new_folder_overlay = get_element(id='new-folder-overlay') |
241 | + wait_for(new_folder_overlay.is_displayed) |
242 | + |
243 | def get_file_row_element(name): |
244 | """Get the HTML row of a file. |
245 | |
246 | @@ -122,6 +136,10 @@ |
247 | return element_file_row. \ |
248 | find_element_by_xpath('td[@class="files-td-size"]').text |
249 | |
250 | +def show_file_details(name): |
251 | + if not _are_details_shown: |
252 | + _click_file_more(name) |
253 | + |
254 | def _are_details_shown(name): |
255 | identifier = _get_file_identifier(name) |
256 | element_details = get_element(id='%s-details' % identifier) |
257 | @@ -139,9 +157,18 @@ |
258 | 'td[@class="files-td-expander expand-row-link"]/a') |
259 | click_element(element_more) |
260 | |
261 | -def show_file_details(name): |
262 | - if not _are_details_shown: |
263 | - _click_file_more(name) |
264 | +def assert_file_information_is_shown(name): |
265 | + """Assert that the full information of a file is shown. |
266 | + |
267 | + Keyword arguments: |
268 | + name -- The name of the file. |
269 | + |
270 | + """ |
271 | + assert _are_details_shown(name) |
272 | + identifier = _get_file_identifier(name) |
273 | + assert _get_link_publish_file(identifier).is_displayed() |
274 | + assert _get_link_download_file(identifier).is_displayed() |
275 | + assert _get_link_delete_file(identifier).is_displayed() |
276 | |
277 | def _get_link_publish_file(identifier): |
278 | """Get the Publish File link element. |
279 | @@ -163,7 +190,6 @@ |
280 | return get_element(id='%s-publish' % identifier, |
281 | css_class='u1-files-stop-publishing-link') |
282 | |
283 | - |
284 | def _get_link_download_file(identifier): |
285 | """Get the Download file link element. |
286 | |
287 | @@ -184,19 +210,6 @@ |
288 | """ |
289 | return get_element(id='%s-delete' % identifier) |
290 | |
291 | -def assert_file_information_is_shown(name): |
292 | - """Assert that the full information of a file is shown. |
293 | - |
294 | - Keyword arguments: |
295 | - name -- The name of the file. |
296 | - |
297 | - """ |
298 | - assert _are_details_shown(name) |
299 | - identifier = _get_file_identifier(name) |
300 | - assert _get_link_publish_file(identifier).is_displayed() |
301 | - assert _get_link_download_file(identifier).is_displayed() |
302 | - assert _get_link_delete_file(identifier).is_displayed() |
303 | - |
304 | def assert_file_type(name, type): |
305 | """Assert that the type of a file is the expected. |
306 | |
307 | @@ -284,7 +297,6 @@ |
308 | _get_link_publish_file(identifier) |
309 | fails(get_public_url, name) |
310 | |
311 | - |
312 | def click_download_file(name): |
313 | """Download a file stored on the Ubuntu One service. |
314 | |
315 | @@ -306,20 +318,6 @@ |
316 | identifier = _get_file_identifier(name) |
317 | return _get_link_download_file(identifier).get_attribute('href') |
318 | |
319 | -def create_new_folder(name): |
320 | - """Create a new folder on the Ubuntu One storage service. |
321 | - |
322 | - The folder will be created as a child of the currently selected one. |
323 | - |
324 | - Keyword arguments: |
325 | - name -- The name of the folder. |
326 | - |
327 | - """ |
328 | - click_new_folder() |
329 | - write_textfield('new-folder-overlay-name', name) |
330 | - click_button('new-folder-overlay-create-button') |
331 | - wait_for_action_to_complete() |
332 | - |
333 | def _get_link_share_folder(identifier): |
334 | """Get the Share folder link element. |
335 | |
336 | @@ -418,32 +416,26 @@ |
337 | click_button('sharing-overlay-share-button') |
338 | wait_for_action_to_complete() |
339 | |
340 | -def _get_shared_with_elements(name): |
341 | - """Get the HTML elements with the information of the shared folder. |
342 | - |
343 | - Keyword arguments: |
344 | - name -- The name of the shared folder. |
345 | - |
346 | - Returns a list with the HTML elements of all the shares for the folder. |
347 | - |
348 | - """ |
349 | - identifier = _get_file_identifier(name) |
350 | - elements_shared_information = get_elements_by_css('#%s-details ' |
351 | - 'li.shared-with' |
352 | - % identifier) |
353 | - return elements_shared_information |
354 | - |
355 | -def _get_shared_with_information(name): |
356 | - """Get the information of the shared folder. |
357 | - |
358 | - Keyword arguments: |
359 | - name -- The name of the shared folder. |
360 | - |
361 | - Returns a list with the information of all the shares for the folder. |
362 | - |
363 | - """ |
364 | - elements_shared_information = _get_shared_with_elements(name) |
365 | - return [element.text for element in elements_shared_information] |
366 | +def assert_folder_shared(name, email, date, allow_modification=True, |
367 | + accepted=False): |
368 | + """Assert that a folder is shared. |
369 | + |
370 | + Keyword arguments: |
371 | + name -- The name of the shared folder. |
372 | + email -- The email address of the person who received the shared folder. |
373 | + date -- The date the folder was shared. |
374 | + allow_modification -- Indicates if the recipient of the shared folder is |
375 | + allowed to modify it. The default value is True. |
376 | + accepted -- Indicates if the folder has been accepted by the recipient. |
377 | + The default value is False. |
378 | + |
379 | + """ |
380 | + show_file_details(name) |
381 | + expected_shared_information = \ |
382 | + _build_shared_information_string(name, email, date, allow_modification, |
383 | + accepted) |
384 | + folder_shared_information = _get_shared_with_information(name) |
385 | + assert expected_shared_information in folder_shared_information |
386 | |
387 | def _build_shared_information_string(name, email, date, |
388 | allow_modification=True, accepted=False): |
389 | @@ -472,28 +464,56 @@ |
390 | shared_information += ' Stop sharing' |
391 | return shared_information |
392 | |
393 | -def assert_folder_shared(name, email, date, allow_modification=True, |
394 | - accepted=False): |
395 | - """Assert that a folder is shared. |
396 | - |
397 | +def _get_shared_with_information(name): |
398 | + """Get the information of the shared folder. |
399 | + |
400 | + Keyword arguments: |
401 | + name -- The name of the shared folder. |
402 | + |
403 | + Returns a list with the information of all the shares for the folder. |
404 | + |
405 | + """ |
406 | + elements_shared_information = _get_shared_with_elements(name) |
407 | + return [element.text for element in elements_shared_information] |
408 | + |
409 | +def _get_shared_with_elements(name): |
410 | + """Get the HTML elements with the information of the shared folder. |
411 | + |
412 | + Keyword arguments: |
413 | + name -- The name of the shared folder. |
414 | + |
415 | + Returns a list with the HTML elements of all the shares for the folder. |
416 | + |
417 | + """ |
418 | + identifier = _get_file_identifier(name) |
419 | + elements_shared_information = get_elements_by_css('#%s-details ' |
420 | + 'li.shared-with' |
421 | + % identifier) |
422 | + return elements_shared_information |
423 | + |
424 | +def stop_sharing_folder(name, email, date, allow_modification=True, |
425 | + accepted=False): |
426 | + """Stop sharing a folder. |
427 | + |
428 | Keyword arguments: |
429 | name -- The name of the shared folder. |
430 | email -- The email address of the person who received the shared folder. |
431 | date -- The date the folder was shared. |
432 | - allow_modification -- Indicates if the recipient of the shared folder is |
433 | + allow_modification -- Indicates if the recipient of the shared folder is |
434 | allowed to modify it. The default value is True. |
435 | accepted -- Indicates if the folder has been accepted by the recipient. |
436 | - The default value is False. |
437 | + The default value is False. |
438 | |
439 | """ |
440 | show_file_details(name) |
441 | - expected_shared_information = \ |
442 | - _build_shared_information_string(name, email, date, allow_modification, |
443 | - accepted) |
444 | - folder_shared_information = _get_shared_with_information(name) |
445 | - assert expected_shared_information in folder_shared_information |
446 | + link_stop_sharing = _get_stop_sharing_folder_link(name, email, date, |
447 | + allow_modification, |
448 | + accepted) |
449 | + click_element(link_stop_sharing, wait=False) |
450 | + accept_alert() |
451 | + wait_for_action_to_complete() |
452 | |
453 | -def _get_stop_sharing_folder(name, email, date, allow_modification=True, |
454 | +def _get_stop_sharing_folder_link(name, email, date, allow_modification=True, |
455 | accepted=False): |
456 | """Get the link to stop sharing a folder. |
457 | |
458 | @@ -517,27 +537,6 @@ |
459 | assert folder_list, 'Stop sharing link not found.' |
460 | return folder_list[0].find_element_by_css_selector('a') |
461 | |
462 | -def stop_sharing_folder(name, email, date, allow_modification=True, |
463 | - accepted=False): |
464 | - """Stop sharing a folder. |
465 | - |
466 | - Keyword arguments: |
467 | - name -- The name of the shared folder. |
468 | - email -- The email address of the person who received the shared folder. |
469 | - date -- The date the folder was shared. |
470 | - allow_modification -- Indicates if the recipient of the shared folder is |
471 | - allowed to modify it. The default value is True. |
472 | - accepted -- Indicates if the folder has been accepted by the recipient. |
473 | - The default value is False. |
474 | - |
475 | - """ |
476 | - show_file_details(name) |
477 | - link_stop_sharing = _get_stop_sharing_folder(name, email, date, |
478 | - allow_modification, accepted) |
479 | - click_element(link_stop_sharing) |
480 | - accept_alert() |
481 | - wait_for_action_to_complete() |
482 | - |
483 | def delete_file(name): |
484 | """Delete a file or folder. |
485 | |
486 | @@ -548,6 +547,6 @@ |
487 | show_file_details(name) |
488 | identifier = _get_file_identifier(name) |
489 | link_delete = _get_link_delete_file(identifier) |
490 | - click_element(link_delete) |
491 | + click_element(link_delete, wait=False) |
492 | accept_alert() |
493 | wait_for_action_to_complete() |
+1