Merge lp:~elopio/ubuntuone-testing/fix-files-this-time-for-real into lp:ubuntuone-testing

Proposed by Leo Arias
Status: Merged
Approved by: Rick McBride
Approved revision: 56
Merged at revision: 52
Proposed branch: lp:~elopio/ubuntuone-testing/fix-files-this-time-for-real
Merge into: lp:ubuntuone-testing
Diff against target: 259 lines (+109/-28)
6 files modified
ubuntuone/web/tests/sst/files/u1webf001_uploadfile.py (+14/-6)
ubuntuone/web/tests/sst/files/u1webf002_publishfile.py (+19/-4)
ubuntuone/web/tests/sst/files/u1webf003_stoppublishingfile.py (+21/-4)
ubuntuone/web/tests/sst/shared/actions/files.py (+49/-12)
ubuntuone/web/tests/sst/shared/actions/setup.py (+3/-0)
ubuntuone/web/tests/sst/shared/actions/sso.py (+3/-2)
To merge this branch: bzr merge lp:~elopio/ubuntuone-testing/fix-files-this-time-for-real
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
Review via email: mp+81346@code.launchpad.net

Commit message

Fixes and additions to the files tests.

Description of the change

Fixes and additions to the files tests.

To post a comment you must log in.
Revision history for this message
Rick McBride (rmcbride) wrote :

