Merge lp:~elopio/+junk/referrals-create-account into lp:ubuntuone-testing

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~elopio/+junk/referrals-create-account
Merge into: lp:ubuntuone-testing
Diff against target: 254 lines (+181/-5)
4 files modified
ubuntuone/web/tests/sst/referrals/u1webref123_createaccountfromreferralslink.py (+53/-0)
ubuntuone/web/tests/sst/shared/actions/account.py (+76/-5)
ubuntuone/web/tests/sst/shared/actions/newdashboard.py (+38/-0)
ubuntuone/web/tests/sst/shared/actions/setup.py (+14/-0)
To merge this branch: bzr merge lp:~elopio/+junk/referrals-create-account
Reviewer Review Type Date Requested Status
Corey Goldberg Pending
Review via email: mp+118605@code.launchpad.net

This proposal has been superseded by a proposal from 2012-08-07.

Commit message

Added the first referrals test: Create account from referrals link.

Description of the change

Added the first referrals test: Create account from referrals link.
Please note that the new account creation is failing. A separate branch will fix that.

To post a comment you must log in.
117. By Leo Arias

Fixed the calls to assert_equal.

118. By Leo Arias

Return floats.

119. By Leo Arias

Added the missing logout action call.

Unmerged revisions

119. By Leo Arias

Added the missing logout action call.

118. By Leo Arias

Return floats.

117. By Leo Arias

Fixed the calls to assert_equal.

116. By Leo Arias

Removed the print statements.

115. By Leo Arias

Added the first referrals test: Create account from referrals link.

114. By Leo Arias

Merged with trunk.

113. By Leo Arias

Added a couple of actions to account.

112. By Leo Arias

