Merge lp:~rmcbride/ubuntuone-testing/sst-services-page into lp:ubuntuone-testing

Proposed by Rick McBride
Status: Merged
Approved by: Rick McBride
Approved revision: 33
Merged at revision: 27
Proposed branch: lp:~rmcbride/ubuntuone-testing/sst-services-page
Merge into: lp:ubuntuone-testing
Diff against target: 741 lines (+633/-2)
18 files modified
ubuntuone/web/qa/tests/payments/u1webp-001.py (+28/-0)
ubuntuone/web/qa/tests/payments/u1webp-002.py (+24/-0)
ubuntuone/web/qa/tests/payments/u1webp-003.py (+21/-0)
ubuntuone/web/qa/tests/services/README.txt (+9/-0)
ubuntuone/web/qa/tests/services/u1webs-002.py (+13/-0)
ubuntuone/web/qa/tests/services/u1webse-001.py (+14/-0)
ubuntuone/web/qa/tests/services/u1webse-002.py (+17/-0)
ubuntuone/web/qa/tests/services/u1webse-003.py (+17/-0)
ubuntuone/web/qa/tests/services/u1webse-004.py (+27/-0)
ubuntuone/web/qa/tests/services/u1webse-005.py (+18/-0)
ubuntuone/web/qa/tests/services/u1webse-006.py (+18/-0)
ubuntuone/web/qa/tests/shared/_actions.py (+19/-0)
ubuntuone/web/qa/tests/shared/actions/__init__.py (+1/-0)
ubuntuone/web/qa/tests/shared/actions/payment.py (+203/-0)
ubuntuone/web/qa/tests/shared/actions/payment_confirmed.py (+62/-0)
ubuntuone/web/qa/tests/shared/actions/services.py (+138/-0)
ubuntuone/web/qa/tests/shared/config.py (+2/-0)
ubuntuone/web/qa/tests/smoketest/README.txt (+2/-2)
To merge this branch: bzr merge lp:~rmcbride/ubuntuone-testing/sst-services-page
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve
Review via email: mp+75772@code.launchpad.net

Commit message

Adds testing for services page. contain's Leo's additions to re-org the SST tests, and additional page tests.

Description of the change

Adds testing for services page. contain's Leo's additions to re-org the SST tests, and additional page tests.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