Neat!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/web/tests/sst/files/u1webf001_uploadfile.py'
2--- ubuntuone/web/tests/sst/files/u1webf001_uploadfile.py 2011-09-26 05:39:58 +0000
3+++ ubuntuone/web/tests/sst/files/u1webf001_uploadfile.py 2011-11-04 23:08:23 +0000
4@@ -26,15 +26,23 @@
5 import actions.setup as setup_actions
6 import actions.files as files_actions
7 import os.path
8+import tempfile
9+import uuid
10
11 setup_actions.setup()
12 files_actions.open()
13-file_name = 'Test_upload_from_website.txt'
14-files_actions.upload_file(
15- os.path.abspath('test_files/' + file_name))
16+file_uuid = str(uuid.uuid1())
17+file_contents = 'This is test file %s' % file_uuid
18+file_name = None
19+with tempfile.NamedTemporaryFile(mode='wr', prefix='Test upload from website',
20+ suffix=file_uuid + '.txt',
21+ delete=False) as upload:
22+ upload.write(file_contents)
23+ upload.close()
24+ files_actions.upload_file(upload.name)
25+ file_name = os.path.basename(upload.name)
26 files_actions.assert_file_exists(file_name)
27 assert files_actions.get_file_upload_date(file_name) == 'Just now'
28-assert files_actions.get_file_size(file_name) == '21 bytes'
29-files_actions.click_file_more(file_name)
30+assert files_actions.get_file_size(file_name) == '54 bytes'
31 files_actions.assert_file_information_is_shown(file_name)
32-files_actions.assert_file_type('text/plain')
33+files_actions.assert_file_type(file_name, 'text/plain')
34
35=== modified file 'ubuntuone/web/tests/sst/files/u1webf002_publishfile.py'
36--- ubuntuone/web/tests/sst/files/u1webf002_publishfile.py 2011-10-03 08:50:46 +0000
37+++ ubuntuone/web/tests/sst/files/u1webf002_publishfile.py 2011-11-04 23:08:23 +0000
38@@ -26,11 +26,26 @@
39 import actions.setup as setup_actions
40 import actions.files as files_actions
41 import os.path
42+import tempfile
43+import uuid
44+import urlparse
45
46 setup_actions.setup()
47 files_actions.open()
48-file_name = 'Test_publish_from_website.txt'
49-files_actions.upload_file(
50- os.path.abspath('test_files/' + file_name))
51+file_uuid = str(uuid.uuid1())
52+file_contents = 'This is test file %s' % file_uuid
53+file_name = None
54+with tempfile.NamedTemporaryFile(mode='wr', prefix='Test publish from website',
55+ suffix=file_uuid + '.txt',
56+ delete=False) as upload:
57+ upload.write(file_contents)
58+ upload.close()
59+ files_actions.upload_file(upload.name)
60+ file_name = os.path.basename(upload.name)
61 files_actions.publish_file(file_name)
62-# TODO assert the publication.
63+files_actions.assert_file_published(file_name)
64+file_url = files_actions.get_public_url(file_name)
65+parsed_url = urlparse.urlparse(file_url)
66+set_base_url(file_url.rstrip(parsed_url.path))
67+goto(parsed_url.path)
68+text_is(get_element(tag='body'), file_contents)
69
70=== modified file 'ubuntuone/web/tests/sst/files/u1webf003_stoppublishingfile.py'
71--- ubuntuone/web/tests/sst/files/u1webf003_stoppublishingfile.py 2011-10-03 08:50:46 +0000
72+++ ubuntuone/web/tests/sst/files/u1webf003_stoppublishingfile.py 2011-11-04 23:08:23 +0000
73@@ -26,12 +26,29 @@
74 import actions.setup as setup_actions
75 import actions.files as files_actions
76 import os.path
77+import tempfile
78+import uuid
79+import urlparse
80
81 setup_actions.setup()
82 files_actions.open()
83-file_name = 'Test_publish_from_website.txt'
84-files_actions.upload_file(
85- os.path.abspath('test_files/' + file_name))
86+file_uuid = str(uuid.uuid1())
87+file_contents = 'This is test file %s' % file_uuid
88+file_name = None
89+with tempfile.NamedTemporaryFile(mode='wr',
90+ prefix='Test stop publishing from website',
91+ suffix=file_uuid + '.txt',
92+ delete=False) as upload:
93+ upload.write(file_contents)
94+ upload.close()
95+ files_actions.upload_file(upload.name)
96+ file_name = os.path.basename(upload.name)
97 files_actions.publish_file(file_name)
98+files_actions.assert_file_published(file_name)
99+file_url = files_actions.get_public_url(file_name)
100 files_actions.stop_publishing_file(file_name)
101-# TODO assert that the file is not published anymore.
102+files_actions.assert_file_not_published(file_name)
103+parsed_url = urlparse.urlparse(file_url)
104+set_base_url(file_url.rstrip(parsed_url.path))
105+goto(parsed_url.path)
106+text_is(get_element(tag='body'), 'Could not locate object')
107
108=== modified file 'ubuntuone/web/tests/sst/shared/actions/files.py'
109--- ubuntuone/web/tests/sst/shared/actions/files.py 2011-11-03 17:56:44 +0000
110+++ ubuntuone/web/tests/sst/shared/actions/files.py 2011-11-04 23:08:23 +0000
111@@ -62,9 +62,8 @@
112 input_file = _get_elem('upload-overlay-file')
113 input_file.send_keys(path)
114 button_click('upload-overlay-upload-button')
115- set_wait_timeout(180)
116+ # TODO set a waiting time proportional to the size of the file to upload.
117 wait_for_action_to_complete()
118- set_wait_timeout(DEFAULT_TIMEOUT)
119
120 def assert_file_exists(name):
121 """Assert that a file exists on the Ubuntu One storage.
122@@ -147,7 +146,19 @@
123 identifier -- The identifier of the file.
124
125 """
126- return get_element('%s-publish' % identifier)
127+ return get_element(id='%s-publish' % identifier,
128+ css_class='u1-files-publish-link')
129+
130+def _get_link_stop_publishing_file(identifier):
131+ """Get the Stop Publish File link element.
132+
133+ Keyword arguments:
134+ identifier -- The identifier of the file.
135+
136+ """
137+ return get_element(id='%s-publish' % identifier,
138+ css_class='u1-files-stop-publishing-link')
139+
140
141 def _get_link_download_file(identifier):
142 """Get the Download file link element.
143@@ -157,9 +168,8 @@
144
145 """
146 # TODO the URL should be taken from the config.
147- return get_element(css_class='download-button',
148- href='http://files.staging.one.ubuntu.com/%s'
149- % identifier)
150+ url = 'https://files.staging.one.ubuntu.com/' + str(identifier[3:])
151+ return get_element(css_class='download-button', href=url)
152
153 def _get_link_delete_file(identifier):
154 """Get the Delete file link element.
155@@ -180,8 +190,8 @@
156 assert _are_details_shown(name)
157 identifier = _get_file_identifier(name)
158 assert _get_link_publish_file(identifier).is_displayed()
159- assert _get_link_download_file.is_displayed()
160- assert _get_link_delete_file.is_displayed()
161+ assert _get_link_download_file(identifier).is_displayed()
162+ assert _get_link_delete_file(identifier).is_displayed()
163
164 def assert_file_type(name, type):
165 """Assert that the type of a file is the expected.
166@@ -206,9 +216,22 @@
167 """
168 show_file_details(name)
169 identifier = _get_file_identifier(name)
170- link_click(_get_link_publish_file(identifier))
171+ element_click(_get_link_publish_file(identifier))
172 wait_for_action_to_complete()
173
174+def assert_file_published(name):
175+ """Assert that a folder is shared.
176+
177+ Keyword arguments:
178+ name -- The name of the published file.
179+
180+ """
181+ show_file_details(name)
182+ identifier = _get_file_identifier(name)
183+ _get_link_stop_publishing_file(identifier)
184+ fails(_get_link_publish_file, identifier)
185+ get_public_url(name)
186+
187 def get_public_url(name):
188 """Get the public URL of a published file.
189
190@@ -218,8 +241,8 @@
191 """
192 show_file_details(name)
193 # XXX this element requires an identifier.
194- input_public_url = get_elementby_xpath('id("%s-details")//'
195- 'input[@class="public_url'
196+ input_public_url = get_element_by_xpath('id("%s-details")//'
197+ 'input[@class="public_url"]'
198 % _get_file_identifier(name))
199 return input_public_url.get_attribute('value')
200
201@@ -232,9 +255,23 @@
202 """
203 show_file_details(name)
204 identifier = _get_file_identifier(name)
205- link_click(_get_link_publish_file(identifier))
206+ element_click(_get_link_stop_publishing_file(identifier))
207 wait_for_action_to_complete()
208
209+def assert_file_not_published(name):
210+ """Assert that a folder is shared.
211+
212+ Keyword arguments:
213+ name -- The name of the published file.
214+
215+ """
216+ show_file_details(name)
217+ identifier = _get_file_identifier(name)
218+ fails(_get_link_stop_publishing_file, identifier)
219+ _get_link_publish_file(identifier)
220+ fails(get_public_url, name)
221+
222+
223 def download_file(name):
224 """Download a file stored on the Ubuntu One service.
225
226
227=== modified file 'ubuntuone/web/tests/sst/shared/actions/setup.py'
228--- ubuntuone/web/tests/sst/shared/actions/setup.py 2011-11-03 17:56:44 +0000
229+++ ubuntuone/web/tests/sst/shared/actions/setup.py 2011-11-04 23:08:23 +0000
230@@ -42,6 +42,9 @@
231 """
232 set_base_url(base_url)
233 set_wait_timeout(DEFAULT_TIMEOUT)
234+ goto()
235+ wait_for_title_to_change('Ubuntu One : Home')
236+ link_click(get_element(text='Log in or Sign up'))
237 if new_user:
238 skip('New user creation is not yet implemented.')
239 else:
240
241=== modified file 'ubuntuone/web/tests/sst/shared/actions/sso.py'
242--- ubuntuone/web/tests/sst/shared/actions/sso.py 2011-10-06 05:31:32 +0000
243+++ ubuntuone/web/tests/sst/shared/actions/sso.py 2011-11-04 23:08:23 +0000
244@@ -31,12 +31,13 @@
245 password -- The password of the user.
246
247 """
248- goto('/auth/login')
249 waitfor(title_is, 'Log in')
250 switch_to_window()
251 is_textfield('id_email')
252 is_textfield('id_password')
253 textfield_write('id_email', email)
254 textfield_write('id_password', password)
255- button_click(get_element(css_class='btn', name='continue'))
256+ button_click(get_element(css_class='btn', name='continue'), wait=False)
257+ waitfor(title_is, 'Authenticate to %s' % base_url)
258+ waitfor(get_element, tag='body')
259 button_click(get_element(css_class='btn', name='yes'))

Subscribers

People subscribed via source and target branches