Merge lp:~elopio/ubuntuone-testing/configglue into lp:ubuntuone-testing
- configglue
- Merge into trunk
Proposed by
Leo Arias
Status: | Merged |
---|---|
Approved by: | Leo Arias |
Approved revision: | 127 |
Merged at revision: | 117 |
Proposed branch: | lp:~elopio/ubuntuone-testing/configglue |
Merge into: | lp:ubuntuone-testing |
Diff against target: |
719 lines (+296/-136) 19 files modified
.bzrignore (+1/-6) ubuntuone/web/tests/sst/account/u1weba001_accountdetails.py (+3/-7) ubuntuone/web/tests/sst/account/u1weba8_createaccount.py (+26/-0) ubuntuone/web/tests/sst/payments/u1webp001_paymusicstreaming.py (+3/-3) ubuntuone/web/tests/sst/payments/u1webp002_payadditionalstorage.py (+1/-2) ubuntuone/web/tests/sst/payments/u1webp003_paywithrefusedcard.py (+3/-3) ubuntuone/web/tests/sst/session/u1webs10_login.py (+4/-9) ubuntuone/web/tests/sst/shared/actions/dashboard.py (+8/-2) ubuntuone/web/tests/sst/shared/actions/files.py (+2/-8) ubuntuone/web/tests/sst/shared/actions/setup.py (+48/-44) ubuntuone/web/tests/sst/shared/config.py (+0/-38) ubuntuone/web/tests/sst/shared/config/environment.py (+49/-0) ubuntuone/web/tests/sst/shared/config/sample.cfg (+25/-0) ubuntuone/web/tests/sst/shared/config/schema.py (+61/-0) ubuntuone/web/tests/sst/shared/data/environment.py (+44/-0) ubuntuone/web/tests/sst/shared/edge_config.py (+0/-2) ubuntuone/web/tests/sst/shared/prod_config.py (+0/-2) ubuntuone/web/tests/sst/shared/stag_config.py (+0/-2) ubuntuone/web/tests/sst/shared/utils/mail.py (+18/-8) |
To merge this branch: | bzr merge lp:~elopio/ubuntuone-testing/configglue |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Corey Goldberg (community) | Approve | ||
Vincent Ladeuil (community) | Approve | ||
Review via email:
|
This proposal supersedes a proposal from 2012-08-08.
Commit message
Added configglue configuration.
Description of the change
Added configglue configuration.
Updated and added tests to try the config files.
Test this branch with:
sst-run -d /path/to/
sst-run -d /path/to/
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Vincent Ladeuil (vila) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2012-06-19 20:26:48 +0000 |
3 | +++ .bzrignore 2012-08-10 00:06:19 +0000 |
4 | @@ -6,12 +6,7 @@ |
5 | *.pyc |
6 | ubuntuone_testing_log |
7 | testdata/*.file |
8 | -passwords.py |
9 | reports/* |
10 | -_passwords.py |
11 | -_musicpasswords.py |
12 | -_localconfig.py |
13 | sourcecode |
14 | results |
15 | -_devserver.py |
16 | -_photopasswords.py |
17 | +local.cfg |
18 | \ No newline at end of file |
19 | |
20 | === modified file 'ubuntuone/web/tests/sst/account/u1weba001_accountdetails.py' |
21 | --- ubuntuone/web/tests/sst/account/u1weba001_accountdetails.py 2012-06-26 16:39:03 +0000 |
22 | +++ ubuntuone/web/tests/sst/account/u1weba001_accountdetails.py 2012-08-10 00:06:19 +0000 |
23 | @@ -23,15 +23,11 @@ |
24 | import actions.setup as setup_actions |
25 | import actions.account as account_actions |
26 | from _passwords import full_name, email |
27 | -from config import ENVIRONMENT |
28 | +from config import environment |
29 | |
30 | setup_actions.setup() |
31 | account_actions.open() |
32 | account_actions.assert_account_details(full_name, email) |
33 | account_actions.click_edit_account_details() |
34 | -url = None |
35 | -if ENVIRONMENT == 'staging': |
36 | - url = 'https://login.staging.ubuntu.com/' |
37 | -else: |
38 | - url = 'https://login.ubuntu.com/' |
39 | -assert_url(url) |
40 | +sso_url = environment.get_environment().sso_url |
41 | +assert_url(sso_url) |
42 | |
43 | === added file 'ubuntuone/web/tests/sst/account/u1weba8_createaccount.py' |
44 | --- ubuntuone/web/tests/sst/account/u1weba8_createaccount.py 1970-01-01 00:00:00 +0000 |
45 | +++ ubuntuone/web/tests/sst/account/u1weba8_createaccount.py 2012-08-10 00:06:19 +0000 |
46 | @@ -0,0 +1,26 @@ |
47 | +# -*- coding: utf-8 -*- |
48 | + |
49 | +# Copyright 2012 Canonical Ltd. |
50 | +# |
51 | +# This program is free software: you can redistribute it and/or modify it |
52 | +# under the terms of the GNU General Public License version 3, as published |
53 | +# by the Free Software Foundation. |
54 | +# |
55 | +# This program is distributed in the hope that it will be useful, but |
56 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
57 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
58 | +# PURPOSE. See the GNU General Public License for more details. |
59 | +# |
60 | +# You should have received a copy of the GNU General Public License along |
61 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
62 | + |
63 | +from sst.actions import * |
64 | +import actions.setup as setup_actions |
65 | +import actions.dashboard as dashboard_actions |
66 | +import actions.header as header_actions |
67 | + |
68 | +setup_actions.setup(new_user=True) |
69 | +user = setup_actions.get_user() |
70 | +dashboard_actions.assert_page_title() |
71 | +header_actions.assert_login(user.full_name) |
72 | +dashboard_actions.assert_welcome_message(user.full_name) |
73 | |
74 | === modified file 'ubuntuone/web/tests/sst/payments/u1webp001_paymusicstreaming.py' |
75 | --- ubuntuone/web/tests/sst/payments/u1webp001_paymusicstreaming.py 2012-06-25 13:59:33 +0000 |
76 | +++ ubuntuone/web/tests/sst/payments/u1webp001_paymusicstreaming.py 2012-08-10 00:06:19 +0000 |
77 | @@ -21,7 +21,7 @@ |
78 | """Pay for the music streaming service.""" |
79 | |
80 | from sst.actions import * |
81 | -from config import ENVIRONMENT |
82 | +from config import environment |
83 | from datetime import date |
84 | import actions.setup as setup_actions |
85 | import actions.services as services_actions |
86 | @@ -29,8 +29,8 @@ |
87 | import actions.payment_confirmed as payment_confirmed_actions |
88 | |
89 | skip('This test must be updated for Ubuntu Pay.') |
90 | -if ENVIRONMENT == 'production': |
91 | - skip('Can\'t test payments on production.') |
92 | +if not environment.can_make_payments(): |
93 | + skip('Can\'t test payments on this environment.') |
94 | setup_actions.setup(new_user=True) |
95 | services_actions.open() |
96 | services_actions.buy_music_streaming_yearly() |
97 | |
98 | === modified file 'ubuntuone/web/tests/sst/payments/u1webp002_payadditionalstorage.py' |
99 | --- ubuntuone/web/tests/sst/payments/u1webp002_payadditionalstorage.py 2012-06-25 13:59:33 +0000 |
100 | +++ ubuntuone/web/tests/sst/payments/u1webp002_payadditionalstorage.py 2012-08-10 00:06:19 +0000 |
101 | @@ -1,5 +1,4 @@ |
102 | # -*- coding: utf-8 -*- |
103 | - |
104 | # Authors: |
105 | # Rick McBride <rick.mcbride@canonical.com> |
106 | # Leo Arias <leo.arias@canonical.com> |
107 | @@ -21,7 +20,7 @@ |
108 | """Pay for the additional sotrage service.""" |
109 | |
110 | from sst.actions import * |
111 | -from config import ENVIRONMENT |
112 | +from config import environment |
113 | import actions.setup as setup_actions |
114 | import actions.services as services_actions |
115 | import actions.payment as payment_actions |
116 | |
117 | === modified file 'ubuntuone/web/tests/sst/payments/u1webp003_paywithrefusedcard.py' |
118 | --- ubuntuone/web/tests/sst/payments/u1webp003_paywithrefusedcard.py 2012-06-25 13:59:33 +0000 |
119 | +++ ubuntuone/web/tests/sst/payments/u1webp003_paywithrefusedcard.py 2012-08-10 00:06:19 +0000 |
120 | @@ -21,15 +21,15 @@ |
121 | """Pay for a service with a refused card.""" |
122 | |
123 | from sst.actions import * |
124 | -from config import ENVIRONMENT |
125 | +from config import environment |
126 | import actions.setup as setup_actions |
127 | import actions.services as services_actions |
128 | import actions.payment as payment_actions |
129 | import actions.payment_confirmed as payment_confirmed_actions |
130 | |
131 | skip('This test must be updated for Ubuntu Pay.') |
132 | -if ENVIRONMENT == 'production': |
133 | - skip('Can\'t test payments on production.') |
134 | +if not environment.can_make_payments(): |
135 | + skip('Can\'t test payments on this environment.') |
136 | setup_actions.setup() |
137 | services_actions.open() |
138 | services_actions.buy_music_streaming() |
139 | |
140 | === renamed file 'ubuntuone/web/tests/sst/session/u1webs002_login.py' => 'ubuntuone/web/tests/sst/session/u1webs10_login.py' |
141 | --- ubuntuone/web/tests/sst/session/u1webs002_login.py 2012-03-27 19:04:46 +0000 |
142 | +++ ubuntuone/web/tests/sst/session/u1webs10_login.py 2012-08-10 00:06:19 +0000 |
143 | @@ -1,6 +1,6 @@ |
144 | # -*- coding: utf-8 -*- |
145 | |
146 | -# Copyright 2011 Canonical Ltd. |
147 | +# Copyright 2011, 2012 Canonical Ltd. |
148 | # |
149 | # This program is free software: you can redistribute it and/or modify it |
150 | # under the terms of the GNU General Public License version 3, as published |
151 | @@ -14,18 +14,13 @@ |
152 | # You should have received a copy of the GNU General Public License along |
153 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
154 | |
155 | -"""Test case u1webs-002 Log in. |
156 | -Log in to the website with an existing account. |
157 | - |
158 | -""" |
159 | - |
160 | from sst.actions import * |
161 | import actions.setup as setup_actions |
162 | import actions.dashboard as dashboard_actions |
163 | import actions.header as header_actions |
164 | -from _passwords import full_name |
165 | |
166 | setup_actions.setup(new_user=False) |
167 | +user = setup_actions.get_user() |
168 | dashboard_actions.assert_page_title() |
169 | -header_actions.assert_login(full_name) |
170 | -dashboard_actions.assert_welcome_message(full_name) |
171 | +header_actions.assert_login(user.full_name) |
172 | +dashboard_actions.assert_welcome_message(user.full_name) |
173 | |
174 | === modified file 'ubuntuone/web/tests/sst/shared/actions/dashboard.py' |
175 | --- ubuntuone/web/tests/sst/shared/actions/dashboard.py 2012-02-02 01:23:26 +0000 |
176 | +++ ubuntuone/web/tests/sst/shared/actions/dashboard.py 2012-08-10 00:06:19 +0000 |
177 | @@ -1,6 +1,6 @@ |
178 | # -*- coding: utf-8 -*- |
179 | |
180 | -# Copyright 2011 Canonical Ltd. |
181 | +# Copyright 2011, 2012 Canonical Ltd. |
182 | # |
183 | # This program is free software: you can redistribute it and/or modify it |
184 | # under the terms of the GNU General Public License version 3, as published |
185 | @@ -24,17 +24,23 @@ |
186 | click_link(_get_dashboard_link()) |
187 | assert_page_title(), 'Dashboard should be opened' |
188 | |
189 | + |
190 | def _get_dashboard_link(): |
191 | return get_element_by_css('#main-nav .dashboard') |
192 | |
193 | + |
194 | def assert_page_title(): |
195 | assert_title(PAGE_TITLE) |
196 | |
197 | + |
198 | def wait_for_page_to_load(): |
199 | wait_for(assert_title, PAGE_TITLE) |
200 | |
201 | + |
202 | def assert_welcome_message(user_full_name): |
203 | - assert_text(_get_welcome_element(), 'Hi %s! Welcome Back' % user_full_name) |
204 | + assert_text(_get_welcome_element(), |
205 | + 'Hi %s! Welcome Back' % user_full_name[:40]) |
206 | + |
207 | |
208 | def _get_welcome_element(): |
209 | return get_element_by_css('h1') |
210 | |
211 | === modified file 'ubuntuone/web/tests/sst/shared/actions/files.py' |
212 | --- ubuntuone/web/tests/sst/shared/actions/files.py 2012-07-15 02:04:04 +0000 |
213 | +++ ubuntuone/web/tests/sst/shared/actions/files.py 2012-08-10 00:06:19 +0000 |
214 | @@ -19,7 +19,7 @@ |
215 | from sst.actions import * |
216 | from sst.actions import _get_elem |
217 | from loading import * |
218 | -from config import * |
219 | +from config import environment |
220 | import urlparse |
221 | |
222 | |
223 | @@ -229,13 +229,7 @@ |
224 | identifier -- The identifier of the file. |
225 | |
226 | """ |
227 | - files_url = None |
228 | - if ENVIRONMENT == 'staging': |
229 | - files_url = 'https://files.staging.one.ubuntu.com/' |
230 | - elif ENVIRONMENT == 'edge': |
231 | - files_url = 'https://files.edge.one.ubuntu.com/' |
232 | - elif ENVIRONMENT == 'production': |
233 | - files_url = 'https://files.one.ubuntu.com/' |
234 | + files_url = environment.get_environment().files_url |
235 | file_url = files_url + str(identifier[3:]) |
236 | return get_element(css_class='download-button', href=file_url) |
237 | |
238 | |
239 | === modified file 'ubuntuone/web/tests/sst/shared/actions/setup.py' |
240 | --- ubuntuone/web/tests/sst/shared/actions/setup.py 2012-07-15 05:27:44 +0000 |
241 | +++ ubuntuone/web/tests/sst/shared/actions/setup.py 2012-08-10 00:06:19 +0000 |
242 | @@ -17,27 +17,27 @@ |
243 | """Set up actions for Ubuntu One sst tests.""" |
244 | |
245 | from sst.actions import * |
246 | -from config import * |
247 | +from config import schema |
248 | +from config import environment |
249 | from data.user import User |
250 | +from data.environment import Environment |
251 | import actions.header as header_actions |
252 | import actions.sso as sso_actions |
253 | import actions.services as services_actions |
254 | import actions.dashboard as dashboard_actions |
255 | import uuid |
256 | from utils import mail |
257 | -try: |
258 | - from _passwords import full_name, email, password |
259 | -except: |
260 | - skip('Try adding a _passwords.py file to the shared folder if you ' \ |
261 | - 'expect this to work. Read the README.txt file ;)') |
262 | |
263 | +# The user account for the test. |
264 | +user = None |
265 | |
266 | def setup(login_or_sign_up=True, new_user=False, user=None): |
267 | - set_wait_timeout(DEFAULT_TIMEOUT) |
268 | + config_values = schema.glue.schema_parser.values('__main__') |
269 | + set_wait_timeout(config_values.get('default_timeout')) |
270 | _go_to_ubuntu_one_home() |
271 | _clear_previous_session() |
272 | if login_or_sign_up: |
273 | - _get_user_and_login_or_sign_up(new_user, user) |
274 | + _make_user_and_login_or_sign_up(new_user, user) |
275 | |
276 | |
277 | def _go_to_ubuntu_one_home(): |
278 | @@ -47,21 +47,7 @@ |
279 | |
280 | |
281 | def get_base_url(): |
282 | - base_url = None |
283 | - if ENVIRONMENT == 'staging': |
284 | - base_url = 'https://staging.one.ubuntu.com' |
285 | - elif ENVIRONMENT == 'edge': |
286 | - base_url = 'https://edge.one.ubuntu.com' |
287 | - elif ENVIRONMENT == 'production': |
288 | - base_url = 'https://one.ubuntu.com' |
289 | - elif ENVIRONMENT == 'development': |
290 | - if address: |
291 | - base_url = address |
292 | - else: |
293 | - skip('development target specified, but address not set.') |
294 | - else: |
295 | - skip('Unknown environment: %s.' % ENVIRONMENT) |
296 | - return base_url |
297 | + return environment.get_environment().url |
298 | |
299 | |
300 | def _clear_previous_session(): |
301 | @@ -76,23 +62,52 @@ |
302 | _go_to_ubuntu_one_home() |
303 | |
304 | |
305 | -def _get_user_and_login_or_sign_up(new_user, user): |
306 | +def _make_user_and_login_or_sign_up(new_user, user): |
307 | if user is None: |
308 | - user = _get_user(new_user) |
309 | + user = _make_user(new_user) |
310 | + _set_user(user) |
311 | _login_or_sign_up(new_user, user) |
312 | dashboard_actions.wait_for_page_to_load() |
313 | header_actions.assert_login(user.full_name) |
314 | |
315 | |
316 | -def _get_user(new_user): |
317 | +def _make_user(new_user): |
318 | test_user = None |
319 | if new_user: |
320 | - test_user = _get_random_user() |
321 | + test_user = _make_random_user() |
322 | else: |
323 | - test_user = _get_user_from_configuration() |
324 | + test_user = _make_user_from_configuration() |
325 | return test_user |
326 | |
327 | |
328 | +def _make_random_user(): |
329 | + random_user_uuid = str(uuid.uuid1()) |
330 | + config_values = schema.glue.schema_parser.values('NewUser') |
331 | + full_name_pattern = config_values.get('full_name_pattern') |
332 | + email_address_pattern = config_values.get('email_address_pattern') |
333 | + random_full_name = full_name_pattern % random_user_uuid |
334 | + random_email_address = email_address_pattern % random_user_uuid |
335 | + password = config_values.get('password') |
336 | + return User(random_full_name, random_email_address, password) |
337 | + |
338 | + |
339 | +def _make_user_from_configuration(): |
340 | + config_values = schema.glue.schema_parser.values('DefaultUser') |
341 | + full_name = config_values.get('full_name') |
342 | + email_address = config_values.get('email_address') |
343 | + password = config_values.get('password') |
344 | + return User(full_name, email_address, password) |
345 | + |
346 | + |
347 | +def _set_user(user_data): |
348 | + global user |
349 | + user = user_data |
350 | + |
351 | + |
352 | +def get_user(): |
353 | + return user |
354 | + |
355 | + |
356 | def _login_or_sign_up(new_user, user): |
357 | if new_user: |
358 | _sign_up(user) |
359 | @@ -100,26 +115,15 @@ |
360 | _login(user) |
361 | |
362 | |
363 | -def _get_user_from_configuration(): |
364 | - return User(full_name, email, password) |
365 | - |
366 | - |
367 | -def _get_random_user(): |
368 | - random_user_uuid = str(uuid.uuid1()) |
369 | - random_user_name = 'Test user ' + random_user_uuid |
370 | - random_user_email = random_user_uuid + '@' + IMAP_SERVER |
371 | - random_user_password = 'Hola123*' |
372 | - return User(random_user_name, random_user_email, random_user_password) |
373 | - |
374 | |
375 | def _sign_up(user): |
376 | - if ENVIRONMENT == 'production': |
377 | - skip('Can\'t create new users on production.') |
378 | - else: |
379 | + if environment.can_create_new_users(): |
380 | header_actions.click_login_or_sign_up() |
381 | sso_actions.create_new_account(user) |
382 | _confirm_email(user.email) |
383 | - services_actions.agree_and_subscribe_to_free_plan() |
384 | + services_actions.agree_and_subscribe_to_free_plan() |
385 | + else: |
386 | + skip('Can\'t create new users on this environment.') |
387 | |
388 | |
389 | def _confirm_email(email): |
390 | @@ -130,7 +134,7 @@ |
391 | |
392 | def _login(user): |
393 | header_actions.click_login_or_sign_up() |
394 | - if ENVIRONMENT == 'development': |
395 | + if environment.is_development_environment(): |
396 | wait_for(assert_title, 'Ubuntu One :') |
397 | switch_to_window() |
398 | click_button(get_elements('button.cta[type="submit"]')[0], wait=False) |
399 | |
400 | === added directory 'ubuntuone/web/tests/sst/shared/config' |
401 | === removed file 'ubuntuone/web/tests/sst/shared/config.py' |
402 | --- ubuntuone/web/tests/sst/shared/config.py 2012-06-04 21:23:42 +0000 |
403 | +++ ubuntuone/web/tests/sst/shared/config.py 1970-01-01 00:00:00 +0000 |
404 | @@ -1,38 +0,0 @@ |
405 | -# -*- coding: utf-8 -*- |
406 | - |
407 | -# Copyright 2011-2012 Canonical Ltd. |
408 | -# |
409 | -# This program is free software: you can redistribute it and/or modify it |
410 | -# under the terms of the GNU General Public License version 3, as published |
411 | -# by the Free Software Foundation. |
412 | -# |
413 | -# This program is distributed in the hope that it will be useful, but |
414 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
415 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
416 | -# PURPOSE. See the GNU General Public License for more details. |
417 | -# |
418 | -# You should have received a copy of the GNU General Public License along |
419 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
420 | - |
421 | -# Waiting actions will wait for this amount of seconds, unless a different |
422 | -# timeout is set calling the SST action set_wait_timeout. |
423 | -DEFAULT_TIMEOUT = 40 |
424 | - |
425 | -# set below according to need (staging v production v edge v development |
426 | -# test instance) |
427 | -ENVIRONMENT = 'staging' |
428 | -#ENVIRONMENT = 'edge' |
429 | -#ENVIRONMENT = 'production' |
430 | -#ENVIRONMENT = 'development' |
431 | - |
432 | -# Email inbox data |
433 | -IMAP_SERVER = 'mail.canonical.com' |
434 | -IMAP_USERNAME = 'u1test' |
435 | -IMAP_PASSWORD = 'password' |
436 | - |
437 | -# You can overwrite the default configuration setting the variables on |
438 | -# the file shared/_local_config.py. |
439 | -try: |
440 | - from _localconfig import * |
441 | -except ImportError: |
442 | - pass |
443 | |
444 | === added file 'ubuntuone/web/tests/sst/shared/config/__init__.py' |
445 | === added file 'ubuntuone/web/tests/sst/shared/config/environment.py' |
446 | --- ubuntuone/web/tests/sst/shared/config/environment.py 1970-01-01 00:00:00 +0000 |
447 | +++ ubuntuone/web/tests/sst/shared/config/environment.py 2012-08-10 00:06:19 +0000 |
448 | @@ -0,0 +1,49 @@ |
449 | +# -*- coding: utf-8 -*- |
450 | + |
451 | +# Copyright 2012 Canonical Ltd. |
452 | +# |
453 | +# This program is free software: you can redistribute it and/or modify it |
454 | +# under the terms of the GNU General Public License version 3, as published |
455 | +# by the Free Software Foundation. |
456 | +# |
457 | +# This program is distributed in the hope that it will be useful, but |
458 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
459 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
460 | +# PURPOSE. See the GNU General Public License for more details. |
461 | +# |
462 | +# You should have received a copy of the GNU General Public License along |
463 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
464 | + |
465 | +from config import schema |
466 | +from data.environment import Environment |
467 | + |
468 | +environment_data = None |
469 | + |
470 | +def get_environment(): |
471 | + global environment_data |
472 | + if not environment_data: |
473 | + config_values = schema.glue.schema_parser.values('Server') |
474 | + name = config_values.get('environment') |
475 | + url = config_values.get('url') |
476 | + sso_url = config_values.get('sso_url') |
477 | + files_url = config_values.get('files_url') |
478 | + environment_data = Environment(name, url, sso_url, files_url) |
479 | + return environment_data |
480 | + |
481 | + |
482 | +def is_staging_environment(): |
483 | + return get_environment().name == 'staging' |
484 | + |
485 | + |
486 | +def is_development_environment(): |
487 | + return get_environment().name == 'production' |
488 | + |
489 | + |
490 | +def can_create_new_users(): |
491 | + return is_staging_environment() |
492 | + |
493 | + |
494 | +def can_make_payments(): |
495 | + return is_staging_environment() |
496 | + |
497 | + |
498 | |
499 | === added file 'ubuntuone/web/tests/sst/shared/config/sample.cfg' |
500 | --- ubuntuone/web/tests/sst/shared/config/sample.cfg 1970-01-01 00:00:00 +0000 |
501 | +++ ubuntuone/web/tests/sst/shared/config/sample.cfg 2012-08-10 00:06:19 +0000 |
502 | @@ -0,0 +1,25 @@ |
503 | +[__main__] |
504 | +default_timeout: 40 |
505 | + |
506 | +[Server] |
507 | +environment: staging |
508 | + |
509 | +[DefaultUser] |
510 | +full_name: Test user |
511 | +email_address: test@example.com |
512 | +password: Hola123* |
513 | + |
514 | +[NewUser] |
515 | +full_name_pattern: Test user %s |
516 | +email_address_pattern: test+%s@example.com |
517 | +password: Hola123* |
518 | +imap_server: mail.example.com |
519 | +imap_port: 993 |
520 | +imap_use_ssl: True |
521 | +imap_username: test |
522 | +imap_password: Hola123* |
523 | + |
524 | +[MusicUser] |
525 | +full_name: Test user |
526 | +email_address: test@example.com |
527 | +password: Hola123* |
528 | \ No newline at end of file |
529 | |
530 | === added file 'ubuntuone/web/tests/sst/shared/config/schema.py' |
531 | --- ubuntuone/web/tests/sst/shared/config/schema.py 1970-01-01 00:00:00 +0000 |
532 | +++ ubuntuone/web/tests/sst/shared/config/schema.py 2012-08-10 00:06:19 +0000 |
533 | @@ -0,0 +1,61 @@ |
534 | +# -*- coding: utf-8 -*- |
535 | + |
536 | +# Copyright 2012 Canonical Ltd. |
537 | +# |
538 | +# This program is free software: you can redistribute it and/or modify it |
539 | +# under the terms of the GNU General Public License version 3, as published |
540 | +# by the Free Software Foundation. |
541 | +# |
542 | +# This program is distributed in the hope that it will be useful, but |
543 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
544 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
545 | +# PURPOSE. See the GNU General Public License for more details. |
546 | +# |
547 | +# You should have received a copy of the GNU General Public License along |
548 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
549 | + |
550 | +from configglue import schema |
551 | +from configglue.glue import configglue |
552 | +import sys |
553 | +import os.path |
554 | + |
555 | +class SstSchema(schema.Schema): |
556 | + |
557 | + default_timeout = schema.IntOption(default=40) |
558 | + |
559 | + class Server(schema.Section): |
560 | + environment = schema.StringOption(default='staging') |
561 | + url = schema.StringOption(default=None) |
562 | + sso_url = schema.StringOption(default=None) |
563 | + files_url = schema.StringOption(default=None) |
564 | + |
565 | + |
566 | + class DefaultUser(schema.Section): |
567 | + full_name = schema.StringOption() |
568 | + email_address = schema.StringOption() |
569 | + password = schema.StringOption() |
570 | + |
571 | + |
572 | + class NewUser(schema.Section): |
573 | + full_name_pattern = schema.StringOption(default='Test user %s', |
574 | + raw=True) |
575 | + email_address_pattern = schema.StringOption(raw=True) |
576 | + password = schema.StringOption(default='Hola123*') |
577 | + imap_server = schema.StringOption() |
578 | + imap_port = schema.IntOption(default=993) |
579 | + imap_use_ssl = schema.BoolOption(default=True) |
580 | + imap_username = schema.StringOption() |
581 | + imap_password = schema.StringOption() |
582 | + |
583 | + |
584 | + class MusicUser(schema.Section): |
585 | + full_name = schema.StringOption() |
586 | + email_address = schema.StringOption() |
587 | + password = schema.StringOption() |
588 | + |
589 | +# XXX The command line arguments are for SST, not for u1 tests. |
590 | +# We will do something to SST on the future so it uses configglue, |
591 | +# or makes available all the additional arguments. |
592 | +sys.argv = [] |
593 | +current_dir = os.path.dirname(os.path.abspath(__file__)) |
594 | +glue = configglue(SstSchema, os.path.join(current_dir, 'local.cfg')) |
595 | |
596 | === added file 'ubuntuone/web/tests/sst/shared/data/environment.py' |
597 | --- ubuntuone/web/tests/sst/shared/data/environment.py 1970-01-01 00:00:00 +0000 |
598 | +++ ubuntuone/web/tests/sst/shared/data/environment.py 2012-08-10 00:06:19 +0000 |
599 | @@ -0,0 +1,44 @@ |
600 | +# -*- coding: utf-8 -*- |
601 | + |
602 | +# Copyright 2012 Canonical Ltd. |
603 | +# |
604 | +# This program is free software: you can redistribute it and/or modify it |
605 | +# under the terms of the GNU General Public License version 3, as published |
606 | +# by the Free Software Foundation. |
607 | +# |
608 | +# This program is distributed in the hope that it will be useful, but |
609 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
610 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
611 | +# PURPOSE. See the GNU General Public License for more details. |
612 | +# |
613 | +# You should have received a copy of the GNU General Public License along |
614 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
615 | + |
616 | +base_urls = {'staging': 'https://staging.one.ubuntu.com', |
617 | + 'edge': 'https://edge.one.ubuntu.com', |
618 | + 'production': 'https://one.ubuntu.com'} |
619 | +sso_urls = {'staging': 'https://loging.staging.ubuntu.com', |
620 | + 'edge': 'https://loging.ubuntu.com', |
621 | + 'production': 'https://loging.ubuntu.com'} |
622 | +files_urls = {'staging': 'https://staging.one.ubuntu.com', |
623 | + 'edge': 'https://edge.one.ubuntu.com', |
624 | + 'production': 'https://one.ubuntu.com'} |
625 | + |
626 | +class Environment: |
627 | + |
628 | + def __init__(self, name, url, sso_url, files_url): |
629 | + self.name = name |
630 | + if url: |
631 | + self.url = url |
632 | + else: |
633 | + self.url = base_urls[name] |
634 | + if sso_url: |
635 | + self.sso_url = sso_url |
636 | + else: |
637 | + self.sso_url = sso_urls[name] |
638 | + if files_url: |
639 | + self.files_url = files_url |
640 | + else: |
641 | + self.files_url = files_urls[name] |
642 | + |
643 | + |
644 | |
645 | === removed file 'ubuntuone/web/tests/sst/shared/edge_config.py' |
646 | --- ubuntuone/web/tests/sst/shared/edge_config.py 2011-09-29 17:53:44 +0000 |
647 | +++ ubuntuone/web/tests/sst/shared/edge_config.py 1970-01-01 00:00:00 +0000 |
648 | @@ -1,2 +0,0 @@ |
649 | -# set below according to need (staging v production v test instance) |
650 | -base_url = 'https://edge.one.ubuntu.com/' |
651 | |
652 | === removed file 'ubuntuone/web/tests/sst/shared/prod_config.py' |
653 | --- ubuntuone/web/tests/sst/shared/prod_config.py 2011-09-29 17:53:44 +0000 |
654 | +++ ubuntuone/web/tests/sst/shared/prod_config.py 1970-01-01 00:00:00 +0000 |
655 | @@ -1,2 +0,0 @@ |
656 | -# set below according to need (staging v production v test instance) |
657 | -base_url = 'https://one.ubuntu.com/' |
658 | |
659 | === removed file 'ubuntuone/web/tests/sst/shared/stag_config.py' |
660 | --- ubuntuone/web/tests/sst/shared/stag_config.py 2011-09-29 17:53:44 +0000 |
661 | +++ ubuntuone/web/tests/sst/shared/stag_config.py 1970-01-01 00:00:00 +0000 |
662 | @@ -1,2 +0,0 @@ |
663 | -# set below according to need (staging v production v test instance) |
664 | -base_url = 'https://staging.one.ubuntu.com/' |
665 | |
666 | === modified file 'ubuntuone/web/tests/sst/shared/utils/mail.py' |
667 | --- ubuntuone/web/tests/sst/shared/utils/mail.py 2012-03-19 19:20:22 +0000 |
668 | +++ ubuntuone/web/tests/sst/shared/utils/mail.py 2012-08-10 00:06:19 +0000 |
669 | @@ -1,6 +1,6 @@ |
670 | # -*- coding: utf-8 -*- |
671 | |
672 | -# Copyright 2011 Canonical Ltd. |
673 | +# Copyright 2011, 2012 Canonical Ltd. |
674 | # |
675 | # This program is free software: you can redistribute it and/or modify it |
676 | # under the terms of the GNU General Public License version 3, as published |
677 | @@ -21,7 +21,7 @@ |
678 | import imaplib |
679 | import time |
680 | from email import email |
681 | -from config import IMAP_SERVER, IMAP_USERNAME, IMAP_PASSWORD |
682 | +from config import schema |
683 | |
684 | def get_confirmation_code_for_address(email_address): |
685 | email_msg = get_latest_email_sent_to(email_address) |
686 | @@ -40,17 +40,27 @@ |
687 | raise AssertionError("No verification link found in email.") |
688 | return vcode |
689 | |
690 | + |
691 | def get_latest_email_sent_to(email_address): |
692 | - with MailBox(IMAP_USERNAME, IMAP_PASSWORD) as mbox: |
693 | + with MailBox() as mbox: |
694 | email_msg = mbox.get_latest_email_sent_to(email_address) |
695 | mbox.delete_msgs_sent_to(email_address) |
696 | return email_msg |
697 | - |
698 | + |
699 | + |
700 | class MailBox(object): |
701 | - def __init__(self, user, password): |
702 | - self.user = user |
703 | - self.password = password |
704 | - self.imap = imaplib.IMAP4_SSL(IMAP_SERVER, 993) |
705 | + |
706 | + def __init__(self): |
707 | + config_values = schema.glue.schema_parser.values('NewUser') |
708 | + self.user = config_values.get('imap_username') |
709 | + self.password = config_values.get('imap_password') |
710 | + imap_server = config_values.get('imap_server') |
711 | + imap_port = config_values.get('imap_port') |
712 | + imap_use_ssl = config_values.get('imap_use_ssl') |
713 | + if imap_use_ssl: |
714 | + self.imap = imaplib.IMAP4_SSL(imap_server, imap_port) |
715 | + else: |
716 | + self.imap = imaplib.IMAP4(imap_server, imap_port) |
717 | |
718 | def __enter__(self): |
719 | self.imap.login(self.user, self.password) |
looks good. ran tests with local config.