Thanks for the review and the merge, Rick.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed directory 'qa' => 'ubuntuone'
=== renamed directory 'qa/selenium' => 'ubuntuone/web'
=== added directory 'ubuntuone/web/qa'
=== added directory 'ubuntuone/web/qa/tests'
=== added directory 'ubuntuone/web/qa/tests/payments'
=== added file 'ubuntuone/web/qa/tests/payments/u1webp-001.py'
--- ubuntuone/web/qa/tests/payments/u1webp-001.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/payments/u1webp-001.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,28 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8from datetime import date
9import actions.services as services_actions
10import actions.payment as payment_actions
11import actions.paymet_confirmed as payment_confirmed_actions
12
13set_base_url(base_url)
14login(username, password)
15title_is(u'Ubuntu One : Dashboard')
16services_actions.open()
17services_actions.buy_music_streaming_yearly()
18payment_actions.assert_title()
19payment_actions.place_order_with_valid_card()
20payment_actions.confirm_payment_details()
21payment_confirmed_actions.assert_processed_payment('annually', 1, 39.99,
22 trial=True)
23payment_confirmed_actions.view_account()
24# TODO move this to the account actions module.
25get_element(tag='span', text='29 trial days left')
26get_element(tag='p', text='You are subscribed yearly')
27get_element(tag='span', text='See my subscription')
28get_element(tag='span', text='20GB with Music Streaming')
029
=== added file 'ubuntuone/web/qa/tests/payments/u1webp-002.py'
--- ubuntuone/web/qa/tests/payments/u1webp-002.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/payments/u1webp-002.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,24 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8import actions.services as services_actions
9import actions.payment as payment_actions
10import actions.payment_confirmed as payment_confirmed_actions
11
12set_base_url(base_url)
13login(username, password)
14title_is(u'Ubuntu One : Dashboard')
15services_actions.open()
16services_actions.buy_extra_storage()
17payment_actions.assert_title()
18payment_actions.place_order_with_valid_card()
19payment_confirmed_actions.assert_title()
20payment_confirmed_actions.assert_processed_payment('annually', 29.99, 29.99)
21payment_confirmed_actions.view_account()
22# TODO move this to the module account actions.
23get_element(tag='span', text='5GB with Ubuntu One Free')
24get_element(tag='span', text='100GB from storage add-on')
025
=== added file 'ubuntuone/web/qa/tests/payments/u1webp-003.py'
--- ubuntuone/web/qa/tests/payments/u1webp-003.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/payments/u1webp-003.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,21 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8import actions.services as services_actions
9import actions.payment as payment_actions
10import actions.payment_confirmed as payment_confirmed_actions
11
12set_base_url(base_url)
13login(username, password)
14title_is(u'Ubuntu One : Dashboard')
15services_actions.open()
16services_actions.buy_music_streaming()
17payment_actions.assert_title()
18payment_actions.place_order_with_refused_card()
19payment_actions.confirm_payment_details()
20payment_confirmed_actions.assert_title()
21payment_confirmed_actions.assert_failed_payment()
022
=== added directory 'ubuntuone/web/qa/tests/services'
=== added file 'ubuntuone/web/qa/tests/services/README.txt'
--- ubuntuone/web/qa/tests/services/README.txt 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/services/README.txt 2011-09-16 16:36:28 +0000
@@ -0,0 +1,9 @@
1The tests involving login require a username (email) and
2password to login to SSO. Create a file ``_passwords.py`` in the ``services``
3directory, with the following contents::
4
5 username = 'my.username@canonical.com'
6 password = 'mypassword'
7
8(``_passwords.py`` is ignored by bazaar so you can't accidentally check it
9into the repository.)
010
=== added file 'ubuntuone/web/qa/tests/services/u1webs-002.py'
--- ubuntuone/web/qa/tests/services/u1webs-002.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/services/u1webs-002.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,13 @@
1from sst.actions import *
2from additional._actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from additional.config import base_url
8
9set_base_url(base_url)
10login(username, password)
11title_is(u'Ubuntu One : Dashboard')
12goto('/services/')
13title_is(u'Ubuntu One : Services')
014
=== added file 'ubuntuone/web/qa/tests/services/u1webse-001.py'
--- ubuntuone/web/qa/tests/services/u1webse-001.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/services/u1webse-001.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,14 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8import actions.services as services_actions
9
10set_base_url(base_url)
11login(username, password)
12title_is(u'Ubuntu One : Dashboard')
13services_actions.open()
14services_actions.assert_services_information()
015
=== added file 'ubuntuone/web/qa/tests/services/u1webse-002.py'
--- ubuntuone/web/qa/tests/services/u1webse-002.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/services/u1webse-002.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,17 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8import actions.services as services_actions
9import actions.payment as payment_actions
10
11set_base_url(base_url)
12login(username, password)
13title_is(u'Ubuntu One : Dashboard')
14services_actions.open()
15services_actions.buy_music_streaming_monthly()
16payment_actions.assert_title()
17payment_actions.assert_monthly_music_streaming_subscription()
018
=== added file 'ubuntuone/web/qa/tests/services/u1webse-003.py'
--- ubuntuone/web/qa/tests/services/u1webse-003.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/services/u1webse-003.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,17 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8import actions.services as services_actions
9import actions.payment as payment_actions
10
11set_base_url(base_url)
12login(username, password)
13title_is(u'Ubuntu One : Dashboard')
14services_actions.open()
15services_actions.buy_music_streaming_yearly()
16payment_actions.assert_title()
17payment_actions.assert_annually_music_streaming_subscription()
018
=== added file 'ubuntuone/web/qa/tests/services/u1webse-004.py'
--- ubuntuone/web/qa/tests/services/u1webse-004.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/services/u1webse-004.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,27 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8import actions.services as services_actions
9
10set_base_url(base_url)
11login(username, password)
12title_is(u'Ubuntu One : Dashboard')
13services_actions.open()
14services_actions.assert_storage(1)
15services_actions.increase_storage_quantity()
16services_actions.assert_storage(2)
17services_actions.decrease_storage_quantity()
18for quantity in range(2, 11):
19 services_actions.increase_storage_quantity()
20 services_actions.assert_storage(quantity)
21for quantity in range(9, 4, -1):
22 services_actions.decrease_storage_quantity()
23 services_actions.assert_storage(quantity)
24services_actions.set_storage_quantity('25')
25# Move the focus out of the textfield.
26click('storage-gb')
27services_actions.assert_storage(25)
028
=== added file 'ubuntuone/web/qa/tests/services/u1webse-005.py'
--- ubuntuone/web/qa/tests/services/u1webse-005.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/services/u1webse-005.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,18 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8import actions.services as services_actions
9import actions.payment as payment_actions
10
11set_base_url(base_url)
12login(username, password)
13title_is(u'Ubuntu One : Dashboard')
14services_actions.open()
15services_actions.set_storage_quantity(5)
16services_actions.buy_extra_storage_monthly()
17payment_actions.assert_title()
18payment_actions.assert_monthly_extra_storage_subscription(5)
019
=== added file 'ubuntuone/web/qa/tests/services/u1webse-006.py'
--- ubuntuone/web/qa/tests/services/u1webse-006.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/services/u1webse-006.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,18 @@
1from sst.actions import *
2from _actions import *
3try:
4 from _passwords import username, password
5except:
6 print "try adding a _passwords.py file if you expect this to work ;)"
7from config import base_url
8import actions.services as services_actions
9import actions.payment as payment_actions
10
11set_base_url(base_url)
12login(username, password)
13title_is(u'Ubuntu One : Dashboard')
14services_actions.open()
15services_actions.set_storage_quantity(5)
16services_actions.buy_extra_storage_yearly()
17payment_actions.assert_title()
18payment_actions.assert_annually_extra_storage_subscription(5)
019
=== added directory 'ubuntuone/web/qa/tests/shared'
=== added file 'ubuntuone/web/qa/tests/shared/__init__.py'
=== added file 'ubuntuone/web/qa/tests/shared/_actions.py'
--- ubuntuone/web/qa/tests/shared/_actions.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/shared/_actions.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,19 @@
1from sst.actions import *
2from config import base_url
3
4set_base_url(base_url)
5set_wait_timeout(40)
6
7
8def wait_for_title_to_change(title):
9 waitfor(title_is, title)
10
11def login(username, password):
12 goto('/auth/login')
13 wait_for_title_to_change('Log in')
14 is_textfield('id_email')
15 is_textfield('id_password')
16 textfield_write('id_email', username)
17 textfield_write('id_password', password)
18 button_click(get_element(css_class='btn', name='continue'))
19 button_click(get_element(css_class='btn', name='yes'))
020
=== added directory 'ubuntuone/web/qa/tests/shared/actions'
=== added file 'ubuntuone/web/qa/tests/shared/actions/__init__.py'
--- ubuntuone/web/qa/tests/shared/actions/__init__.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/shared/actions/__init__.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,1 @@
1
02
=== added file 'ubuntuone/web/qa/tests/shared/actions/payment.py'
--- ubuntuone/web/qa/tests/shared/actions/payment.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/shared/actions/payment.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,203 @@
1# -*- coding: utf-8 -*-
2
3# Authors:
4# Leo Arias <leo.arias@canonical.com>
5#
6# Copyright 2011 Canonical Ltd.
7#
8# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU General Public License version 3, as published
10# by the Free Software Foundation.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranties of
14# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15# PURPOSE. See the GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program. If not, see <http://www.gnu.org/licenses/>.
19
20"""Actions for the Payments page of the Ubuntu One website."""
21
22from datetime import date
23from sst.actions import *
24
25def assert_title():
26 """Assert that the title of the page is the expected."""
27 title_is(u'Ubuntu One : Checkout')
28
29def assert_music_streaming_subscription(period):
30 """Assert that the information of the new music streaming subscription
31 is the expected.
32
33 Keyword arguments:
34 period -- The period of the subscription.
35 It can be 'monthly' or 'annually'.
36
37 """
38 if period == 'monthly':
39 price = '$3.99'
40 elif period == 'annually':
41 price = '$39.99'
42 else:
43 # TODO throw an error.
44 pass
45 get_element(tag='h1', text='New Subscription')
46 get_element(css_class='price', text=price)
47 get_element(tag='span', css_class='price', text=price)
48 today = date.today()
49 next_month = today.replace(month = today.month + 1)
50 get_element(tag='p', text='This is a trial subscription which will ' \
51 'expire %(next_month)s afterwhich your card ' \
52 'will automatically be billed %(price) %(period)'
53 % {'next_month':
54 next_month.strftime('%B %-d, %Y'),
55 'price': price, 'period': period})
56
57def assert_monthly_music_streaming_subscription():
58 """Assert that the information of the new monthly music streaming
59 subscription is the expected.
60
61 """
62 assert_music_streaming_subscription('monthly')
63
64def assert_annually_music_streaming_subscription():
65 """Assert that the information of the new yearly music streaming
66 subscription is the expected.
67
68 """
69 assert_music_streaming_subscription('annually')
70
71def assert_extra_storage_subscription(period, quantity):
72 """Assert that the information of the new extra storage subscription
73 is the expected.
74
75 Keyword arguments:
76 period -- The period of the subscription.
77 It can be 'monthly' or 'annually'.
78 quantity -- The quantity of extra storage to buy.
79
80 """
81 today = date.today()
82 if period == 'monthly':
83 price_per_add_on = 2.99
84 period_alternate = period
85 period_end = today.replace(month = today.month + 1)
86 elif period == 'annually':
87 price_per_add_on = 29.99
88 period_alternate = 'yearly'
89 period_end = today.replace(year = today.year + 1)
90 else:
91 # TODO throw an error.
92 pass
93 price_per_period = quantity * price_per_add_on
94 get_element(tag='h1', text='Subscription Change')
95 get_element(tag='p', text='%(quantity)d x 20-Pack with 20 GB (%(period)s)'
96 % {'quantity': quantity,
97 'period': period_alternate})
98 get_element(tag='strong', text=period_alternate.capitalize())
99 get_element(css_class='price', text='$' + str(price_per_add_on))
100 get_element(tag='span', css_class='price',
101 text='$' + str(price_per_period))
102 get_element(tag='p', text='This payment will cover the period from ' \
103 '%(today)s to %(period_end)s afterwhich your ' \
104 'card will automatically be billed $%(price)s ' \
105 '%(period)s'
106 % {'today': today.strftime('%B %-d, %Y'),
107 'period_end':
108 period_end.strftime('%B %-d, %Y'),
109 'price': str(price_per_period),
110 'period': period})
111
112def assert_monthly_extra_storage_subscription(quantity):
113 """Assert that the information of the new extra storage subscription is
114 the expected.
115
116 Keyword arguments:
117 quantity -- The quantity of extra storage to buy.
118
119 """
120 assert_extra_storage_subscription('monthly', quantity)
121
122def assert_annually_extra_storage_subscription(quantity):
123 """Assert that the information of the new extra storage subscription is
124 the expected.
125
126 Keyword arguments:
127 quantity -- The quantity of extra storage to buy.
128
129 """
130 assert_extra_storage_subscription('annually', quantity)
131
132def set_billing_address(street='Test Street', city='Test City',
133 state='Test State', postal_code='12345',
134 country='United States'):
135 """Set the billing address information.
136
137 Keyword arguments:
138 street -- The street of the address (default 'Test Street').
139 city -- The city of the address (default 'Test City').
140 state -- The state or region of the address (default 'Test State').
141 postal_code -- The postal code of the address (default '12345').
142 country -- The country of the address (default 'United States').
143
144 """
145 textfield_write('id_street', street)
146 textfield_write('id_city', city)
147 textfield_write('id_state', state)
148 textfield_write('id_postal', postal_code)
149 set_select('id_country', country)
150
151def set_credit_card_details(card_type='Visa', name='Test Name',
152 number='4111111111111111', ccv='123',
153 expiration_month='10', expiration_year='2015'):
154 """Set the credit card information.
155
156 Default value are a valid credit card for payments on the staging
157 environment.
158
159 Keyword arguments:
160 card_type -- The type of the credit card (default 'Visa')
161 name -- The name on the card (default 'Test Name')
162 number -- The credit card number (default '4111111111111111')
163 ccv -- The CCV number of the credit card (default '123')
164 expiration_month -- The month of expiration (default '10')
165 expiration_year -- The year of expiration (default '2015')
166
167 """
168 set_select('id_card_type', card_type)
169 textfield_write('id_card_holder', name)
170 textfield_write('id_card_number', number)
171 textfield_write('id_card_ccv', ccv)
172 set_select('id_card_expiration_0', expiration_month)
173 set_select('id_card_expiration_1', expiration_year)
174
175def place_order_with_valid_card():
176 """Place the order with a credit card that will be accepted on the
177 staging environment.
178
179 """
180 set_billing_address()
181 set_credit_card_details()
182 agree_and_place_order()
183
184def place_order_with_refused_card():
185 """Place the order with a credit card that will be refused on the
186 staging environment.
187
188 """
189 set_billing_address()
190 set_credit_card_details(name='REFUSED')
191 agree_and_place_order()
192
193
194def agree_and_place_order():
195 """Click the button to agree with the terms and conditions and place
196 the order.
197
198 """
199 button_click(get_element(css_class='cta', value='Purchase'))
200
201def confirm_payment_details():
202 title_is(u'Ubuntu One : Confirm Payment Details')
203 link_click(get_element(css_class='cta', href='confirmed'))
0204
=== added file 'ubuntuone/web/qa/tests/shared/actions/payment_confirmed.py'
--- ubuntuone/web/qa/tests/shared/actions/payment_confirmed.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/shared/actions/payment_confirmed.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,62 @@
1# -*- coding: utf-8 -*-
2
3# Authors:
4# Leo Arias <leo.arias@canonical.com>
5#
6# Copyright 2011 Canonical Ltd.
7#
8# This program is free software: you can redistribute it and/or modify it
9# under the terms of the GNU General Public License version 3, as published
10# by the Free Software Foundation.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranties of
14# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15# PURPOSE. See the GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program. If not, see <http://www.gnu.org/licenses/>.
19
20"""Actions for the Payment Confirmed page of the Ubuntu One website."""
21
22from sst.actions import *
23
24def assert_title():
25 """Assert that the title of the page is the expected."""
26 title_is(u'Ubuntu One : Confirm Payment Details')
27
28def assert_failed_payment():
29 """Assert that the payment failed."""
30 get_element(tag='h1', text='Your Payment Failed')
31 get_element(tag='a', text='fill out the details here', href='/payment/')
32
33def assert_processed_payment(period, paid, price, trial=False):
34 """Assert that the payment was processed.
35
36 Keyword arguments:
37 period -- The period of the service paid.
38 paid -- The paid amount.
39 price -- The price of the service, per period.
40 trial -- Indicates if the service paid has a trial period
41 (default False).
42
43 """
44 get_element(tag='h1', text='Payment Processed')
45 today = date.today()
46 if trial or period == 'monthly':
47 expire_date = today.replace(month = today.month + 1)
48 elif period == 'annually':
49 expire_date = today.replace(year = today.year + 1)
50 # TODO assert the paid amount.
51 # TODO assert payments in euros.
52 get_element(tag='dt', css_class='purchase_details'
53 text='Expires: %(expire_date)s'
54 % {'expire_date': expire_date.strftime('%B %-d, %Y')})
55 get_element(tag='p', css_class='explanation',
56 text='Your card will automatically be billed $%(price)s ' \
57 '%(period)s' % {'price': str(price), 'period': period})
58 get_element(tag='dd', text='AUTHORISED')
59
60def view_account():
61 """Go to the account information page."""
62 link_click(get_element(tag='a', text='View your account'))
063
=== added file 'ubuntuone/web/qa/tests/shared/actions/services.py'
--- ubuntuone/web/qa/tests/shared/actions/services.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/shared/actions/services.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,138 @@
1# -*- coding: utf-8 -*-
2
3# Authors:
4# Rick McBride <rick.mcbride@canonical.com>
5# Leo Arias <leo.arias@canonical.com>
6#
7# Copyright 2011 Canonical Ltd.
8#
9# This program is free software: you can redistribute it and/or modify it
10# under the terms of the GNU General Public License version 3, as published
11# by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranties of
15# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16# PURPOSE. See the GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program. If not, see <http://www.gnu.org/licenses/>.
20
21"""Actions for the Services page of the Ubuntu One website."""
22
23from sst.actions import *
24
25def open():
26 """Open the services page and assert it's title."""
27 goto('/services/')
28 assert_title()
29
30def assert_title():
31 """Assert that the title of the page is the expected."""
32 title_is(u'Ubuntu One : Services')
33
34def assert_services_information():
35 """Assert that the information about the services is the expected."""
36 assert_free_service_information()
37 assert_music_streaming_service_information()
38 assert_storage_service_information()
39 assert_discount_information()
40
41def assert_free_service_information():
42 """Assert that the information about the free service is the expected."""
43 get_element(tag='h1', text='Free')
44 get_element(tag='li', text='File sync across platforms')
45 get_element(tag='li', text='Share folders and files')
46 get_element(tag='li', text='Access on your mobile')
47
48def assert_music_streaming_service_information():
49 """Assert that the information about the music streaming service is
50 the expected.
51
52 """
53 # TODO there are two Music Streaming elements. We should use xpath to be
54 # sure that we are on the right section.
55 #get_element(tag='h1', text='Music Streaming')
56 get_element(css_class='try-free', text='Try for FREE')
57 get_element(tag='li', text='Music streaming on your mobile')
58 get_element(tag='li', text='20 GB of Storage built in')
59 get_element(tag='li', text='Listen offline on Android')
60 get_element(tag='li', text='$3.99 / month or $39.99 / year')
61
62def assert_storage_service_information():
63 """Assert that the information about the storage service is the
64 expected.
65
66 """
67 get_element(tag='h1', text='Storage')
68 get_element(tag='li', text='20 GB')
69 get_element(tag='li', text='$2.99 / month')
70 get_element(tag='li', text='or $29.99 / year')
71
72def assert_discount_information():
73 """Assert that the yearly discount information is the expected."""
74 get_element(tag='h1', text='Discount')
75 get_element(tag='p', text='Two months free on Music Streaming and Storage '
76 'when you sign up for 12 months')
77
78def buy_music_streaming_monthly():
79 """Buy the monthly music streaming service."""
80 radio_select('ms1')
81 button_click(get_elements(css_class='buy-now',
82 text='Buy now and go to checkout')[0])
83
84def buy_music_streaming_yearly():
85 """Buy the yearly music streaming service."""
86 radio_select('ms2')
87 buy_music_streaming()
88
89def buy_music_streaming():
90 """Click the button to buy the music streaming service."""
91 button_click(get_elements(css_class='buy-now',
92 text='Buy now and go to checkout')[0])
93
94def assert_storage(quantity):
95 """Asert the storage quantity selected and its space and price.
96
97 Keyword arguments:
98 quantity -- The expected storage quantity.
99
100 """
101 text_is('qty', str(quantity))
102 text_is('storage-gb', '%sGB' % (quantity * 20))
103 monthly_price = quantity * 2.99
104 text_is('storage-monthly-price', '$%s' % monthly_price)
105 annual_price = quantity * 29.99
106 text_is('storage-annual-price', '$%s' % annual_price)
107
108def increase_storage_quantity():
109 """Click the button that increases the storage quantity to buy."""
110 button_click('plus_qty')
111
112def decrease_storage_quantity():
113 """Click the button that decreases the storage quantity to buy."""
114 button_click('minus_qty')
115
116def set_storage_quantity(quantity):
117 """Set the storage quantity to buy.
118
119 Keyword arguments:
120 quantity -- The quantity to buy.
121
122 """
123 textfield_write('qty', str(quantity))
124
125def buy_extra_storage_monthly():
126 """Buy the monthly extra storage service."""
127 radio_select('st1')
128 buy_extra_storage()
129
130def buy_extra_storage_yearly():
131 """Buy the yearly extra storage service."""
132 radio_select('st2')
133 buy_extra_storage()
134
135def buy_extra_storage():
136 """Click the button to buy extra storage."""
137 button_click(get_elements(css_class='buy-now',
138 text='Buy now and go to checkout')[1])
0139
=== added file 'ubuntuone/web/qa/tests/shared/config.py'
--- ubuntuone/web/qa/tests/shared/config.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/qa/tests/shared/config.py 2011-09-16 16:36:28 +0000
@@ -0,0 +1,2 @@
1# set below according to need (staging v production v test instance)
2base_url = 'https://staging.one.ubuntu.com/'
03
=== renamed directory 'qa/selenium/smoketest' => 'ubuntuone/web/qa/tests/smoketest'
=== modified file 'ubuntuone/web/qa/tests/smoketest/README.txt'
--- qa/selenium/smoketest/README.txt 2011-04-22 18:05:31 +0000
+++ ubuntuone/web/qa/tests/smoketest/README.txt 2011-09-16 16:36:28 +0000
@@ -1,9 +1,9 @@
1The tests involving login require a username (email) and1The tests involving login require a username (email) and
2password to login to SSO. Create a file ``passwords.py`` in the ``staging-pay``2password to login to SSO. Create a file ``_passwords.py`` in the ``smoketest``
3directory, with the following contents::3directory, with the following contents::
44
5 username = 'my.username@canonical.com'5 username = 'my.username@canonical.com'
6 password = 'mypassword'6 password = 'mypassword'
77
8(``passwords.py`` is ignored by bazaar so you can't accidentally check it8(``_passwords.py`` is ignored by bazaar so you can't accidentally check it
9into the repository.)9into the repository.)

Subscribers

People subscribed via source and target branches