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

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
Reviewer Review Type Date Requested Status
Corey Goldberg (community) Approve
Vincent Ladeuil (community) Approve
Review via email: mp+119065@code.launchpad.net

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/ubuntuone-testing/ubuntuone/web/tests/sst/ u1webs10_login
sst-run -d /path/to/ubuntuone-testing/ubuntuone/web/tests/sst/ u1weba8_createaccount

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) :
review: Approve
Revision history for this message
Corey Goldberg (coreygoldberg) wrote :

looks good. ran tests with local config.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2012-06-19 20:26:48 +0000
+++ .bzrignore 2012-08-10 00:06:19 +0000
@@ -6,12 +6,7 @@
6*.pyc6*.pyc
7ubuntuone_testing_log7ubuntuone_testing_log
8testdata/*.file8testdata/*.file
9passwords.py
10reports/*9reports/*
11_passwords.py
12_musicpasswords.py
13_localconfig.py
14sourcecode10sourcecode
15results11results
16_devserver.py12local.cfg
17_photopasswords.py
18\ No newline at end of file13\ No newline at end of file
1914
=== modified file 'ubuntuone/web/tests/sst/account/u1weba001_accountdetails.py'
--- ubuntuone/web/tests/sst/account/u1weba001_accountdetails.py 2012-06-26 16:39:03 +0000
+++ ubuntuone/web/tests/sst/account/u1weba001_accountdetails.py 2012-08-10 00:06:19 +0000
@@ -23,15 +23,11 @@
23import actions.setup as setup_actions23import actions.setup as setup_actions
24import actions.account as account_actions24import actions.account as account_actions
25from _passwords import full_name, email25from _passwords import full_name, email
26from config import ENVIRONMENT26from config import environment
2727
28setup_actions.setup()28setup_actions.setup()
29account_actions.open()29account_actions.open()
30account_actions.assert_account_details(full_name, email)30account_actions.assert_account_details(full_name, email)
31account_actions.click_edit_account_details()31account_actions.click_edit_account_details()
32url = None32sso_url = environment.get_environment().sso_url
33if ENVIRONMENT == 'staging':33assert_url(sso_url)
34 url = 'https://login.staging.ubuntu.com/'
35else:
36 url = 'https://login.ubuntu.com/'
37assert_url(url)
3834
=== added file 'ubuntuone/web/tests/sst/account/u1weba8_createaccount.py'
--- ubuntuone/web/tests/sst/account/u1weba8_createaccount.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/account/u1weba8_createaccount.py 2012-08-10 00:06:19 +0000
@@ -0,0 +1,26 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2012 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
17from sst.actions import *
18import actions.setup as setup_actions
19import actions.dashboard as dashboard_actions
20import actions.header as header_actions
21
22setup_actions.setup(new_user=True)
23user = setup_actions.get_user()
24dashboard_actions.assert_page_title()
25header_actions.assert_login(user.full_name)
26dashboard_actions.assert_welcome_message(user.full_name)
027
=== modified file 'ubuntuone/web/tests/sst/payments/u1webp001_paymusicstreaming.py'
--- ubuntuone/web/tests/sst/payments/u1webp001_paymusicstreaming.py 2012-06-25 13:59:33 +0000
+++ ubuntuone/web/tests/sst/payments/u1webp001_paymusicstreaming.py 2012-08-10 00:06:19 +0000
@@ -21,7 +21,7 @@
21"""Pay for the music streaming service."""21"""Pay for the music streaming service."""
2222
23from sst.actions import *23from sst.actions import *
24from config import ENVIRONMENT24from config import environment
25from datetime import date25from datetime import date
26import actions.setup as setup_actions26import actions.setup as setup_actions
27import actions.services as services_actions27import actions.services as services_actions
@@ -29,8 +29,8 @@
29import actions.payment_confirmed as payment_confirmed_actions29import actions.payment_confirmed as payment_confirmed_actions
3030
31skip('This test must be updated for Ubuntu Pay.')31skip('This test must be updated for Ubuntu Pay.')
32if ENVIRONMENT == 'production':32if not environment.can_make_payments():
33 skip('Can\'t test payments on production.')33 skip('Can\'t test payments on this environment.')
34setup_actions.setup(new_user=True)34setup_actions.setup(new_user=True)
35services_actions.open()35services_actions.open()
36services_actions.buy_music_streaming_yearly()36services_actions.buy_music_streaming_yearly()
3737
=== modified file 'ubuntuone/web/tests/sst/payments/u1webp002_payadditionalstorage.py'
--- ubuntuone/web/tests/sst/payments/u1webp002_payadditionalstorage.py 2012-06-25 13:59:33 +0000
+++ ubuntuone/web/tests/sst/payments/u1webp002_payadditionalstorage.py 2012-08-10 00:06:19 +0000
@@ -1,5 +1,4 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2
3# Authors: 2# Authors:
4# Rick McBride <rick.mcbride@canonical.com>3# Rick McBride <rick.mcbride@canonical.com>
5# Leo Arias <leo.arias@canonical.com>4# Leo Arias <leo.arias@canonical.com>
@@ -21,7 +20,7 @@
21"""Pay for the additional sotrage service."""20"""Pay for the additional sotrage service."""
2221
23from sst.actions import *22from sst.actions import *
24from config import ENVIRONMENT23from config import environment
25import actions.setup as setup_actions24import actions.setup as setup_actions
26import actions.services as services_actions25import actions.services as services_actions
27import actions.payment as payment_actions26import actions.payment as payment_actions
2827
=== modified file 'ubuntuone/web/tests/sst/payments/u1webp003_paywithrefusedcard.py'
--- ubuntuone/web/tests/sst/payments/u1webp003_paywithrefusedcard.py 2012-06-25 13:59:33 +0000
+++ ubuntuone/web/tests/sst/payments/u1webp003_paywithrefusedcard.py 2012-08-10 00:06:19 +0000
@@ -21,15 +21,15 @@
21"""Pay for a service with a refused card."""21"""Pay for a service with a refused card."""
2222
23from sst.actions import *23from sst.actions import *
24from config import ENVIRONMENT24from config import environment
25import actions.setup as setup_actions25import actions.setup as setup_actions
26import actions.services as services_actions26import actions.services as services_actions
27import actions.payment as payment_actions27import actions.payment as payment_actions
28import actions.payment_confirmed as payment_confirmed_actions28import actions.payment_confirmed as payment_confirmed_actions
2929
30skip('This test must be updated for Ubuntu Pay.')30skip('This test must be updated for Ubuntu Pay.')
31if ENVIRONMENT == 'production':31if not environment.can_make_payments():
32 skip('Can\'t test payments on production.')32 skip('Can\'t test payments on this environment.')
33setup_actions.setup()33setup_actions.setup()
34services_actions.open()34services_actions.open()
35services_actions.buy_music_streaming()35services_actions.buy_music_streaming()
3636
=== renamed file 'ubuntuone/web/tests/sst/session/u1webs002_login.py' => 'ubuntuone/web/tests/sst/session/u1webs10_login.py'
--- ubuntuone/web/tests/sst/session/u1webs002_login.py 2012-03-27 19:04:46 +0000
+++ ubuntuone/web/tests/sst/session/u1webs10_login.py 2012-08-10 00:06:19 +0000
@@ -1,6 +1,6 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22
3# Copyright 2011 Canonical Ltd.3# Copyright 2011, 2012 Canonical Ltd.
4#4#
5# This program is free software: you can redistribute it and/or modify it5# 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 published6# under the terms of the GNU General Public License version 3, as published
@@ -14,18 +14,13 @@
14# You should have received a copy of the GNU General Public License along14# 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/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17"""Test case u1webs-002 Log in.
18Log in to the website with an existing account.
19
20"""
21
22from sst.actions import *17from sst.actions import *
23import actions.setup as setup_actions18import actions.setup as setup_actions
24import actions.dashboard as dashboard_actions19import actions.dashboard as dashboard_actions
25import actions.header as header_actions20import actions.header as header_actions
26from _passwords import full_name
2721
28setup_actions.setup(new_user=False)22setup_actions.setup(new_user=False)
23user = setup_actions.get_user()
29dashboard_actions.assert_page_title()24dashboard_actions.assert_page_title()
30header_actions.assert_login(full_name)25header_actions.assert_login(user.full_name)
31dashboard_actions.assert_welcome_message(full_name)26dashboard_actions.assert_welcome_message(user.full_name)
3227
=== modified file 'ubuntuone/web/tests/sst/shared/actions/dashboard.py'
--- ubuntuone/web/tests/sst/shared/actions/dashboard.py 2012-02-02 01:23:26 +0000
+++ ubuntuone/web/tests/sst/shared/actions/dashboard.py 2012-08-10 00:06:19 +0000
@@ -1,6 +1,6 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22
3# Copyright 2011 Canonical Ltd.3# Copyright 2011, 2012 Canonical Ltd.
4#4#
5# This program is free software: you can redistribute it and/or modify it5# 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 published6# under the terms of the GNU General Public License version 3, as published
@@ -24,17 +24,23 @@
24 click_link(_get_dashboard_link())24 click_link(_get_dashboard_link())
25 assert_page_title(), 'Dashboard should be opened'25 assert_page_title(), 'Dashboard should be opened'
2626
27
27def _get_dashboard_link():28def _get_dashboard_link():
28 return get_element_by_css('#main-nav .dashboard')29 return get_element_by_css('#main-nav .dashboard')
2930
31
30def assert_page_title():32def assert_page_title():
31 assert_title(PAGE_TITLE)33 assert_title(PAGE_TITLE)
3234
35
33def wait_for_page_to_load():36def wait_for_page_to_load():
34 wait_for(assert_title, PAGE_TITLE)37 wait_for(assert_title, PAGE_TITLE)
3538
39
36def assert_welcome_message(user_full_name):40def assert_welcome_message(user_full_name):
37 assert_text(_get_welcome_element(), 'Hi %s! Welcome Back' % user_full_name)41 assert_text(_get_welcome_element(),
42 'Hi %s! Welcome Back' % user_full_name[:40])
43
38 44
39def _get_welcome_element():45def _get_welcome_element():
40 return get_element_by_css('h1')46 return get_element_by_css('h1')
4147
=== modified file 'ubuntuone/web/tests/sst/shared/actions/files.py'
--- ubuntuone/web/tests/sst/shared/actions/files.py 2012-07-15 02:04:04 +0000
+++ ubuntuone/web/tests/sst/shared/actions/files.py 2012-08-10 00:06:19 +0000
@@ -19,7 +19,7 @@
19from sst.actions import *19from sst.actions import *
20from sst.actions import _get_elem20from sst.actions import _get_elem
21from loading import *21from loading import *
22from config import *22from config import environment
23import urlparse23import urlparse
2424
2525
@@ -229,13 +229,7 @@
229 identifier -- The identifier of the file.229 identifier -- The identifier of the file.
230230
231 """231 """
232 files_url = None232 files_url = environment.get_environment().files_url
233 if ENVIRONMENT == 'staging':
234 files_url = 'https://files.staging.one.ubuntu.com/'
235 elif ENVIRONMENT == 'edge':
236 files_url = 'https://files.edge.one.ubuntu.com/'
237 elif ENVIRONMENT == 'production':
238 files_url = 'https://files.one.ubuntu.com/'
239 file_url = files_url + str(identifier[3:])233 file_url = files_url + str(identifier[3:])
240 return get_element(css_class='download-button', href=file_url)234 return get_element(css_class='download-button', href=file_url)
241235
242236
=== modified file 'ubuntuone/web/tests/sst/shared/actions/setup.py'
--- ubuntuone/web/tests/sst/shared/actions/setup.py 2012-07-15 05:27:44 +0000
+++ ubuntuone/web/tests/sst/shared/actions/setup.py 2012-08-10 00:06:19 +0000
@@ -17,27 +17,27 @@
17"""Set up actions for Ubuntu One sst tests."""17"""Set up actions for Ubuntu One sst tests."""
1818
19from sst.actions import *19from sst.actions import *
20from config import *20from config import schema
21from config import environment
21from data.user import User22from data.user import User
23from data.environment import Environment
22import actions.header as header_actions24import actions.header as header_actions
23import actions.sso as sso_actions25import actions.sso as sso_actions
24import actions.services as services_actions26import actions.services as services_actions
25import actions.dashboard as dashboard_actions27import actions.dashboard as dashboard_actions
26import uuid28import uuid
27from utils import mail29from utils import mail
28try:
29 from _passwords import full_name, email, password
30except:
31 skip('Try adding a _passwords.py file to the shared folder if you ' \
32 'expect this to work. Read the README.txt file ;)')
3330
31# The user account for the test.
32user = None
3433
35def setup(login_or_sign_up=True, new_user=False, user=None):34def setup(login_or_sign_up=True, new_user=False, user=None):
36 set_wait_timeout(DEFAULT_TIMEOUT)35 config_values = schema.glue.schema_parser.values('__main__')
36 set_wait_timeout(config_values.get('default_timeout'))
37 _go_to_ubuntu_one_home()37 _go_to_ubuntu_one_home()
38 _clear_previous_session()38 _clear_previous_session()
39 if login_or_sign_up:39 if login_or_sign_up:
40 _get_user_and_login_or_sign_up(new_user, user)40 _make_user_and_login_or_sign_up(new_user, user)
4141
4242
43def _go_to_ubuntu_one_home():43def _go_to_ubuntu_one_home():
@@ -47,21 +47,7 @@
4747
4848
49def get_base_url():49def get_base_url():
50 base_url = None50 return environment.get_environment().url
51 if ENVIRONMENT == 'staging':
52 base_url = 'https://staging.one.ubuntu.com'
53 elif ENVIRONMENT == 'edge':
54 base_url = 'https://edge.one.ubuntu.com'
55 elif ENVIRONMENT == 'production':
56 base_url = 'https://one.ubuntu.com'
57 elif ENVIRONMENT == 'development':
58 if address:
59 base_url = address
60 else:
61 skip('development target specified, but address not set.')
62 else:
63 skip('Unknown environment: %s.' % ENVIRONMENT)
64 return base_url
6551
6652
67def _clear_previous_session():53def _clear_previous_session():
@@ -76,23 +62,52 @@
76 _go_to_ubuntu_one_home()62 _go_to_ubuntu_one_home()
7763
7864
79def _get_user_and_login_or_sign_up(new_user, user):65def _make_user_and_login_or_sign_up(new_user, user):
80 if user is None:66 if user is None:
81 user = _get_user(new_user)67 user = _make_user(new_user)
68 _set_user(user)
82 _login_or_sign_up(new_user, user)69 _login_or_sign_up(new_user, user)
83 dashboard_actions.wait_for_page_to_load()70 dashboard_actions.wait_for_page_to_load()
84 header_actions.assert_login(user.full_name)71 header_actions.assert_login(user.full_name)
8572
8673
87def _get_user(new_user):74def _make_user(new_user):
88 test_user = None75 test_user = None
89 if new_user:76 if new_user:
90 test_user = _get_random_user()77 test_user = _make_random_user()
91 else:78 else:
92 test_user = _get_user_from_configuration()79 test_user = _make_user_from_configuration()
93 return test_user80 return test_user
9481
9582
83def _make_random_user():
84 random_user_uuid = str(uuid.uuid1())
85 config_values = schema.glue.schema_parser.values('NewUser')
86 full_name_pattern = config_values.get('full_name_pattern')
87 email_address_pattern = config_values.get('email_address_pattern')
88 random_full_name = full_name_pattern % random_user_uuid
89 random_email_address = email_address_pattern % random_user_uuid
90 password = config_values.get('password')
91 return User(random_full_name, random_email_address, password)
92
93
94def _make_user_from_configuration():
95 config_values = schema.glue.schema_parser.values('DefaultUser')
96 full_name = config_values.get('full_name')
97 email_address = config_values.get('email_address')
98 password = config_values.get('password')
99 return User(full_name, email_address, password)
100
101
102def _set_user(user_data):
103 global user
104 user = user_data
105
106
107def get_user():
108 return user
109
110
96def _login_or_sign_up(new_user, user):111def _login_or_sign_up(new_user, user):
97 if new_user:112 if new_user:
98 _sign_up(user)113 _sign_up(user)
@@ -100,26 +115,15 @@
100 _login(user)115 _login(user)
101116
102117
103def _get_user_from_configuration():
104 return User(full_name, email, password)
105
106
107def _get_random_user():
108 random_user_uuid = str(uuid.uuid1())
109 random_user_name = 'Test user ' + random_user_uuid
110 random_user_email = random_user_uuid + '@' + IMAP_SERVER
111 random_user_password = 'Hola123*'
112 return User(random_user_name, random_user_email, random_user_password)
113
114118
115def _sign_up(user):119def _sign_up(user):
116 if ENVIRONMENT == 'production':120 if environment.can_create_new_users():
117 skip('Can\'t create new users on production.')
118 else:
119 header_actions.click_login_or_sign_up()121 header_actions.click_login_or_sign_up()
120 sso_actions.create_new_account(user)122 sso_actions.create_new_account(user)
121 _confirm_email(user.email)123 _confirm_email(user.email)
122 services_actions.agree_and_subscribe_to_free_plan()124 services_actions.agree_and_subscribe_to_free_plan()
125 else:
126 skip('Can\'t create new users on this environment.')
123127
124128
125def _confirm_email(email):129def _confirm_email(email):
@@ -130,7 +134,7 @@
130134
131def _login(user):135def _login(user):
132 header_actions.click_login_or_sign_up()136 header_actions.click_login_or_sign_up()
133 if ENVIRONMENT == 'development':137 if environment.is_development_environment():
134 wait_for(assert_title, 'Ubuntu One :')138 wait_for(assert_title, 'Ubuntu One :')
135 switch_to_window()139 switch_to_window()
136 click_button(get_elements('button.cta[type="submit"]')[0], wait=False)140 click_button(get_elements('button.cta[type="submit"]')[0], wait=False)
137141
=== added directory 'ubuntuone/web/tests/sst/shared/config'
=== removed file 'ubuntuone/web/tests/sst/shared/config.py'
--- ubuntuone/web/tests/sst/shared/config.py 2012-06-04 21:23:42 +0000
+++ ubuntuone/web/tests/sst/shared/config.py 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2011-2012 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# Waiting actions will wait for this amount of seconds, unless a different
18# timeout is set calling the SST action set_wait_timeout.
19DEFAULT_TIMEOUT = 40
20
21# set below according to need (staging v production v edge v development
22# test instance)
23ENVIRONMENT = 'staging'
24#ENVIRONMENT = 'edge'
25#ENVIRONMENT = 'production'
26#ENVIRONMENT = 'development'
27
28# Email inbox data
29IMAP_SERVER = 'mail.canonical.com'
30IMAP_USERNAME = 'u1test'
31IMAP_PASSWORD = 'password'
32
33# You can overwrite the default configuration setting the variables on
34# the file shared/_local_config.py.
35try:
36 from _localconfig import *
37except ImportError:
38 pass
390
=== added file 'ubuntuone/web/tests/sst/shared/config/__init__.py'
=== added file 'ubuntuone/web/tests/sst/shared/config/environment.py'
--- ubuntuone/web/tests/sst/shared/config/environment.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/shared/config/environment.py 2012-08-10 00:06:19 +0000
@@ -0,0 +1,49 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2012 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
17from config import schema
18from data.environment import Environment
19
20environment_data = None
21
22def get_environment():
23 global environment_data
24 if not environment_data:
25 config_values = schema.glue.schema_parser.values('Server')
26 name = config_values.get('environment')
27 url = config_values.get('url')
28 sso_url = config_values.get('sso_url')
29 files_url = config_values.get('files_url')
30 environment_data = Environment(name, url, sso_url, files_url)
31 return environment_data
32
33
34def is_staging_environment():
35 return get_environment().name == 'staging'
36
37
38def is_development_environment():
39 return get_environment().name == 'production'
40
41
42def can_create_new_users():
43 return is_staging_environment()
44
45
46def can_make_payments():
47 return is_staging_environment()
48
49
050
=== added file 'ubuntuone/web/tests/sst/shared/config/sample.cfg'
--- ubuntuone/web/tests/sst/shared/config/sample.cfg 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/shared/config/sample.cfg 2012-08-10 00:06:19 +0000
@@ -0,0 +1,25 @@
1[__main__]
2default_timeout: 40
3
4[Server]
5environment: staging
6
7[DefaultUser]
8full_name: Test user
9email_address: test@example.com
10password: Hola123*
11
12[NewUser]
13full_name_pattern: Test user %s
14email_address_pattern: test+%s@example.com
15password: Hola123*
16imap_server: mail.example.com
17imap_port: 993
18imap_use_ssl: True
19imap_username: test
20imap_password: Hola123*
21
22[MusicUser]
23full_name: Test user
24email_address: test@example.com
25password: Hola123*
0\ No newline at end of file26\ No newline at end of file
127
=== added file 'ubuntuone/web/tests/sst/shared/config/schema.py'
--- ubuntuone/web/tests/sst/shared/config/schema.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/shared/config/schema.py 2012-08-10 00:06:19 +0000
@@ -0,0 +1,61 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2012 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
17from configglue import schema
18from configglue.glue import configglue
19import sys
20import os.path
21
22class SstSchema(schema.Schema):
23
24 default_timeout = schema.IntOption(default=40)
25
26 class Server(schema.Section):
27 environment = schema.StringOption(default='staging')
28 url = schema.StringOption(default=None)
29 sso_url = schema.StringOption(default=None)
30 files_url = schema.StringOption(default=None)
31
32
33 class DefaultUser(schema.Section):
34 full_name = schema.StringOption()
35 email_address = schema.StringOption()
36 password = schema.StringOption()
37
38
39 class NewUser(schema.Section):
40 full_name_pattern = schema.StringOption(default='Test user %s',
41 raw=True)
42 email_address_pattern = schema.StringOption(raw=True)
43 password = schema.StringOption(default='Hola123*')
44 imap_server = schema.StringOption()
45 imap_port = schema.IntOption(default=993)
46 imap_use_ssl = schema.BoolOption(default=True)
47 imap_username = schema.StringOption()
48 imap_password = schema.StringOption()
49
50
51 class MusicUser(schema.Section):
52 full_name = schema.StringOption()
53 email_address = schema.StringOption()
54 password = schema.StringOption()
55
56# XXX The command line arguments are for SST, not for u1 tests.
57# We will do something to SST on the future so it uses configglue,
58# or makes available all the additional arguments.
59sys.argv = []
60current_dir = os.path.dirname(os.path.abspath(__file__))
61glue = configglue(SstSchema, os.path.join(current_dir, 'local.cfg'))
062
=== added file 'ubuntuone/web/tests/sst/shared/data/environment.py'
--- ubuntuone/web/tests/sst/shared/data/environment.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/shared/data/environment.py 2012-08-10 00:06:19 +0000
@@ -0,0 +1,44 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2012 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
17base_urls = {'staging': 'https://staging.one.ubuntu.com',
18 'edge': 'https://edge.one.ubuntu.com',
19 'production': 'https://one.ubuntu.com'}
20sso_urls = {'staging': 'https://loging.staging.ubuntu.com',
21 'edge': 'https://loging.ubuntu.com',
22 'production': 'https://loging.ubuntu.com'}
23files_urls = {'staging': 'https://staging.one.ubuntu.com',
24 'edge': 'https://edge.one.ubuntu.com',
25 'production': 'https://one.ubuntu.com'}
26
27class Environment:
28
29 def __init__(self, name, url, sso_url, files_url):
30 self.name = name
31 if url:
32 self.url = url
33 else:
34 self.url = base_urls[name]
35 if sso_url:
36 self.sso_url = sso_url
37 else:
38 self.sso_url = sso_urls[name]
39 if files_url:
40 self.files_url = files_url
41 else:
42 self.files_url = files_urls[name]
43
44
045
=== removed file 'ubuntuone/web/tests/sst/shared/edge_config.py'
--- ubuntuone/web/tests/sst/shared/edge_config.py 2011-09-29 17:53:44 +0000
+++ ubuntuone/web/tests/sst/shared/edge_config.py 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1# set below according to need (staging v production v test instance)
2base_url = 'https://edge.one.ubuntu.com/'
30
=== removed file 'ubuntuone/web/tests/sst/shared/prod_config.py'
--- ubuntuone/web/tests/sst/shared/prod_config.py 2011-09-29 17:53:44 +0000
+++ ubuntuone/web/tests/sst/shared/prod_config.py 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1# set below according to need (staging v production v test instance)
2base_url = 'https://one.ubuntu.com/'
30
=== removed file 'ubuntuone/web/tests/sst/shared/stag_config.py'
--- ubuntuone/web/tests/sst/shared/stag_config.py 2011-09-29 17:53:44 +0000
+++ ubuntuone/web/tests/sst/shared/stag_config.py 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1# set below according to need (staging v production v test instance)
2base_url = 'https://staging.one.ubuntu.com/'
30
=== modified file 'ubuntuone/web/tests/sst/shared/utils/mail.py'
--- ubuntuone/web/tests/sst/shared/utils/mail.py 2012-03-19 19:20:22 +0000
+++ ubuntuone/web/tests/sst/shared/utils/mail.py 2012-08-10 00:06:19 +0000
@@ -1,6 +1,6 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22
3# Copyright 2011 Canonical Ltd.3# Copyright 2011, 2012 Canonical Ltd.
4#4#
5# This program is free software: you can redistribute it and/or modify it5# 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 published6# under the terms of the GNU General Public License version 3, as published
@@ -21,7 +21,7 @@
21import imaplib21import imaplib
22import time22import time
23from email import email23from email import email
24from config import IMAP_SERVER, IMAP_USERNAME, IMAP_PASSWORD24from config import schema
2525
26def get_confirmation_code_for_address(email_address):26def get_confirmation_code_for_address(email_address):
27 email_msg = get_latest_email_sent_to(email_address)27 email_msg = get_latest_email_sent_to(email_address)
@@ -40,17 +40,27 @@
40 raise AssertionError("No verification link found in email.")40 raise AssertionError("No verification link found in email.")
41 return vcode41 return vcode
4242
43
43def get_latest_email_sent_to(email_address):44def get_latest_email_sent_to(email_address):
44 with MailBox(IMAP_USERNAME, IMAP_PASSWORD) as mbox:45 with MailBox() as mbox:
45 email_msg = mbox.get_latest_email_sent_to(email_address)46 email_msg = mbox.get_latest_email_sent_to(email_address)
46 mbox.delete_msgs_sent_to(email_address)47 mbox.delete_msgs_sent_to(email_address)
47 return email_msg48 return email_msg
48 49
50
49class MailBox(object):51class MailBox(object):
50 def __init__(self, user, password):52
51 self.user = user53 def __init__(self):
52 self.password = password54 config_values = schema.glue.schema_parser.values('NewUser')
53 self.imap = imaplib.IMAP4_SSL(IMAP_SERVER, 993)55 self.user = config_values.get('imap_username')
56 self.password = config_values.get('imap_password')
57 imap_server = config_values.get('imap_server')
58 imap_port = config_values.get('imap_port')
59 imap_use_ssl = config_values.get('imap_use_ssl')
60 if imap_use_ssl:
61 self.imap = imaplib.IMAP4_SSL(imap_server, imap_port)
62 else:
63 self.imap = imaplib.IMAP4(imap_server, imap_port)
5464
55 def __enter__(self):65 def __enter__(self):
56 self.imap.login(self.user, self.password)66 self.imap.login(self.user, self.password)

Subscribers

People subscribed via source and target branches