Merge lp:~elopio/ubuntuone-testing/music2 into lp:ubuntuone-testing

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
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.
Revision history for this message
Rick McBride (rmcbride) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/web/tests/sst/README.txt'
--- ubuntuone/web/tests/sst/README.txt 2011-11-15 06:22:41 +0000
+++ ubuntuone/web/tests/sst/README.txt 2011-12-19 15:40:32 +0000
@@ -1,10 +1,15 @@
1The tests involving login require the user's full name, email and1The tests involving login require the user's full name, email and
2password to login to SSO. Create a file ``_passwords.py`` in the ``shared``2password to login to SSO. Create a file '_passwords.py' in the 'shared'
3directory, with the following contents::3directory, with the following contents::
44
5 full_name = My Full Name5 full_name = My Full Name
6 email = 'my.username@canonical.com'6 email = 'my.username@canonical.com'
7 password = 'mypassword'7 password = 'mypassword'
88
9(``_passwords.py`` is ignored by bazaar so you can't accidentally check it9('_passwords.py' is ignored by bazaar so you can't accidentally check it
10into the repository.)10into the repository.)
11
12The tests for the web music player require a special account with the
13streaming service and some songs preloaded. The user information for this
14tests should be added to the file '_musicpasswords.py' in the 'music'
15directory.
1116
=== modified file 'ubuntuone/web/tests/sst/music/u1webm001_playsong.py'
--- ubuntuone/web/tests/sst/music/u1webm001_playsong.py 2011-12-13 23:35:07 +0000
+++ ubuntuone/web/tests/sst/music/u1webm001_playsong.py 2011-12-19 15:40:32 +0000
@@ -23,9 +23,15 @@
23import actions.setup as setup_actions23import actions.setup as setup_actions
24import actions.music as music_actions24import actions.music as music_actions
25from data.song import Song25from data.song import Song
26from data.user import User
27try:
28 from _musicpasswords import full_name, email, password
29except:
30 skip('Try adding a _musicpasswords.py file to the music folder if you ' \
31 'expect this to work. Read the README.txt file ;)')
2632
27skip('Not ready for unattended execution.')33test_user = User(full_name, email, password)
28setup_actions.setup()34setup_actions.setup(user=test_user)
29music_actions.open()35music_actions.open()
30song = Song('gentle marimba', 'Alastair Cameron', 'Free Film Music (cameronmusic.co.uk)')36song = Song('gentle marimba', 'Alastair Cameron', 'Free Film Music (cameronmusic.co.uk)')
31music_actions.play_song(song)37music_actions.play_song(song)
3238
=== added file 'ubuntuone/web/tests/sst/music/u1webm002_selectartist.py'
--- ubuntuone/web/tests/sst/music/u1webm002_selectartist.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/music/u1webm002_selectartist.py 2011-12-19 15:40:32 +0000
@@ -0,0 +1,39 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Test case u1webm-002 Select artist.
18Select an artist on the Ubuntu One web music player.
19
20"""
21
22from sst.actions import *
23import actions.setup as setup_actions
24import actions.music as music_actions
25from data.song import Song
26from data.user import User
27try:
28 from _musicpasswords import full_name, email, password
29except:
30 skip('Try adding a _musicpasswords.py file to the music folder if you ' \
31 'expect this to work. Read the README.txt file ;)')
32
33test_user = User(full_name, email, password)
34setup_actions.setup(user=test_user)
35music_actions.open()
36artist = 'Alastair Cameron'
37album = 'Free Film Music (cameronmusic.co.uk)'
38music_actions.select_artist(artist)
39music_actions.assert_artist_albums(artist, [album])
040
=== added file 'ubuntuone/web/tests/sst/music/u1webm003_selectalbum.py'
--- ubuntuone/web/tests/sst/music/u1webm003_selectalbum.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/music/u1webm003_selectalbum.py 2011-12-19 15:40:32 +0000
@@ -0,0 +1,38 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Test case u1webm-003 Select album.
18Select an album on the Ubuntu One web music player.
19
20"""
21
22from sst.actions import *
23import actions.setup as setup_actions
24import actions.music as music_actions
25from data.song import Song
26from data.user import User
27try:
28 from _musicpasswords import full_name, email, password
29except:
30 skip('Try adding a _musicpasswords.py file to the music folder if you ' \
31 'expect this to work. Read the README.txt file ;)')
32
33test_user = User(full_name, email, password)
34setup_actions.setup(user=test_user)
35music_actions.open()
36song = Song('gentle marimba', 'Alastair Cameron', 'Free Film Music (cameronmusic.co.uk)')
37music_actions.select_album(song.album)
38music_actions.assert_album_songs(song.artist, song.album, [song.title])
039
=== modified file 'ubuntuone/web/tests/sst/shared/actions/header.py'
--- ubuntuone/web/tests/sst/shared/actions/header.py 2011-12-09 18:19:11 +0000
+++ ubuntuone/web/tests/sst/shared/actions/header.py 2011-12-19 15:40:32 +0000
@@ -30,6 +30,7 @@
30 _get_logout_link()30 _get_logout_link()
3131
32def _assert_full_name(full_name):32def _assert_full_name(full_name):
33 wait_for(exists_element, id='ac-status')
33 welcome_element = get_element_by_css('#ac-status > span')34 welcome_element = get_element_by_css('#ac-status > span')
34 assert_text(welcome_element, 'Welcome %s' % full_name[:40])35 assert_text(welcome_element, 'Welcome %s' % full_name[:40])
3536
3637
=== modified file 'ubuntuone/web/tests/sst/shared/actions/music.py'
--- ubuntuone/web/tests/sst/shared/actions/music.py 2011-12-13 23:34:06 +0000
+++ ubuntuone/web/tests/sst/shared/actions/music.py 2011-12-19 15:40:32 +0000
@@ -17,8 +17,7 @@
17"""Actions for the Music page of the Ubuntu One website."""17"""Actions for the Music page of the Ubuntu One website."""
1818
19from sst.actions import *19from sst.actions import *
20from loading import *20from data.song import Song
21import urlparse
2221
23def open():22def open():
24 """Open the music page and assert it's title."""23 """Open the music page and assert it's title."""
@@ -34,7 +33,7 @@
3433
35def assert_page_title():34def assert_page_title():
36 """Assert that the title of the page is the expected."""35 """Assert that the title of the page is the expected."""
37 assert_title(u'Ubuntu One : Music Streaming')36 assert_title(u'Ubuntu One : Music')
3837
39def play_song(song):38def play_song(song):
40 _open_songs()39 _open_songs()
@@ -46,7 +45,7 @@
46 'td.c1 > button' \45 'td.c1 > button' \
47 % identifier)46 % identifier)
48 click_button(song_play_button)47 click_button(song_play_button)
49 assert not song_play_button.assert_displayed()48 assert not song_play_button.is_displayed()
5049
51def assert_songs_added_to_queue(songs_list):50def assert_songs_added_to_queue(songs_list):
52 number_of_songs = len(songs_list)51 number_of_songs = len(songs_list)
@@ -65,7 +64,7 @@
65 _assert_message_content(message_content)64 _assert_message_content(message_content)
6665
67def _assert_message_displayed():66def _assert_message_displayed():
68 assert _get_message_element().assert_displayed()67 assert _get_message_element().is_displayed()
6968
70def _assert_message_content(message_content):69def _assert_message_content(message_content):
71 assert _get_message_element().text == message_content70 assert _get_message_element().text == message_content
@@ -83,12 +82,12 @@
83 set_checkbox_value(song_checkbox, True)82 set_checkbox_value(song_checkbox, True)
84 83
85def _open_songs():84def _open_songs():
86 if not _is_songs_opened():85 if not _is_songs_open():
87 songs_element = _get_songs_element()86 songs_element = _get_songs_element()
88 click_element(songs_element)87 click_element(songs_element)
89 _wait_for_action_to_complete()88 _wait_for_action_to_complete()
9089
91def _is_songs_opened():90def _is_songs_open():
92 songs_element = _get_songs_element()91 songs_element = _get_songs_element()
93 return _is_active(songs_element)92 return _is_active(songs_element)
9493
@@ -110,12 +109,12 @@
110 assert expected_title == player_title_element.text109 assert expected_title == player_title_element.text
111110
112def assert_player_playing():111def assert_player_playing():
113 assert _get_stop_button().assert_displayed()112 assert _get_stop_button().is_displayed()
114 assert not _get_play_button().assert_displayed()113 assert not _get_play_button().is_displayed()
115114
116def assert_player_paused():115def assert_player_paused():
117 assert not _get_stop_button().assert_displayed()116 assert not _get_stop_button().is_displayed()
118 assert _get_play_button().assert_displayed()117 assert _get_play_button().is_displayed()
119118
120def _get_stop_button():119def _get_stop_button():
121 return get_element_by_css('#stop')120 return get_element_by_css('#stop')
@@ -142,6 +141,9 @@
142141
143def assert_song_in_queue(song):142def assert_song_in_queue(song):
144 _open_now_playing()143 _open_now_playing()
144 _assert_song(song)
145
146def _assert_song(song):
145 song_row_xpath = '//tr[contains(@class, "song-listing")]/' \147 song_row_xpath = '//tr[contains(@class, "song-listing")]/' \
146 'td[text()="%(title)s"]/../td[text()="%(artist)s"]/../' \148 'td[text()="%(title)s"]/../td[text()="%(artist)s"]/../' \
147 'td[text()="%(album)s"]/..' % {'title': song.title,149 'td[text()="%(album)s"]/..' % {'title': song.title,
@@ -150,10 +152,10 @@
150 get_element_by_xpath(song_row_xpath)152 get_element_by_xpath(song_row_xpath)
151153
152def _open_now_playing():154def _open_now_playing():
153 if not _is_now_playing_opened():155 if not _is_now_playing_open():
154 click_element(_get_now_playing_element())156 click_element(_get_now_playing_element())
155157
156def _is_now_playing_opened():158def _is_now_playing_open():
157 now_playing_element = _get_now_playing_element()159 now_playing_element = _get_now_playing_element()
158 return _is_active(now_playing_element)160 return _is_active(now_playing_element)
159161
@@ -175,3 +177,70 @@
175 sleep(3)177 sleep(3)
176 waiting_bar = get_element_by_css('.loading-view > .indicator')178 waiting_bar = get_element_by_css('.loading-view > .indicator')
177 wait_for(fails, assert_displayed, waiting_bar)179 wait_for(fails, assert_displayed, waiting_bar)
180
181def select_artist(artist):
182 _open_artists()
183 _click_artist(artist)
184
185def _open_artists():
186 if not _is_artists_open():
187 click_element(_get_artists_element())
188
189def _is_artists_open():
190 artists_element = _get_artists_element()
191 return _is_active(artists_element)
192
193def _get_artists_element():
194 return get_element(css_class='artists')
195
196def _click_artist(artist):
197 artist_link_xpath = '//a[@data-u1m-artistid and text()="{0}"]' \
198 .format(artist)
199 artist_link = get_element_by_xpath(artist_link_xpath)
200 artist_link.click()
201 _wait_for_action_to_complete()
202
203def assert_artist_albums(artist, albums_list):
204 _assert_albums_view_title('{0} albums'.format(artist))
205 for album in albums_list:
206 _assert_album(album)
207
208def _assert_albums_view_title(title):
209 view_title = get_element_by_css('#album-view > h2')
210 assert_text(view_title, title)
211
212def _assert_album(album):
213 _get_album_link(album)
214
215def _get_album_link(album):
216 album_link_xpath = '//a[@data-u1m-albumid and text()="{0}"]' \
217 .format(album)
218 return get_element_by_xpath(album_link_xpath)
219
220def select_album(album):
221 _open_albums()
222 _click_album(album)
223
224def _open_albums():
225 if not _is_albums_open():
226 click_element(_get_albums_element())
227
228def _is_albums_open():
229 albums_element = _get_albums_element()
230 return _is_active(albums_element)
231
232def _get_albums_element():
233 return get_element(css_class='albums')
234
235def _click_album(album):
236 _get_album_link(album).click()
237 _wait_for_action_to_complete()
238
239def assert_album_songs(artist, album, songs_title_list):
240 _assert_songs_view_title('{0} by {1}'.format(album, artist))
241 for song_title in songs_title_list:
242 _assert_song(Song(artist, album, song_title))
243
244def _assert_songs_view_title(title):
245 view_title = get_element_by_css('#song-view > h2')
246 assert_text(view_title, title)
178247
=== modified file 'ubuntuone/web/tests/sst/shared/actions/setup.py'
--- ubuntuone/web/tests/sst/shared/actions/setup.py 2011-12-13 23:05:13 +0000
+++ ubuntuone/web/tests/sst/shared/actions/setup.py 2011-12-19 15:40:32 +0000
@@ -18,6 +18,7 @@
1818
19from sst.actions import *19from sst.actions import *
20from config import *20from config import *
21from data.user import User
21import actions.header as header_actions22import actions.header as header_actions
22import actions.sso as sso_actions23import actions.sso as sso_actions
23import actions.services as services_actions24import actions.services as services_actions
@@ -31,7 +32,7 @@
31 'expect this to work. Read the README.txt file ;)')32 'expect this to work. Read the README.txt file ;)')
3233
3334
34def setup(new_user=False):35def setup(new_user=False, user=None):
35 """Log in to the Ubuntu One website. Optionally, you can create a new user.36 """Log in to the Ubuntu One website. Optionally, you can create a new user.
3637
37 After calling setup, the browser will be in the Dashboard ready to38 After calling setup, the browser will be in the Dashboard ready to
@@ -46,21 +47,26 @@
46 go_to()47 go_to()
47 wait_for(assert_title, 'Ubuntu One : Home')48 wait_for(assert_title, 'Ubuntu One : Home')
48 header_actions.click_login_or_sign_up()49 header_actions.click_login_or_sign_up()
49 user_name = full_name50 test_user = user
50 user_email = email
51 if new_user:51 if new_user:
52 user_uuid = str(uuid.uuid1())52 if user is None:
53 user_name = 'Test user ' + user_uuid53 user_uuid = str(uuid.uuid1())
54 user_email = user_uuid + '@' + IMAP_SERVER54 user_name = 'Test user ' + user_uuid
55 sso_actions.create_new_account(user_name, user_email, 'Hola123*')55 user_email = user_uuid + '@' + IMAP_SERVER
56 confirmation_code = mail.get_confirmation_code_for_address(user_email)56 user_password = 'Hola123*'
57 test_user = User(user_name, user_email, user_password)
58 sso_actions.create_new_account(test_user)
59 confirmation_code = \
60 mail.get_confirmation_code_for_address(test_user.email)
57 sso_actions.confirm_email(confirmation_code)61 sso_actions.confirm_email(confirmation_code)
58 else:62 else:
59 sso_actions.login(user_email, password)63 if user is None:
64 test_user = User(full_name, email, password)
65 sso_actions.login(test_user)
60 if new_user:66 if new_user:
61 services_actions.agree_and_subscribe_to_free_plan()67 services_actions.agree_and_subscribe_to_free_plan()
62 header_actions.assert_login(user_name)
63 dashboard_actions.wait_for_page_to_load()68 dashboard_actions.wait_for_page_to_load()
69 header_actions.assert_login(test_user.full_name)
6470
65def get_base_url():71def get_base_url():
66 base_url = None72 base_url = None
6773
=== modified file 'ubuntuone/web/tests/sst/shared/actions/sso.py'
--- ubuntuone/web/tests/sst/shared/actions/sso.py 2011-12-13 20:11:54 +0000
+++ ubuntuone/web/tests/sst/shared/actions/sso.py 2011-12-19 15:40:32 +0000
@@ -23,7 +23,7 @@
23from sst.actions import *23from sst.actions import *
24from actions.setup import get_base_url24from actions.setup import get_base_url
2525
26def login(email, password):26def login(user):
27 """Log in to Ubuntu One website.27 """Log in to Ubuntu One website.
2828
29 Keyword arguments:29 Keyword arguments:
@@ -35,17 +35,17 @@
35 switch_to_window()35 switch_to_window()
36 assert_textfield('id_email')36 assert_textfield('id_email')
37 assert_textfield('id_password')37 assert_textfield('id_password')
38 write_textfield('id_email', email)38 write_textfield('id_email', user.email)
39 write_textfield('id_password', password)39 write_textfield('id_password', user.password)
40 click_button(get_element(css_class='btn', name='continue'), wait=False)40 click_button(get_element(css_class='btn', name='continue'), wait=False)
4141
42def create_new_account(full_name, email, password):42def create_new_account(user):
43 click_link(get_element(href='+new_account'))43 click_link(get_element(href='+new_account'))
44 wait_for(assert_title, 'Create account')44 wait_for(assert_title, 'Create account')
45 write_textfield('id_displayname', full_name)45 write_textfield('id_displayname', user.full_name)
46 write_textfield('id_email', email)46 write_textfield('id_email', user.email)
47 write_textfield('id_password', password)47 write_textfield('id_password', user.password)
48 write_textfield('id_passwordconfirm', password)48 write_textfield('id_passwordconfirm', user.password)
49 click_button(get_element(name='continue'))49 click_button(get_element(name='continue'))
5050
51def confirm_email(confirmation_code):51def confirm_email(confirmation_code):
5252
=== added file 'ubuntuone/web/tests/sst/shared/data/user.py'
--- ubuntuone/web/tests/sst/shared/data/user.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/shared/data/user.py 2011-12-19 15:40:32 +0000
@@ -0,0 +1,25 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Data class for a User."""
18
19class User:
20 "Class for User information."
21
22 def __init__(self, full_name, email, password):
23 self.full_name = full_name
24 self.email = email
25 self.password = password

Subscribers

People subscribed via source and target branches