Merge lp:~elopio/u1-test-utils/pay-client2 into lp:u1-test-utils
- pay-client2
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Leo Arias |
Approved revision: | 46 |
Merged at revision: | 39 |
Proposed branch: | lp:~elopio/u1-test-utils/pay-client2 |
Merge into: | lp:u1-test-utils |
Diff against target: |
587 lines (+361/-43) 15 files modified
fabtasks/development.py (+1/-2) requirements.txt (+2/-1) u1testutils/pay/client.py (+96/-0) u1testutils/pay/data.py (+71/-0) u1testutils/pay/environment.py (+20/-0) u1testutils/pay/selftests/unit/test_pay_api_client.py (+81/-0) u1testutils/selftests/django_project/settings.py (+4/-0) u1testutils/sst/__init__.py (+56/-0) u1testutils/sst/config.py (+10/-3) u1testutils/sst/sso/__init__.py (+0/-2) u1testutils/sst/sso/client.py (+1/-2) u1testutils/sst/sso/data.py (+9/-0) u1testutils/sst/sso/environment.py (+0/-2) u1testutils/sst/sso/pages.py (+10/-29) u1testutils/sst/sso/selftests/unit/test_client.py (+0/-2) |
To merge this branch: | bzr merge lp:~elopio/u1-test-utils/pay-client2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matias Bordese (community) | Approve | ||
Review via email: mp+155401@code.launchpad.net |
Commit message
Added helpers for the Pay API client.
Description of the change
Leo Arias (elopio) wrote : | # |
<matiasb> elopio: did you change anything in u1testutils/
<elopio> matiasb: ahh, crap. Yes, I thought I had reverted it. thanks for pointing it out.
<elopio> matiasb: fixed.
<matiasb> elopio: ack, thanks; taking a look
<elopio> matiasb: there were a couple of lint errors. I pushed the fixes.
<matiasb> elopio: ack, one question, btw: why are you removing the encoding notice from some files?
<elopio> matiasb: that's something I read on one of the peps. It said that we should use the default encoding unless one of the authors had weird characters in the name. Let me find it.
<nessita> elopio, have a link to that? I would expect always use explicitely the encoding definition
<elopio> nessita: I'm looking.
<nessita> elopio, nice!
<elopio> nessita, matiasb: huh, here it is: http://
<elopio> "Files using ASCII should not have a coding cookie. Latin-1 (or UTF-8) should only be used when a comment or docstring needs to mention an author name that requires Latin-1"
<nessita> elopio, where is that?
<nessita> elopio, sorry, got the link
<elopio> That's for the core distribution, but it says: Open source projects with a global audience are encouraged to adopt a similar policy.
<nessita> elopio, I see. I personally disagree, but I'm happy to apply it to be consistent with the pep
<elopio> nessita: it just encourages us, so I wouldn't mind if we go other way. But now the default is UTF-8, so I think soon it won't matter, right?
<nessita> elopio, the default is for python 3 (and maybe 2.7(
<nessita> ))
<elopio> nessita: so, should I keep the UTF 8 on all files?
<matiasb> elopio, nessita: so, we are ok by removing this? if not, I guess we should agree on adding the notice consistently
<nessita> elopio, I personally would not remove, instead just not add if not needed. But I do not have a strong opinion on this :-)
<elopio> I'm fine with whatever leads to consistency :)
<elopio> what about an executive team lead decission from pindonga?
<matiasb> I'm ok removing it, if we are not explicitly using weird chars, and if we don't have this anywhere else
<matiasb> nessita: you are ok with that? ^
<nessita> yes!
<matiasb> ack
<matiasb> elopio: +1 then
Preview Diff
1 | === modified file 'fabtasks/development.py' |
2 | --- fabtasks/development.py 2013-01-21 03:18:56 +0000 |
3 | +++ fabtasks/development.py 2013-03-26 15:13:23 +0000 |
4 | @@ -1,5 +1,3 @@ |
5 | -# -*- coding: utf-8 -*- |
6 | - |
7 | # Copyright 2012, 2013 Canonical Ltd. |
8 | # |
9 | # This program is free software: you can redistribute it and/or modify it |
10 | @@ -42,6 +40,7 @@ |
11 | if 'unit' in suites: |
12 | module_paths.append('u1testutils/selftests/unit') |
13 | module_paths.append('u1testutils/sst/sso/selftests/unit') |
14 | + module_paths.append('u1testutils/pay/selftests/unit') |
15 | for mp in module_paths: |
16 | suite.addTest(unittest.TestLoader().discover(mp)) |
17 | # List the tests as we run them |
18 | |
19 | === modified file 'requirements.txt' |
20 | --- requirements.txt 2013-02-27 23:19:39 +0000 |
21 | +++ requirements.txt 2013-03-26 15:13:23 +0000 |
22 | @@ -3,7 +3,8 @@ |
23 | mock |
24 | pep8 |
25 | pyflakes |
26 | -sst |
27 | Twisted |
28 | bzr+ssh://bazaar.launchpad.net/~bloodearnest/localmail/trunk |
29 | +bzr+http://bazaar.launchpad.net/~ubuntuone-hackers/payclient/trunk@1 |
30 | +bzr+http://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk@367 |
31 | bzr+http://bazaar.launchpad.net/~canonical-isd-hackers/canonical-identity-provider/ssoclient@3 |
32 | |
33 | === added directory 'u1testutils/pay' |
34 | === added file 'u1testutils/pay/__init__.py' |
35 | === added file 'u1testutils/pay/client.py' |
36 | --- u1testutils/pay/client.py 1970-01-01 00:00:00 +0000 |
37 | +++ u1testutils/pay/client.py 2013-03-26 15:13:23 +0000 |
38 | @@ -0,0 +1,96 @@ |
39 | +# Copyright 2013 Canonical Ltd. |
40 | +# |
41 | +# This program is free software: you can redistribute it and/or modify it |
42 | +# under the terms of the GNU Lesser General Public License version 3, as |
43 | +# published by the Free Software Foundation. |
44 | +# |
45 | +# This program is distributed in the hope that it will be useful, but |
46 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
47 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
48 | +# PURPOSE. See the GNU Lesser General Public License for more details. |
49 | +# |
50 | +# You should have received a copy of the GNU General Public License along |
51 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
52 | + |
53 | +import payclient |
54 | +from django.conf import settings |
55 | +from piston_mini_client import auth, failhandlers |
56 | + |
57 | +import u1testutils.pay.environment |
58 | + |
59 | + |
60 | +def get_pay_client(pay_server_url=None): |
61 | + """Return the Payment Service API client. |
62 | + |
63 | + pay_server_url -- The URL of the Pay server that provides the API. Default |
64 | + is None, which means that the URL will be taken from value of the |
65 | + Django settings PAY_SERVER_URL option. |
66 | + |
67 | + """ |
68 | + user = settings.PAY_API_USERNAME |
69 | + password = settings.PAY_API_PASSWORD |
70 | + basic_auth = auth.BasicAuthorizer(user, password) |
71 | + pay_server_url = _get_pay_server_url(pay_server_url) |
72 | + pay_api_url = '{0}/api/2.0/'.format(pay_server_url) |
73 | + return payclient.PaymentServiceAPI( |
74 | + auth=basic_auth, service_root=pay_api_url) |
75 | + |
76 | + |
77 | +def _get_pay_server_url(pay_server_url=None): |
78 | + if pay_server_url is None: |
79 | + pay_server_url = \ |
80 | + u1testutils.pay.environment.get_pay_base_url() |
81 | + else: |
82 | + pay_server_url = pay_server_url.rstrip('/') |
83 | + return pay_server_url |
84 | + |
85 | + |
86 | +def add_new_credit_card(shop_id, user, credit_card, billing_address, |
87 | + pay_server_url=None): |
88 | + """Add a new credit card through the Pay API. |
89 | + |
90 | + Keyword arguments: |
91 | + shop_id -- The identifier of the shop that will add the credit card. |
92 | + user -- The user that will have the new credit card. It must have the |
93 | + openid attribute. |
94 | + credit_card -- The credit card information. It must have the attributes |
95 | + card_type, name_on_cad, card_number, ccv_number, expiration_month and |
96 | + expiration_year. |
97 | + billing_address -- The billing address for the card. It must have the |
98 | + attributes street_line1, state, country and postal_code. The country |
99 | + is the name of the country in english. |
100 | + pay_server_url -- The URL of the Pay server that provides the API. Default |
101 | + is None. |
102 | + |
103 | + """ |
104 | + billing_address_dict = { |
105 | + 'street': billing_address.street_line1, |
106 | + 'state': billing_address.state, |
107 | + 'country': _get_country_code(billing_address.country), |
108 | + 'postal': billing_address.postal_code |
109 | + } |
110 | + kwargs = dict( |
111 | + shop_id=shop_id, |
112 | + open_id=user.openid, |
113 | + card_type=credit_card.card_type, |
114 | + card_holder=credit_card.name_on_card, |
115 | + card_number=credit_card.card_number, |
116 | + card_ccv=credit_card.ccv_number, |
117 | + card_expiration_month=credit_card.expiration_month, |
118 | + card_expiration_year=credit_card.expiration_year, |
119 | + billing_address=billing_address_dict |
120 | + ) |
121 | + credit_card_request = payclient.CreditCardRequest(**kwargs) |
122 | + pay_client = get_pay_client(pay_server_url) |
123 | + try: |
124 | + response = pay_client.new_credit_card(data=credit_card_request) |
125 | + return isinstance(response, payclient.CreditCardResponse) |
126 | + except failhandlers.APIError: |
127 | + # TODO log the error. |
128 | + return False |
129 | + |
130 | + |
131 | +def _get_country_code(country_name): |
132 | + # TODO add more? |
133 | + country_data = {'United States': 'US'} |
134 | + return country_data.get(country_name) |
135 | |
136 | === added file 'u1testutils/pay/data.py' |
137 | --- u1testutils/pay/data.py 1970-01-01 00:00:00 +0000 |
138 | +++ u1testutils/pay/data.py 2013-03-26 15:13:23 +0000 |
139 | @@ -0,0 +1,71 @@ |
140 | +# Copyright 2013 Canonical Ltd. |
141 | +# |
142 | +# This program is free software: you can redistribute it and/or modify it |
143 | +# under the terms of the GNU Lesser General Public License version 3, as |
144 | +# published by the Free Software Foundation. |
145 | +# |
146 | +# This program is distributed in the hope that it will be useful, but |
147 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
148 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
149 | +# PURPOSE. See the GNU Lesser General Public License for more details. |
150 | +# |
151 | +# You should have received a copy of the GNU General Public License along |
152 | +# with this program. If not, see <http://www.gnu.org/licenses/ |
153 | + |
154 | +import uuid |
155 | + |
156 | + |
157 | +class CreditCard(object): |
158 | + |
159 | + def __init__(self, card_type, name_on_card, card_number, ccv_number, |
160 | + expiration_month, expiration_year): |
161 | + self.card_type = card_type |
162 | + self.name_on_card = name_on_card |
163 | + self.card_number = card_number |
164 | + self.ccv_number = ccv_number |
165 | + self.expiration_month = expiration_month |
166 | + self.expiration_year = expiration_year |
167 | + |
168 | + def __repr__(self): |
169 | + return '%s(%r)' % (self.__class__, self.__dict__) |
170 | + |
171 | + @classmethod |
172 | + def make_test_visa_card(cls, unique_id=None): |
173 | + if unique_id is None: |
174 | + unique_id = str(uuid.uuid1()) |
175 | + card_type = 'Visa' |
176 | + name_on_card = 'Test name {0}'.format(unique_id) |
177 | + card_number = '4111111111111111' |
178 | + ccv_number = '123' |
179 | + expiration_month = '12' |
180 | + expiration_year = '2026' |
181 | + return cls(card_type, name_on_card, card_number, ccv_number, |
182 | + expiration_month, expiration_year) |
183 | + |
184 | + |
185 | +class Address(object): |
186 | + |
187 | + def __init__(self, street_line1=None, street_line2=None, city=None, |
188 | + state=None, postal_code=None, country=None): |
189 | + self.street_line1 = street_line1 |
190 | + self.street_line2 = street_line2 |
191 | + self.city = city |
192 | + self.state = state |
193 | + self.postal_code = postal_code |
194 | + self.country = country |
195 | + |
196 | + def __repr__(self): |
197 | + return '%s(%r)' % (self.__class__, self.__dict__) |
198 | + |
199 | + @classmethod |
200 | + def make_unique(cls, unique_id=None): |
201 | + if unique_id is None: |
202 | + unique_id = str(uuid.uuid1()) |
203 | + street_line1 = "Test street line 1 {0}".format(unique_id) |
204 | + street_line2 = "Test street line 2 {0}".format(unique_id) |
205 | + city = "Test city {0}".format(unique_id) |
206 | + state = "Test state {0}".format(unique_id) |
207 | + postal_code = "12345" |
208 | + country = "United States" |
209 | + return cls( |
210 | + street_line1, street_line2, city, state, postal_code, country) |
211 | |
212 | === added file 'u1testutils/pay/environment.py' |
213 | --- u1testutils/pay/environment.py 1970-01-01 00:00:00 +0000 |
214 | +++ u1testutils/pay/environment.py 2013-03-26 15:13:23 +0000 |
215 | @@ -0,0 +1,20 @@ |
216 | +# Copyright 2013 Canonical Ltd. |
217 | +# |
218 | +# This program is free software: you can redistribute it and/or modify it |
219 | +# under the terms of the GNU Lesser General Public License version 3, as |
220 | +# published by the Free Software Foundation. |
221 | +# |
222 | +# This program is distributed in the hope that it will be useful, but |
223 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
224 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
225 | +# PURPOSE. See the GNU Lesser General Public License for more details. |
226 | +# |
227 | +# You should have received a copy of the GNU General Public License along |
228 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
229 | + |
230 | +from django.conf import settings |
231 | + |
232 | + |
233 | +def get_pay_base_url(default='http://localhost:8000'): |
234 | + base_url = getattr(settings, 'PAY_SERVER_URL', default).rstrip('/') |
235 | + return base_url |
236 | |
237 | === added directory 'u1testutils/pay/selftests' |
238 | === added file 'u1testutils/pay/selftests/__init__.py' |
239 | === added directory 'u1testutils/pay/selftests/unit' |
240 | === added file 'u1testutils/pay/selftests/unit/__init__.py' |
241 | === added file 'u1testutils/pay/selftests/unit/test_pay_api_client.py' |
242 | --- u1testutils/pay/selftests/unit/test_pay_api_client.py 1970-01-01 00:00:00 +0000 |
243 | +++ u1testutils/pay/selftests/unit/test_pay_api_client.py 2013-03-26 15:13:23 +0000 |
244 | @@ -0,0 +1,81 @@ |
245 | +# Copyright 2013 Canonical Ltd. |
246 | +# |
247 | +# This program is free software: you can redistribute it and/or modify it |
248 | +# under the terms of the GNU Lesser General Public License version 3, as |
249 | +# published by the Free Software Foundation. |
250 | +# |
251 | +# This program is distributed in the hope that it will be useful, but |
252 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
253 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
254 | +# PURPOSE. See the GNU Lesser General Public License for more details. |
255 | +# |
256 | +# You should have received a copy of the GNU General Public License along |
257 | +# with this program. If not, see <http://www.gnu.org/licenses/ |
258 | + |
259 | +import unittest |
260 | + |
261 | +import mock |
262 | +import payclient |
263 | +from piston_mini_client import failhandlers |
264 | + |
265 | +import u1testutils.django |
266 | +from u1testutils.pay import client |
267 | +from u1testutils.pay import data as pay_data |
268 | +from u1testutils.sst.sso import data as sso_data |
269 | + |
270 | + |
271 | +class APIClientTestCase(unittest.TestCase): |
272 | + |
273 | + def test_get_api_client(self): |
274 | + api_client = client.get_pay_client() |
275 | + self.assertTrue(isinstance(api_client, payclient.PaymentServiceAPI)) |
276 | + |
277 | + def test_get_api_client_with_default_url(self): |
278 | + api_client = client.get_pay_client() |
279 | + self.assertEquals( |
280 | + api_client._service_root, 'http://localhost:8000/api/2.0/') |
281 | + |
282 | + def test_get_api_client_with_settings_url(self): |
283 | + with u1testutils.django.patch_settings( |
284 | + PAY_SERVER_URL='http://settings.pay.local:8000'): |
285 | + api_client = client.get_pay_client() |
286 | + self.assertEquals( |
287 | + api_client._service_root, |
288 | + 'http://settings.pay.local:8000/api/2.0/') |
289 | + |
290 | + def test_get_api_client_with_argument_url(self): |
291 | + pay_server_url = 'http://argument.pay.local:8000' |
292 | + api_client = client.get_pay_client(pay_server_url) |
293 | + self.assertEquals( |
294 | + api_client._service_root, |
295 | + 'http://argument.pay.local:8000/api/2.0/') |
296 | + |
297 | + def test_get_api_client_with_argument_url_and_trailing_slash(self): |
298 | + pay_server_url = 'http://argument.pay.local:8000/' |
299 | + api_client = client.get_pay_client(pay_server_url) |
300 | + self.assertEquals( |
301 | + api_client._service_root, |
302 | + 'http://argument.pay.local:8000/api/2.0/') |
303 | + |
304 | + |
305 | +class CreditCardAPIClientTestCase(unittest.TestCase): |
306 | + |
307 | + def setUp(self): |
308 | + self.user = sso_data.User( |
309 | + full_name='test', email='test', password='test', openid='test') |
310 | + self.credit_card = pay_data.CreditCard.make_test_visa_card() |
311 | + self.billing_address = pay_data.Address.make_unique() |
312 | + |
313 | + def test_new_credit_card_added(self): |
314 | + with mock.patch('payclient.PaymentServiceAPI.new_credit_card', |
315 | + return_value=payclient.CreditCardResponse()): |
316 | + added = client.add_new_credit_card( |
317 | + 'TEST', self.user, self.credit_card, self.billing_address) |
318 | + self.assertTrue(added) |
319 | + |
320 | + def test_add_new_credit_card_failed(self): |
321 | + with mock.patch('payclient.PaymentServiceAPI.new_credit_card', |
322 | + side_effect=failhandlers.APIError('test')): |
323 | + added = client.add_new_credit_card( |
324 | + 'TEST', self.user, self.credit_card, self.billing_address) |
325 | + self.assertFalse(added) |
326 | |
327 | === modified file 'u1testutils/selftests/django_project/settings.py' |
328 | --- u1testutils/selftests/django_project/settings.py 2013-01-21 03:26:21 +0000 |
329 | +++ u1testutils/selftests/django_project/settings.py 2013-03-26 15:13:23 +0000 |
330 | @@ -19,6 +19,10 @@ |
331 | IMAP_USE_SSL = False |
332 | IMAP_SERVER = 'localhost' |
333 | IMAP_PORT = 2143 |
334 | + |
335 | SSO_TEST_ACCOUNT_FULL_NAME = 'Test full name' |
336 | SSO_TEST_ACCOUNT_EMAIL = 'email@test.com' |
337 | SSO_TEST_ACCOUNT_PASSWORD = '7357 ΒΆ@55\^/0rD' |
338 | + |
339 | +PAY_API_USERNAME = 'testuser' |
340 | +PAY_API_PASSWORD = 'testpassword' |
341 | |
342 | === modified file 'u1testutils/sst/__init__.py' |
343 | --- u1testutils/sst/__init__.py 2011-12-20 19:36:51 +0000 |
344 | +++ u1testutils/sst/__init__.py 2013-03-26 15:13:23 +0000 |
345 | @@ -0,0 +1,56 @@ |
346 | +# Copyright 2013 Canonical Ltd. |
347 | +# |
348 | +# This program is free software: you can redistribute it and/or modify it |
349 | +# under the terms of the GNU Lesser General Public License version 3, as |
350 | +# published by the Free Software Foundation. |
351 | +# |
352 | +# This program is distributed in the hope that it will be useful, but |
353 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
354 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
355 | +# PURPOSE. See the GNU Lesser General Public License for more details. |
356 | +# |
357 | +# You should have received a copy of the GNU General Public License along |
358 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
359 | + |
360 | +import sst.actions |
361 | + |
362 | + |
363 | +class Page(object): |
364 | + """Base class for the page objects used in acceptance testing. |
365 | + |
366 | + Instance variables: |
367 | + title -- The title of the page. |
368 | + |
369 | + """ |
370 | + |
371 | + title = None |
372 | + headings1 = [] |
373 | + headings2 = [] |
374 | + |
375 | + def __init__(self): |
376 | + super(Page, self).__init__() |
377 | + self.assert_page_is_open() |
378 | + |
379 | + def assert_page_is_open(self): |
380 | + """Assert that the page is open.""" |
381 | + sst.actions.assert_title(self.title) |
382 | + if self.headings1: |
383 | + self.assert_headings1() |
384 | + if self.headings2: |
385 | + self.assert_headings2() |
386 | + |
387 | + def assert_headings1(self): |
388 | + """Assert the h1 elements of the page.""" |
389 | + self._assert_elements_text('h1', self.headings1) |
390 | + |
391 | + def _assert_elements_text(self, tag, expected_text_list): |
392 | + get_text = lambda x: x.text |
393 | + page_elements_text = map(get_text, sst.actions.get_elements(tag=tag)) |
394 | + assert expected_text_list == page_elements_text, \ |
395 | + 'Expected elements texts: {0}\n' \ |
396 | + 'Actual elements texts: {1}'.format( |
397 | + expected_text_list, page_elements_text) |
398 | + |
399 | + def assert_headings2(self): |
400 | + """Assert the h2 elements of the page.""" |
401 | + self._assert_elements_text('h2', self.headings2) |
402 | |
403 | === modified file 'u1testutils/sst/config.py' |
404 | --- u1testutils/sst/config.py 2013-03-13 15:55:37 +0000 |
405 | +++ u1testutils/sst/config.py 2013-03-26 15:13:23 +0000 |
406 | @@ -2,7 +2,14 @@ |
407 | from sst.actions import set_base_url |
408 | |
409 | |
410 | -def set_base_url_from_env(default_to='http://localhost:8000'): |
411 | +DEFAULT_BASE_URL = 'http://localhost:8000' |
412 | + |
413 | + |
414 | +def set_base_url_from_env(default_url=DEFAULT_BASE_URL): |
415 | """Set the base URL for SST tests from the env or default.""" |
416 | - base_url = os.environ.get('SST_BASE_URL', default_to) |
417 | - set_base_url(base_url.rstrip('/')) |
418 | + set_base_url(get_base_url_from_env(default_url)) |
419 | + |
420 | + |
421 | +def get_base_url_from_env(default_url=DEFAULT_BASE_URL): |
422 | + base_url = os.environ.get('SST_BASE_URL', default_url) |
423 | + return base_url.rstrip('/') |
424 | |
425 | === modified file 'u1testutils/sst/sso/__init__.py' |
426 | --- u1testutils/sst/sso/__init__.py 2013-02-26 20:38:37 +0000 |
427 | +++ u1testutils/sst/sso/__init__.py 2013-03-26 15:13:23 +0000 |
428 | @@ -1,5 +1,3 @@ |
429 | -# -*- coding: utf-8 -*- |
430 | - |
431 | # Copyright 2012, 2013 Canonical Ltd. |
432 | # |
433 | # This program is free software: you can redistribute it and/or modify it |
434 | |
435 | === modified file 'u1testutils/sst/sso/client.py' |
436 | --- u1testutils/sst/sso/client.py 2013-02-27 22:47:32 +0000 |
437 | +++ u1testutils/sst/sso/client.py 2013-03-26 15:13:23 +0000 |
438 | @@ -1,5 +1,3 @@ |
439 | -# -*- coding: utf-8 -*- |
440 | - |
441 | # Copyright 2012, 2013 Canonical Ltd. |
442 | # |
443 | # This program is free software: you can redistribute it and/or modify it |
444 | @@ -13,6 +11,7 @@ |
445 | # |
446 | # You should have received a copy of the GNU General Public License along |
447 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
448 | + |
449 | from ssoclient.v2 import V2ApiClient |
450 | |
451 | from u1testutils.sst.sso import environment |
452 | |
453 | === modified file 'u1testutils/sst/sso/data.py' |
454 | --- u1testutils/sst/sso/data.py 2013-02-14 19:53:25 +0000 |
455 | +++ u1testutils/sst/sso/data.py 2013-03-26 15:13:23 +0000 |
456 | @@ -42,6 +42,15 @@ |
457 | return self._openid |
458 | |
459 | @classmethod |
460 | + def make_unique(cls, unique_id=None): |
461 | + if unique_id is None: |
462 | + unique_id = str(uuid.uuid1()) |
463 | + full_name = 'Test user ' + unique_id |
464 | + email = 'test+{0}@example.com'.format(unique_id) |
465 | + password = 'Hola123*' |
466 | + return cls(full_name, email, password) |
467 | + |
468 | + @classmethod |
469 | def make_from_configuration(cls, new_user=False): |
470 | """Return a user taking its credentials from the configuration files. |
471 | |
472 | |
473 | === modified file 'u1testutils/sst/sso/environment.py' |
474 | --- u1testutils/sst/sso/environment.py 2013-02-14 19:51:37 +0000 |
475 | +++ u1testutils/sst/sso/environment.py 2013-03-26 15:13:23 +0000 |
476 | @@ -1,5 +1,3 @@ |
477 | -# -*- coding: utf-8 -*- |
478 | - |
479 | # Copyright 2012, 2013 Canonical Ltd. |
480 | # |
481 | # This program is free software: you can redistribute it and/or modify it |
482 | |
483 | === modified file 'u1testutils/sst/sso/pages.py' |
484 | --- u1testutils/sst/sso/pages.py 2013-02-26 20:51:33 +0000 |
485 | +++ u1testutils/sst/sso/pages.py 2013-03-26 15:13:23 +0000 |
486 | @@ -1,5 +1,3 @@ |
487 | -# -*- coding: utf-8 -*- |
488 | - |
489 | # Copyright 2013 Canonical Ltd. |
490 | # |
491 | # This program is free software: you can redistribute it and/or modify it |
492 | @@ -16,27 +14,10 @@ |
493 | |
494 | import sst.actions |
495 | |
496 | - |
497 | -class Page(object): |
498 | - """Base class for the page objects used in acceptance testing. |
499 | - |
500 | - Instance variables: |
501 | - title -- The title of the page. |
502 | - |
503 | - """ |
504 | - |
505 | - title = None |
506 | - |
507 | - def __init__(self): |
508 | - super(Page, self).__init__() |
509 | - self.assert_page_is_open() |
510 | - |
511 | - def assert_page_is_open(self): |
512 | - """Assert that the page is open.""" |
513 | - sst.actions.assert_title(self.title) |
514 | - |
515 | - |
516 | -class LogIn(Page): |
517 | +import u1testutils.sst |
518 | + |
519 | + |
520 | +class LogIn(u1testutils.sst.Page): |
521 | """Log in page of the Ubuntu Single Sign On website. |
522 | |
523 | This is a subclass of the Page object. It extends the assert_page_is_open |
524 | @@ -111,7 +92,7 @@ |
525 | return CreateAccount() |
526 | |
527 | |
528 | -class CreateAccount(Page): |
529 | +class CreateAccount(u1testutils.sst.Page): |
530 | """Create account page of the Ubuntu Single Sign On website. |
531 | |
532 | This is a subclass of the Page object. It adds methods for the actions |
533 | @@ -146,7 +127,7 @@ |
534 | sst.actions.click_button(continue_button) |
535 | |
536 | |
537 | -class RegistrationMailSent(Page): |
538 | +class RegistrationMailSent(u1testutils.sst.Page): |
539 | """Registration mail sent page of the Ubuntu Single Sign On website. |
540 | |
541 | This is a subclass of the Page object. It extends the assert_page_is_open |
542 | @@ -200,7 +181,7 @@ |
543 | sst.actions.click_button(continue_button) |
544 | |
545 | |
546 | -class ValidateEmail(Page): |
547 | +class ValidateEmail(u1testutils.sst.Page): |
548 | """Validate email address confirmation page. |
549 | |
550 | This is a subclass of the Page object. It adds methods for the actions |
551 | @@ -234,7 +215,7 @@ |
552 | return YourAccount(self.user_name) |
553 | |
554 | |
555 | -class SiteNotRecognized(Page): |
556 | +class SiteNotRecognized(u1testutils.sst.Page): |
557 | """Site not Recognized page of the Ubuntu Single Sign On website. |
558 | |
559 | This is a subclass of the Page object. It overrides the assert_page_is_open |
560 | @@ -281,7 +262,7 @@ |
561 | sst.actions.click_button(sign_me_in_button) |
562 | |
563 | |
564 | -class YourAccount(Page): |
565 | +class YourAccount(u1testutils.sst.Page): |
566 | """Your account page of the Ubuntu Single Sign On website. |
567 | |
568 | This is a subclass of the Page object. It extends the constructor to |
569 | @@ -312,7 +293,7 @@ |
570 | return YouHaveBeenLoggedOut() |
571 | |
572 | |
573 | -class YouHaveBeenLoggedOut(Page): |
574 | +class YouHaveBeenLoggedOut(u1testutils.sst.Page): |
575 | """Your account page of the Ubuntu Single Sign On website. |
576 | |
577 | This is a subclass of the Page object. |
578 | |
579 | === modified file 'u1testutils/sst/sso/selftests/unit/test_client.py' |
580 | --- u1testutils/sst/sso/selftests/unit/test_client.py 2013-02-27 22:47:32 +0000 |
581 | +++ u1testutils/sst/sso/selftests/unit/test_client.py 2013-03-26 15:13:23 +0000 |
582 | @@ -1,5 +1,3 @@ |
583 | -# -*- coding: utf-8 -*- |
584 | - |
585 | # Copyright 2012, 2013 Canonical Ltd. |
586 | # |
587 | # This program is free software: you can redistribute it and/or modify it |
Looks good!