Merge lp:~elopio/ubuntuone-testing/music2 into lp:ubuntuone-testing
- music2
- Merge into trunk
Proposed by
Leo Arias
Status: | Merged |
---|---|
Approved by: | Rick McBride |
Approved revision: | 79 |
Merged at revision: | 69 |
Proposed branch: | lp:~elopio/ubuntuone-testing/music2 |
Merge into: | lp:ubuntuone-testing |
Diff against target: |
434 lines (+224/-35) 9 files modified
ubuntuone/web/tests/sst/README.txt (+7/-2) ubuntuone/web/tests/sst/music/u1webm001_playsong.py (+8/-2) ubuntuone/web/tests/sst/music/u1webm002_selectartist.py (+39/-0) ubuntuone/web/tests/sst/music/u1webm003_selectalbum.py (+38/-0) ubuntuone/web/tests/sst/shared/actions/header.py (+1/-0) ubuntuone/web/tests/sst/shared/actions/music.py (+82/-13) ubuntuone/web/tests/sst/shared/actions/setup.py (+16/-10) ubuntuone/web/tests/sst/shared/actions/sso.py (+8/-8) ubuntuone/web/tests/sst/shared/data/user.py (+25/-0) |
To merge this branch: | bzr merge lp:~elopio/ubuntuone-testing/music2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rick McBride (community) | Approve | ||
Review via email: mp+86255@code.launchpad.net |
Commit message
Added two more music tests.
Made a small adjustment to see if the full name verification after login gets more stable.
Description of the change
Second batch of music 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 'ubuntuone/web/tests/sst/README.txt' |
2 | --- ubuntuone/web/tests/sst/README.txt 2011-11-15 06:22:41 +0000 |
3 | +++ ubuntuone/web/tests/sst/README.txt 2011-12-19 15:40:32 +0000 |
4 | @@ -1,10 +1,15 @@ |
5 | The tests involving login require the user's full name, email and |
6 | -password to login to SSO. Create a file ``_passwords.py`` in the ``shared`` |
7 | +password to login to SSO. Create a file '_passwords.py' in the 'shared' |
8 | directory, with the following contents:: |
9 | |
10 | full_name = My Full Name |
11 | email = 'my.username@canonical.com' |
12 | password = 'mypassword' |
13 | |
14 | -(``_passwords.py`` is ignored by bazaar so you can't accidentally check it |
15 | +('_passwords.py' is ignored by bazaar so you can't accidentally check it |
16 | into the repository.) |
17 | + |
18 | +The tests for the web music player require a special account with the |
19 | +streaming service and some songs preloaded. The user information for this |
20 | +tests should be added to the file '_musicpasswords.py' in the 'music' |
21 | +directory. |
22 | |
23 | === modified file 'ubuntuone/web/tests/sst/music/u1webm001_playsong.py' |
24 | --- ubuntuone/web/tests/sst/music/u1webm001_playsong.py 2011-12-13 23:35:07 +0000 |
25 | +++ ubuntuone/web/tests/sst/music/u1webm001_playsong.py 2011-12-19 15:40:32 +0000 |
26 | @@ -23,9 +23,15 @@ |
27 | import actions.setup as setup_actions |
28 | import actions.music as music_actions |
29 | from data.song import Song |
30 | +from data.user import User |
31 | +try: |
32 | + from _musicpasswords import full_name, email, password |
33 | +except: |
34 | + skip('Try adding a _musicpasswords.py file to the music folder if you ' \ |
35 | + 'expect this to work. Read the README.txt file ;)') |
36 | |
37 | -skip('Not ready for unattended execution.') |
38 | -setup_actions.setup() |
39 | +test_user = User(full_name, email, password) |
40 | +setup_actions.setup(user=test_user) |
41 | music_actions.open() |
42 | song = Song('gentle marimba', 'Alastair Cameron', 'Free Film Music (cameronmusic.co.uk)') |
43 | music_actions.play_song(song) |
44 | |
45 | === added file 'ubuntuone/web/tests/sst/music/u1webm002_selectartist.py' |
46 | --- ubuntuone/web/tests/sst/music/u1webm002_selectartist.py 1970-01-01 00:00:00 +0000 |
47 | +++ ubuntuone/web/tests/sst/music/u1webm002_selectartist.py 2011-12-19 15:40:32 +0000 |
48 | @@ -0,0 +1,39 @@ |
49 | +# -*- coding: utf-8 -*- |
50 | + |
51 | +# Copyright 2011 Canonical Ltd. |
52 | +# |
53 | +# This program is free software: you can redistribute it and/or modify it |
54 | +# under the terms of the GNU General Public License version 3, as published |
55 | +# by the Free Software Foundation. |
56 | +# |
57 | +# This program is distributed in the hope that it will be useful, but |
58 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
59 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
60 | +# PURPOSE. See the GNU General Public License for more details. |
61 | +# |
62 | +# You should have received a copy of the GNU General Public License along |
63 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
64 | + |
65 | +"""Test case u1webm-002 Select artist. |
66 | +Select an artist on the Ubuntu One web music player. |
67 | + |
68 | +""" |
69 | + |
70 | +from sst.actions import * |
71 | +import actions.setup as setup_actions |
72 | +import actions.music as music_actions |
73 | +from data.song import Song |
74 | +from data.user import User |
75 | +try: |
76 | + from _musicpasswords import full_name, email, password |
77 | +except: |
78 | + skip('Try adding a _musicpasswords.py file to the music folder if you ' \ |
79 | + 'expect this to work. Read the README.txt file ;)') |
80 | + |
81 | +test_user = User(full_name, email, password) |
82 | +setup_actions.setup(user=test_user) |
83 | +music_actions.open() |
84 | +artist = 'Alastair Cameron' |
85 | +album = 'Free Film Music (cameronmusic.co.uk)' |
86 | +music_actions.select_artist(artist) |
87 | +music_actions.assert_artist_albums(artist, [album]) |
88 | |
89 | === added file 'ubuntuone/web/tests/sst/music/u1webm003_selectalbum.py' |
90 | --- ubuntuone/web/tests/sst/music/u1webm003_selectalbum.py 1970-01-01 00:00:00 +0000 |
91 | +++ ubuntuone/web/tests/sst/music/u1webm003_selectalbum.py 2011-12-19 15:40:32 +0000 |
92 | @@ -0,0 +1,38 @@ |
93 | +# -*- coding: utf-8 -*- |
94 | + |
95 | +# Copyright 2011 Canonical Ltd. |
96 | +# |
97 | +# This program is free software: you can redistribute it and/or modify it |
98 | +# under the terms of the GNU General Public License version 3, as published |
99 | +# by the Free Software Foundation. |
100 | +# |
101 | +# This program is distributed in the hope that it will be useful, but |
102 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
103 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
104 | +# PURPOSE. See the GNU General Public License for more details. |
105 | +# |
106 | +# You should have received a copy of the GNU General Public License along |
107 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
108 | + |
109 | +"""Test case u1webm-003 Select album. |
110 | +Select an album on the Ubuntu One web music player. |
111 | + |
112 | +""" |
113 | + |
114 | +from sst.actions import * |
115 | +import actions.setup as setup_actions |
116 | +import actions.music as music_actions |
117 | +from data.song import Song |
118 | +from data.user import User |
119 | +try: |
120 | + from _musicpasswords import full_name, email, password |
121 | +except: |
122 | + skip('Try adding a _musicpasswords.py file to the music folder if you ' \ |
123 | + 'expect this to work. Read the README.txt file ;)') |
124 | + |
125 | +test_user = User(full_name, email, password) |
126 | +setup_actions.setup(user=test_user) |
127 | +music_actions.open() |
128 | +song = Song('gentle marimba', 'Alastair Cameron', 'Free Film Music (cameronmusic.co.uk)') |
129 | +music_actions.select_album(song.album) |
130 | +music_actions.assert_album_songs(song.artist, song.album, [song.title]) |
131 | |
132 | === modified file 'ubuntuone/web/tests/sst/shared/actions/header.py' |
133 | --- ubuntuone/web/tests/sst/shared/actions/header.py 2011-12-09 18:19:11 +0000 |
134 | +++ ubuntuone/web/tests/sst/shared/actions/header.py 2011-12-19 15:40:32 +0000 |
135 | @@ -30,6 +30,7 @@ |
136 | _get_logout_link() |
137 | |
138 | def _assert_full_name(full_name): |
139 | + wait_for(exists_element, id='ac-status') |
140 | welcome_element = get_element_by_css('#ac-status > span') |
141 | assert_text(welcome_element, 'Welcome %s' % full_name[:40]) |
142 | |
143 | |
144 | === modified file 'ubuntuone/web/tests/sst/shared/actions/music.py' |
145 | --- ubuntuone/web/tests/sst/shared/actions/music.py 2011-12-13 23:34:06 +0000 |
146 | +++ ubuntuone/web/tests/sst/shared/actions/music.py 2011-12-19 15:40:32 +0000 |
147 | @@ -17,8 +17,7 @@ |
148 | """Actions for the Music page of the Ubuntu One website.""" |
149 | |
150 | from sst.actions import * |
151 | -from loading import * |
152 | -import urlparse |
153 | +from data.song import Song |
154 | |
155 | def open(): |
156 | """Open the music page and assert it's title.""" |
157 | @@ -34,7 +33,7 @@ |
158 | |
159 | def assert_page_title(): |
160 | """Assert that the title of the page is the expected.""" |
161 | - assert_title(u'Ubuntu One : Music Streaming') |
162 | + assert_title(u'Ubuntu One : Music') |
163 | |
164 | def play_song(song): |
165 | _open_songs() |
166 | @@ -46,7 +45,7 @@ |
167 | 'td.c1 > button' \ |
168 | % identifier) |
169 | click_button(song_play_button) |
170 | - assert not song_play_button.assert_displayed() |
171 | + assert not song_play_button.is_displayed() |
172 | |
173 | def assert_songs_added_to_queue(songs_list): |
174 | number_of_songs = len(songs_list) |
175 | @@ -65,7 +64,7 @@ |
176 | _assert_message_content(message_content) |
177 | |
178 | def _assert_message_displayed(): |
179 | - assert _get_message_element().assert_displayed() |
180 | + assert _get_message_element().is_displayed() |
181 | |
182 | def _assert_message_content(message_content): |
183 | assert _get_message_element().text == message_content |
184 | @@ -83,12 +82,12 @@ |
185 | set_checkbox_value(song_checkbox, True) |
186 | |
187 | def _open_songs(): |
188 | - if not _is_songs_opened(): |
189 | + if not _is_songs_open(): |
190 | songs_element = _get_songs_element() |
191 | click_element(songs_element) |
192 | _wait_for_action_to_complete() |
193 | |
194 | -def _is_songs_opened(): |
195 | +def _is_songs_open(): |
196 | songs_element = _get_songs_element() |
197 | return _is_active(songs_element) |
198 | |
199 | @@ -110,12 +109,12 @@ |
200 | assert expected_title == player_title_element.text |
201 | |
202 | def assert_player_playing(): |
203 | - assert _get_stop_button().assert_displayed() |
204 | - assert not _get_play_button().assert_displayed() |
205 | + assert _get_stop_button().is_displayed() |
206 | + assert not _get_play_button().is_displayed() |
207 | |
208 | def assert_player_paused(): |
209 | - assert not _get_stop_button().assert_displayed() |
210 | - assert _get_play_button().assert_displayed() |
211 | + assert not _get_stop_button().is_displayed() |
212 | + assert _get_play_button().is_displayed() |
213 | |
214 | def _get_stop_button(): |
215 | return get_element_by_css('#stop') |
216 | @@ -142,6 +141,9 @@ |
217 | |
218 | def assert_song_in_queue(song): |
219 | _open_now_playing() |
220 | + _assert_song(song) |
221 | + |
222 | +def _assert_song(song): |
223 | song_row_xpath = '//tr[contains(@class, "song-listing")]/' \ |
224 | 'td[text()="%(title)s"]/../td[text()="%(artist)s"]/../' \ |
225 | 'td[text()="%(album)s"]/..' % {'title': song.title, |
226 | @@ -150,10 +152,10 @@ |
227 | get_element_by_xpath(song_row_xpath) |
228 | |
229 | def _open_now_playing(): |
230 | - if not _is_now_playing_opened(): |
231 | + if not _is_now_playing_open(): |
232 | click_element(_get_now_playing_element()) |
233 | |
234 | -def _is_now_playing_opened(): |
235 | +def _is_now_playing_open(): |
236 | now_playing_element = _get_now_playing_element() |
237 | return _is_active(now_playing_element) |
238 | |
239 | @@ -175,3 +177,70 @@ |
240 | sleep(3) |
241 | waiting_bar = get_element_by_css('.loading-view > .indicator') |
242 | wait_for(fails, assert_displayed, waiting_bar) |
243 | + |
244 | +def select_artist(artist): |
245 | + _open_artists() |
246 | + _click_artist(artist) |
247 | + |
248 | +def _open_artists(): |
249 | + if not _is_artists_open(): |
250 | + click_element(_get_artists_element()) |
251 | + |
252 | +def _is_artists_open(): |
253 | + artists_element = _get_artists_element() |
254 | + return _is_active(artists_element) |
255 | + |
256 | +def _get_artists_element(): |
257 | + return get_element(css_class='artists') |
258 | + |
259 | +def _click_artist(artist): |
260 | + artist_link_xpath = '//a[@data-u1m-artistid and text()="{0}"]' \ |
261 | + .format(artist) |
262 | + artist_link = get_element_by_xpath(artist_link_xpath) |
263 | + artist_link.click() |
264 | + _wait_for_action_to_complete() |
265 | + |
266 | +def assert_artist_albums(artist, albums_list): |
267 | + _assert_albums_view_title('{0} albums'.format(artist)) |
268 | + for album in albums_list: |
269 | + _assert_album(album) |
270 | + |
271 | +def _assert_albums_view_title(title): |
272 | + view_title = get_element_by_css('#album-view > h2') |
273 | + assert_text(view_title, title) |
274 | + |
275 | +def _assert_album(album): |
276 | + _get_album_link(album) |
277 | + |
278 | +def _get_album_link(album): |
279 | + album_link_xpath = '//a[@data-u1m-albumid and text()="{0}"]' \ |
280 | + .format(album) |
281 | + return get_element_by_xpath(album_link_xpath) |
282 | + |
283 | +def select_album(album): |
284 | + _open_albums() |
285 | + _click_album(album) |
286 | + |
287 | +def _open_albums(): |
288 | + if not _is_albums_open(): |
289 | + click_element(_get_albums_element()) |
290 | + |
291 | +def _is_albums_open(): |
292 | + albums_element = _get_albums_element() |
293 | + return _is_active(albums_element) |
294 | + |
295 | +def _get_albums_element(): |
296 | + return get_element(css_class='albums') |
297 | + |
298 | +def _click_album(album): |
299 | + _get_album_link(album).click() |
300 | + _wait_for_action_to_complete() |
301 | + |
302 | +def assert_album_songs(artist, album, songs_title_list): |
303 | + _assert_songs_view_title('{0} by {1}'.format(album, artist)) |
304 | + for song_title in songs_title_list: |
305 | + _assert_song(Song(artist, album, song_title)) |
306 | + |
307 | +def _assert_songs_view_title(title): |
308 | + view_title = get_element_by_css('#song-view > h2') |
309 | + assert_text(view_title, title) |
310 | |
311 | === modified file 'ubuntuone/web/tests/sst/shared/actions/setup.py' |
312 | --- ubuntuone/web/tests/sst/shared/actions/setup.py 2011-12-13 23:05:13 +0000 |
313 | +++ ubuntuone/web/tests/sst/shared/actions/setup.py 2011-12-19 15:40:32 +0000 |
314 | @@ -18,6 +18,7 @@ |
315 | |
316 | from sst.actions import * |
317 | from config import * |
318 | +from data.user import User |
319 | import actions.header as header_actions |
320 | import actions.sso as sso_actions |
321 | import actions.services as services_actions |
322 | @@ -31,7 +32,7 @@ |
323 | 'expect this to work. Read the README.txt file ;)') |
324 | |
325 | |
326 | -def setup(new_user=False): |
327 | +def setup(new_user=False, user=None): |
328 | """Log in to the Ubuntu One website. Optionally, you can create a new user. |
329 | |
330 | After calling setup, the browser will be in the Dashboard ready to |
331 | @@ -46,21 +47,26 @@ |
332 | go_to() |
333 | wait_for(assert_title, 'Ubuntu One : Home') |
334 | header_actions.click_login_or_sign_up() |
335 | - user_name = full_name |
336 | - user_email = email |
337 | + test_user = user |
338 | if new_user: |
339 | - user_uuid = str(uuid.uuid1()) |
340 | - user_name = 'Test user ' + user_uuid |
341 | - user_email = user_uuid + '@' + IMAP_SERVER |
342 | - sso_actions.create_new_account(user_name, user_email, 'Hola123*') |
343 | - confirmation_code = mail.get_confirmation_code_for_address(user_email) |
344 | + if user is None: |
345 | + user_uuid = str(uuid.uuid1()) |
346 | + user_name = 'Test user ' + user_uuid |
347 | + user_email = user_uuid + '@' + IMAP_SERVER |
348 | + user_password = 'Hola123*' |
349 | + test_user = User(user_name, user_email, user_password) |
350 | + sso_actions.create_new_account(test_user) |
351 | + confirmation_code = \ |
352 | + mail.get_confirmation_code_for_address(test_user.email) |
353 | sso_actions.confirm_email(confirmation_code) |
354 | else: |
355 | - sso_actions.login(user_email, password) |
356 | + if user is None: |
357 | + test_user = User(full_name, email, password) |
358 | + sso_actions.login(test_user) |
359 | if new_user: |
360 | services_actions.agree_and_subscribe_to_free_plan() |
361 | - header_actions.assert_login(user_name) |
362 | dashboard_actions.wait_for_page_to_load() |
363 | + header_actions.assert_login(test_user.full_name) |
364 | |
365 | def get_base_url(): |
366 | base_url = None |
367 | |
368 | === modified file 'ubuntuone/web/tests/sst/shared/actions/sso.py' |
369 | --- ubuntuone/web/tests/sst/shared/actions/sso.py 2011-12-13 20:11:54 +0000 |
370 | +++ ubuntuone/web/tests/sst/shared/actions/sso.py 2011-12-19 15:40:32 +0000 |
371 | @@ -23,7 +23,7 @@ |
372 | from sst.actions import * |
373 | from actions.setup import get_base_url |
374 | |
375 | -def login(email, password): |
376 | +def login(user): |
377 | """Log in to Ubuntu One website. |
378 | |
379 | Keyword arguments: |
380 | @@ -35,17 +35,17 @@ |
381 | switch_to_window() |
382 | assert_textfield('id_email') |
383 | assert_textfield('id_password') |
384 | - write_textfield('id_email', email) |
385 | - write_textfield('id_password', password) |
386 | + write_textfield('id_email', user.email) |
387 | + write_textfield('id_password', user.password) |
388 | click_button(get_element(css_class='btn', name='continue'), wait=False) |
389 | |
390 | -def create_new_account(full_name, email, password): |
391 | +def create_new_account(user): |
392 | click_link(get_element(href='+new_account')) |
393 | wait_for(assert_title, 'Create account') |
394 | - write_textfield('id_displayname', full_name) |
395 | - write_textfield('id_email', email) |
396 | - write_textfield('id_password', password) |
397 | - write_textfield('id_passwordconfirm', password) |
398 | + write_textfield('id_displayname', user.full_name) |
399 | + write_textfield('id_email', user.email) |
400 | + write_textfield('id_password', user.password) |
401 | + write_textfield('id_passwordconfirm', user.password) |
402 | click_button(get_element(name='continue')) |
403 | |
404 | def confirm_email(confirmation_code): |
405 | |
406 | === added file 'ubuntuone/web/tests/sst/shared/data/user.py' |
407 | --- ubuntuone/web/tests/sst/shared/data/user.py 1970-01-01 00:00:00 +0000 |
408 | +++ ubuntuone/web/tests/sst/shared/data/user.py 2011-12-19 15:40:32 +0000 |
409 | @@ -0,0 +1,25 @@ |
410 | +# -*- coding: utf-8 -*- |
411 | + |
412 | +# Copyright 2011 Canonical Ltd. |
413 | +# |
414 | +# This program is free software: you can redistribute it and/or modify it |
415 | +# under the terms of the GNU General Public License version 3, as published |
416 | +# by the Free Software Foundation. |
417 | +# |
418 | +# This program is distributed in the hope that it will be useful, but |
419 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
420 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
421 | +# PURPOSE. See the GNU General Public License for more details. |
422 | +# |
423 | +# You should have received a copy of the GNU General Public License along |
424 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
425 | + |
426 | +"""Data class for a User.""" |
427 | + |
428 | +class User: |
429 | + "Class for User information." |
430 | + |
431 | + def __init__(self, full_name, email, password): |
432 | + self.full_name = full_name |
433 | + self.email = email |
434 | + self.password = password |
+1