Cleaned a little the account actions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'ubuntuone/web/tests/sst/referrals'
2=== added file 'ubuntuone/web/tests/sst/referrals/u1webref123_createaccountfromreferralslink.py'
3--- ubuntuone/web/tests/sst/referrals/u1webref123_createaccountfromreferralslink.py 1970-01-01 00:00:00 +0000
4+++ ubuntuone/web/tests/sst/referrals/u1webref123_createaccountfromreferralslink.py 2012-08-07 18:48:18 +0000
5@@ -0,0 +1,53 @@
6+# -*- coding: utf-8 -*-
7+
8+# Copyright 2012 Canonical Ltd.
9+#
10+# This program is free software: you can redistribute it and/or modify it
11+# under the terms of the GNU General Public License version 3, as published
12+# by the Free Software Foundation.
13+#
14+# This program is distributed in the hope that it will be useful, but
15+# WITHOUT ANY WARRANTY; without even the implied warranties of
16+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17+# PURPOSE. See the GNU General Public License for more details.
18+#
19+# You should have received a copy of the GNU General Public License along
20+# with this program. If not, see <http://www.gnu.org/licenses/>.
21+
22+from sst.actions import *
23+import actions.setup as setup_actions
24+import actions.account as account_actions
25+import actions.newdashboard as dashboard_actions
26+import actions.header as header_actions
27+
28+# Log in with the referrer.
29+setup_actions.setup()
30+account_actions.open()
31+referrer_available_space_before_referral = \
32+ account_actions.get_available_storage_space_in_gigabytes()
33+referrer_storage_space_from_referrals_before_referral = \
34+ account_actions.get_storage_space_from_referrals_in_gigabytes()
35+dashboard_actions.open()
36+referrals_link = dashboard_actions.get_referrals_link()
37+header_actions.logout()
38+# Log in with the recipient.
39+setup_actions.setup_new_user_with_referrals_link(referrals_link)
40+account_actions.open()
41+recipient_available_space = \
42+ account_actions.get_available_storage_space_in_gigabytes()
43+assert_equal(recipient_available_space, 5.5)
44+recipient_storage_space_from_referrals = \
45+ account_actions.get_storage_space_from_referrals_in_gigabytes()
46+assert_equal(recipient_storage_space_from_referrals, 0.5)
47+header_actions.logout()
48+# Log in again with the referrer.
49+setup_actions.setup()
50+account_actions.open()
51+referrer_available_space_after_referral = \
52+ account_actions.get_available_storage_space_in_gigabytes()
53+assert_equal(referrer_available_space_after_referral,
54+ referrer_available_space_before_referral + 0.5)
55+referrer_storage_space_from_referrals_after_referral = \
56+ account_actions.get_storage_space_from_referrals_in_gigabytes()
57+assert_equal(referrer_storage_space_from_referrals_after_referral,
58+ referrer_storage_space_from_referrals_before_referral + 0.5)
59
60=== modified file 'ubuntuone/web/tests/sst/shared/actions/account.py'
61--- ubuntuone/web/tests/sst/shared/actions/account.py 2011-12-09 18:19:11 +0000
62+++ ubuntuone/web/tests/sst/shared/actions/account.py 2012-08-07 18:48:18 +0000
63@@ -1,6 +1,6 @@
64 # -*- coding: utf-8 -*-
65
66-# Copyright 2011 Canonical Ltd.
67+# Copyright 2011, 2012 Canonical Ltd.
68 #
69 # This program is free software: you can redistribute it and/or modify it
70 # under the terms of the GNU General Public License version 3, as published
71@@ -16,6 +16,8 @@
72
73 """Actions for the Account page of the Ubuntu One website."""
74
75+import re
76+
77 from sst.actions import *
78 import actions.header as header_actions
79
80@@ -23,29 +25,98 @@
81 header_actions.open_my_account()
82 assert_page_title(), 'My account should be opened'
83
84+
85 def assert_page_title():
86 assert_title(u'Ubuntu One : Your Account')
87
88+
89 def assert_account_details(full_name, email):
90 _assert_name(full_name)
91 _assert_email(email)
92 _assert_password('********')
93
94+
95 def _assert_name(full_name):
96 name_element = _get_user_details_data_elements()[0]
97 assert_text(name_element, full_name)
98
99+
100+def _get_user_details_data_elements():
101+ return get_elements_by_css('.user-details dd')
102+
103+
104 def _assert_email(email):
105 email_element = _get_user_details_data_elements()[1]
106 assert_text(email_element, email)
107
108+
109 def _assert_password(password):
110 password_element = _get_user_details_data_elements()[2]
111 assert_text(password_element, password)
112
113-def _get_user_details_data_elements():
114- return get_elements_by_css('.user-details dd')
115
116 def click_edit_account_details():
117- click_link(get_element(text='Edit your account details in Ubuntu Single '
118- 'Sign On'))
119+ click_link(_get_edit_account_details_link())
120+
121+
122+def _get_edit_account_details_link():
123+ get_element(text='Edit your account details in Ubuntu Single '
124+ 'Sign On')
125+
126+
127+def get_available_storage_space_in_gigabytes():
128+ available_storage_space = _get_available_storage_space()
129+ assert available_storage_space.endswith(' GB'), \
130+ 'Available storage space is not in gigabytes.'
131+ return float(available_storage_space[:-3])
132+
133+
134+def _get_available_storage_space():
135+ storage_summary = _get_storage_summary_string()
136+ match = _get_storage_summary_match(storage_summary)
137+ return match.group(3)
138+
139+
140+def _get_storage_summary_string():
141+ return _get_storage_summary_label().text
142+
143+
144+def _get_storage_summary_label():
145+ return get_elements_by_css('.storage > p')[0]
146+ click_link(_get_edit_account_details_link())
147+
148+
149+def _get_edit_account_details_link():
150+ get_element(text='Edit your account details in Ubuntu Single '
151+ 'Sign On')
152+
153+
154+def _get_storage_summary_match(storage_summary_string):
155+ return re.match('(.*)% in use \((.*) of (.*)\)', storage_summary_string)
156+
157+
158+def get_storage_space_from_referrals_in_gigabytes():
159+ storage_space_from_referrals = _get_storage_space_from_referrals()
160+ assert storage_space_from_referrals.endswith('GB'), \
161+ 'Storage space from referrals is not in gigabytes'
162+ return float(storage_space_from_referrals[:-2])
163+
164+
165+def _get_storage_space_from_referrals():
166+ storage_space_from_referrals_string = \
167+ _get_storage_space_from_referrals_string()
168+ storage_space_from_referrals = '0GB'
169+ if storage_space_from_referrals_string:
170+ match = re.match('(.*) from referrals',
171+ storage_space_from_referrals_string)
172+ storage_space_from_referrals = match.group(1)
173+ return storage_space_from_referrals
174+
175+
176+def _get_storage_space_from_referrals_string():
177+ storage_elements = get_elements_by_css('.storage .items>li>span')
178+ storage_space_from_referrals = None
179+ for element in storage_elements:
180+ if 'from referrals' in element.text:
181+ storage_space_from_referrals = element.text
182+ return storage_space_from_referrals
183
184=== added file 'ubuntuone/web/tests/sst/shared/actions/newdashboard.py'
185--- ubuntuone/web/tests/sst/shared/actions/newdashboard.py 1970-01-01 00:00:00 +0000
186+++ ubuntuone/web/tests/sst/shared/actions/newdashboard.py 2012-08-07 18:48:18 +0000
187@@ -0,0 +1,38 @@
188+# -*- coding: utf-8 -*-
189+
190+# Copyright 2012 Canonical Ltd.
191+#
192+# This program is free software: you can redistribute it and/or modify it
193+# under the terms of the GNU General Public License version 3, as published
194+# by the Free Software Foundation.
195+#
196+# This program is distributed in the hope that it will be useful, but
197+# WITHOUT ANY WARRANTY; without even the implied warranties of
198+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
199+# PURPOSE. See the GNU General Public License for more details.
200+#
201+# You should have received a copy of the GNU General Public License along
202+# with this program. If not, see <http://www.gnu.org/licenses/>.
203+
204+
205+from sst.actions import *
206+
207+PAGE_TITLE = u'Ubuntu One : Dashboard'
208+
209+def open():
210+ go_to('dashboard/?newdash=1')
211+ assert_page_title(), 'Dashboard should be opened'
212+
213+
214+def assert_page_title():
215+ assert_title(PAGE_TITLE)
216+
217+
218+# Referrals.
219+
220+def get_referrals_link():
221+ return _get_referrals_element().get_attribute('value')
222+
223+
224+def _get_referrals_element():
225+ return get_element(id='ref-link')
226
227=== modified file 'ubuntuone/web/tests/sst/shared/actions/setup.py'
228--- ubuntuone/web/tests/sst/shared/actions/setup.py 2012-07-15 05:27:44 +0000
229+++ ubuntuone/web/tests/sst/shared/actions/setup.py 2012-08-07 18:48:18 +0000
230@@ -117,6 +117,10 @@
231 skip('Can\'t create new users on production.')
232 else:
233 header_actions.click_login_or_sign_up()
234+ _sign_up_on_sso_and_subscribe(user)
235+
236+
237+def _sign_up_on_sso_and_subscribe(user):
238 sso_actions.create_new_account(user)
239 _confirm_email(user.email)
240 services_actions.agree_and_subscribe_to_free_plan()
241@@ -136,3 +140,13 @@
242 click_button(get_elements('button.cta[type="submit"]')[0], wait=False)
243 else:
244 sso_actions.login(user)
245+
246+
247+def setup_new_user_with_referrals_link(referrals_url):
248+ _go_to_ubuntu_one_home()
249+ _clear_previous_session()
250+ go_to(referrals_url)
251+ user = _get_random_user()
252+ _sign_up_on_sso_and_subscribe(user)
253+ dashboard_actions.wait_for_page_to_load()
254+ header_actions.assert_login(user.full_name)

Subscribers

People subscribed via source and target branches