Merge lp:~elopio/ubuntuone-credentials/fixtured_fake_server into lp:ubuntuone-credentials
- fixtured_fake_server
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Leo Arias |
Approved revision: | 90 |
Merged at revision: | 86 |
Proposed branch: | lp:~elopio/ubuntuone-credentials/fixtured_fake_server |
Merge into: | lp:ubuntuone-credentials |
Diff against target: |
476 lines (+75/-258) 6 files modified
online-accounts-provider/tests/CMakeLists.txt (+6/-2) online-accounts-provider/tests/autopilot/run (+0/-26) online-accounts-provider/tests/autopilot/run_mock_server.py (+0/-205) online-accounts-provider/tests/autopilot/ubuntuone_credentials/__init__.py (+27/-16) online-accounts-provider/tests/autopilot/ubuntuone_credentials/test_existing_account.py (+14/-6) online-accounts-provider/tests/autopilot/ubuntuone_credentials/test_new_account.py (+28/-3) |
To merge this branch: | bzr merge lp:~elopio/ubuntuone-credentials/fixtured_fake_server |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
dobey (community) | Approve | ||
Richard Huddie | Pending | ||
Javier Collado | Pending | ||
VĂctor R. Ruiz | Pending | ||
Review via email: mp+202972@code.launchpad.net |
Commit message
Refactor the fake servers to be a thread on the same process, started from a fixture on the test setup.
Description of the change
This change was requested by dobey in order to package the autopilot tests. It's nice because now it follows the same style we use on the click scope.
We need the autopilot helpers of ubuntuone-
PS Jenkins bot (ps-jenkins) wrote : | # |
dobey (dobey) wrote : | # |
390 +# Copyright (C) 2013, 2014 Canonical Ltd.
Please use - instead of a list of years, like 2013-2014, for the copyright headers.
Also, I think maybe online-
dobey (dobey) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:90
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'online-accounts-provider/tests/CMakeLists.txt' | |||
2 | --- online-accounts-provider/tests/CMakeLists.txt 2013-10-23 17:58:21 +0000 | |||
3 | +++ online-accounts-provider/tests/CMakeLists.txt 2014-01-24 15:43:44 +0000 | |||
4 | @@ -1,12 +1,16 @@ | |||
5 | 1 | SET (TESTS_TARGET test-online-accounts-provider) | 1 | SET (TESTS_TARGET test-online-accounts-provider) |
6 | 2 | 2 | ||
7 | 3 | set (AUTOPILOT_PACKAGE ubuntuone_credentials) | ||
8 | 4 | |||
9 | 3 | add_custom_target(online-accounts-provider-autopilot-tests | 5 | add_custom_target(online-accounts-provider-autopilot-tests |
11 | 4 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/autopilot/run ${CMAKE_CURRENT_BINARY_DIR} | 6 | COMMAND autopilot run ${AUTOPILOT_PACKAGE} |
12 | 7 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/autopilot | ||
13 | 5 | DEPENDS ${QML_PLUGIN_NAME} | 8 | DEPENDS ${QML_PLUGIN_NAME} |
14 | 6 | ) | 9 | ) |
15 | 7 | 10 | ||
16 | 8 | add_custom_target(online-accounts-provider-autopilot-tests-local | 11 | add_custom_target(online-accounts-provider-autopilot-tests-local |
18 | 9 | COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/autopilot/run ${CMAKE_CURRENT_BINARY_DIR} local | 12 | COMMAND SSO_AUTH_BASE_URL=fake SSO_UONE_BASE_URL=fake autopilot run ${AUTOPILOT_PACKAGE} |
19 | 13 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/autopilot | ||
20 | 10 | DEPENDS ${QML_PLUGIN_NAME} | 14 | DEPENDS ${QML_PLUGIN_NAME} |
21 | 11 | ) | 15 | ) |
22 | 12 | 16 | ||
23 | 13 | 17 | ||
24 | === removed file 'online-accounts-provider/tests/autopilot/run' | |||
25 | --- online-accounts-provider/tests/autopilot/run 2013-10-25 23:26:53 +0000 | |||
26 | +++ online-accounts-provider/tests/autopilot/run 1970-01-01 00:00:00 +0000 | |||
27 | @@ -1,26 +0,0 @@ | |||
28 | 1 | #!/bin/bash | ||
29 | 2 | |||
30 | 3 | if [[ -z `which autopilot` ]]; then | ||
31 | 4 | echo "Autopilot is not installed. Skip" | ||
32 | 5 | exit | ||
33 | 6 | fi | ||
34 | 7 | |||
35 | 8 | SCRIPTPATH=`dirname $0` | ||
36 | 9 | pushd ${SCRIPTPATH} | ||
37 | 10 | |||
38 | 11 | if [ "x$2" == "xlocal" ]; then | ||
39 | 12 | echo "Using server at localhost:8080" | ||
40 | 13 | export SSO_AUTH_BASE_URL=http://localhost:8080 | ||
41 | 14 | export SSO_UONE_BASE_URL=http://localhost:8080 | ||
42 | 15 | python run_mock_server.py & | ||
43 | 16 | fi | ||
44 | 17 | |||
45 | 18 | export QML2_IMPORT_PATH=/usr/lib/i386-linux-gnu/ubuntu-system-settings/private:$1/../../qml-credentials-service | ||
46 | 19 | export U1_DEBUG=1 | ||
47 | 20 | autopilot run UbuntuOneCredentialsProviderAutopilotTests | ||
48 | 21 | popd | ||
49 | 22 | |||
50 | 23 | if [ "x$2" == "xlocal" ]; then | ||
51 | 24 | echo "tearing down server" | ||
52 | 25 | kill -HUP %1 | ||
53 | 26 | fi | ||
54 | 27 | 0 | ||
55 | === removed file 'online-accounts-provider/tests/autopilot/run_mock_server.py' | |||
56 | --- online-accounts-provider/tests/autopilot/run_mock_server.py 2013-10-29 17:25:31 +0000 | |||
57 | +++ online-accounts-provider/tests/autopilot/run_mock_server.py 1970-01-01 00:00:00 +0000 | |||
58 | @@ -1,205 +0,0 @@ | |||
59 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
60 | 2 | # | ||
61 | 3 | # Copyright (C) 2013 Canonical Ltd. | ||
62 | 4 | # | ||
63 | 5 | # This program is free software; you can redistribute it and/or modify | ||
64 | 6 | # it under the terms of the GNU General Public License version 3, as published | ||
65 | 7 | # by the Free Software Foundation. | ||
66 | 8 | # | ||
67 | 9 | # This program is distributed in the hope that it will be useful, | ||
68 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
69 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
70 | 12 | # GNU General Public License for more details. | ||
71 | 13 | # | ||
72 | 14 | # You should have received a copy of the GNU General Public License | ||
73 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
74 | 16 | |||
75 | 17 | """Mock server for SSO and U1 Ping endpoints.""" | ||
76 | 18 | |||
77 | 19 | import BaseHTTPServer | ||
78 | 20 | import json | ||
79 | 21 | import signal | ||
80 | 22 | import sys | ||
81 | 23 | |||
82 | 24 | from urlparse import urlparse, parse_qs | ||
83 | 25 | |||
84 | 26 | SSO_API_PATH = '/api/v2' | ||
85 | 27 | UONE_API_PATH = '/oauth/sso-finished-so-get-tokens/' | ||
86 | 28 | |||
87 | 29 | |||
88 | 30 | LOGIN_OK_RESPONSE = """ | ||
89 | 31 | { | ||
90 | 32 | "href": "https://login.ubuntu.com/api/v2/tokens/oauth/the-key", | ||
91 | 33 | "token_key": "token-key", | ||
92 | 34 | "token_secret": "token-secret", | ||
93 | 35 | "token_name": "token-name", | ||
94 | 36 | "consumer_key": "consumer-key", | ||
95 | 37 | "consumer_secret": "consumer-secret", | ||
96 | 38 | "date_created": "2013-01-11 12:43:23", | ||
97 | 39 | "date_updated": "2013-01-11 12:43:23" | ||
98 | 40 | } | ||
99 | 41 | """ | ||
100 | 42 | |||
101 | 43 | TWOFACTOR_REQUIRED_RESPONSE = """ | ||
102 | 44 | { | ||
103 | 45 | "code": "TWOFACTOR_REQUIRED", | ||
104 | 46 | "message": "This account requires 2-factor authentication.", | ||
105 | 47 | "extra": {} | ||
106 | 48 | } | ||
107 | 49 | """ | ||
108 | 50 | |||
109 | 51 | LOGIN_ERR_RESPONSE = """ | ||
110 | 52 | { | ||
111 | 53 | "code": "INVALID_CREDENTIALS", | ||
112 | 54 | "message": "Your email/password isn't correct.", | ||
113 | 55 | "extra": {} | ||
114 | 56 | } | ||
115 | 57 | """ | ||
116 | 58 | |||
117 | 59 | TWOFACTOR_ERR_RESPONSE = """ | ||
118 | 60 | { | ||
119 | 61 | "message": "The provided 2-factor key is not recognised.", | ||
120 | 62 | "code": "TWOFACTOR_FAILURE", | ||
121 | 63 | "extra": {} | ||
122 | 64 | } | ||
123 | 65 | """ | ||
124 | 66 | |||
125 | 67 | INVALID_DATA_RESPONSE = """ | ||
126 | 68 | { | ||
127 | 69 | "message": "Invalid request data", | ||
128 | 70 | "code": "INVALID_DATA", | ||
129 | 71 | "extra": { | ||
130 | 72 | "password": [ | ||
131 | 73 | "A real password-specific message would go here." | ||
132 | 74 | ], | ||
133 | 75 | "email": [ | ||
134 | 76 | "A real email-specific message would go here." | ||
135 | 77 | ] | ||
136 | 78 | } | ||
137 | 79 | } | ||
138 | 80 | """ | ||
139 | 81 | |||
140 | 82 | REGISTER_CREATED_RESPONSE = """ | ||
141 | 83 | { | ||
142 | 84 | "status": "Active", | ||
143 | 85 | "openid": "fFcTeSt", | ||
144 | 86 | "verified": false, | ||
145 | 87 | "emails": [ | ||
146 | 88 | { | ||
147 | 89 | "href": "/api/v2/emails/new@te.st", | ||
148 | 90 | "verified": false | ||
149 | 91 | } | ||
150 | 92 | ], | ||
151 | 93 | "tokens": [], | ||
152 | 94 | "href": "/api/v2/accounts/fFcTeSt", | ||
153 | 95 | "displayname": "Test", | ||
154 | 96 | "email": "new@te.st" | ||
155 | 97 | } | ||
156 | 98 | """ | ||
157 | 99 | |||
158 | 100 | |||
159 | 101 | class MockSSOAndUOneRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): | ||
160 | 102 | |||
161 | 103 | def do_GET(self): | ||
162 | 104 | """Handle GET as if we were the one.ubuntu.com server | ||
163 | 105 | """ | ||
164 | 106 | parsedPath = urlparse(self.path) | ||
165 | 107 | queryDict = parse_qs(parsedPath.query) | ||
166 | 108 | |||
167 | 109 | if parsedPath.path.startswith('/oauth/sso-finished-so-get-tokens/'): | ||
168 | 110 | for k in ['platform', 'platform_version', 'platform_arch']: | ||
169 | 111 | if k not in queryDict: | ||
170 | 112 | print "****** MISSING ", k, " IN ", queryDict, "bailing" | ||
171 | 113 | self.send_error(401) | ||
172 | 114 | return | ||
173 | 115 | self.send_response(200) | ||
174 | 116 | self.end_headers() | ||
175 | 117 | self.wfile.write("ok 0/0") # fake format of server's real response | ||
176 | 118 | else: | ||
177 | 119 | self.send_error(404) # real server currently returns 500! | ||
178 | 120 | |||
179 | 121 | def do_POST(self): | ||
180 | 122 | """Handle POST as if we are the login.ubuntu.com server. | ||
181 | 123 | """ | ||
182 | 124 | length = int(self.headers['Content-Length']) | ||
183 | 125 | postdata = self.rfile.read(length) | ||
184 | 126 | if postdata == '': | ||
185 | 127 | print "NOTE: empty postdata, just dropping the request" | ||
186 | 128 | return | ||
187 | 129 | |||
188 | 130 | try: | ||
189 | 131 | bodyDict = json.loads(postdata) | ||
190 | 132 | except ValueError: | ||
191 | 133 | print "error loading json from postdata: '%s'" % postdata | ||
192 | 134 | self.send_error(500) | ||
193 | 135 | return | ||
194 | 136 | |||
195 | 137 | if self.path == SSO_API_PATH + '/tokens/oauth': | ||
196 | 138 | self.handle_login(bodyDict) | ||
197 | 139 | elif self.path == SSO_API_PATH + '/accounts': | ||
198 | 140 | self.handle_register(bodyDict) | ||
199 | 141 | else: | ||
200 | 142 | print "unknown -- self.path is ", self.path | ||
201 | 143 | self.send_error(404, 'unknown') | ||
202 | 144 | |||
203 | 145 | def send_JSON_reply(self, code, replyJSON): | ||
204 | 146 | self.send_response(code) | ||
205 | 147 | self.send_header("Content-Type", "application/json") | ||
206 | 148 | self.end_headers() | ||
207 | 149 | self.wfile.write(replyJSON) | ||
208 | 150 | |||
209 | 151 | def handle_login(self, bodyDict): | ||
210 | 152 | |||
211 | 153 | if 'email' not in bodyDict \ | ||
212 | 154 | or 'password' not in bodyDict or 'token_name' not in bodyDict: | ||
213 | 155 | self.send_JSON_reply(400, INVALID_DATA_RESPONSE) | ||
214 | 156 | return | ||
215 | 157 | |||
216 | 158 | email = bodyDict['email'] | ||
217 | 159 | |||
218 | 160 | if email in ["ok@te.st", "new@te.st"]: | ||
219 | 161 | self.send_JSON_reply(201, LOGIN_OK_RESPONSE) | ||
220 | 162 | |||
221 | 163 | elif email == "2fa@te.st": | ||
222 | 164 | if 'otp' not in bodyDict: | ||
223 | 165 | self.send_JSON_reply(401, TWOFACTOR_REQUIRED_RESPONSE) | ||
224 | 166 | else: | ||
225 | 167 | if len(bodyDict['otp']) != 6: | ||
226 | 168 | self.send_JSON_reply(403, TWOFACTOR_ERR_RESPONSE) | ||
227 | 169 | else: | ||
228 | 170 | self.send_JSON_reply(201, LOGIN_OK_RESPONSE) | ||
229 | 171 | |||
230 | 172 | else: | ||
231 | 173 | self.send_JSON_reply(401, LOGIN_ERR_RESPONSE) | ||
232 | 174 | |||
233 | 175 | def handle_register(self, bodyDict): | ||
234 | 176 | if 'email' not in bodyDict \ | ||
235 | 177 | or 'password' not in bodyDict \ | ||
236 | 178 | or 'displayname' not in bodyDict \ | ||
237 | 179 | or bodyDict['email'] == 'bad-new@te.st': | ||
238 | 180 | |||
239 | 181 | self.send_JSON_reply(400, INVALID_DATA_RESPONSE) | ||
240 | 182 | return | ||
241 | 183 | |||
242 | 184 | self.send_JSON_reply(201, REGISTER_CREATED_RESPONSE) | ||
243 | 185 | |||
244 | 186 | |||
245 | 187 | if __name__ == '__main__': | ||
246 | 188 | |||
247 | 189 | server_address = ('', 8080) | ||
248 | 190 | httpd = BaseHTTPServer.HTTPServer(server_address, | ||
249 | 191 | MockSSOAndUOneRequestHandler) | ||
250 | 192 | |||
251 | 193 | def stop_immediately(signum, frame): | ||
252 | 194 | print "Got signal ", signum, ", stopping server." | ||
253 | 195 | httpd.socket.close() | ||
254 | 196 | |||
255 | 197 | signal.signal(signal.SIGINT, stop_immediately) | ||
256 | 198 | signal.signal(signal.SIGHUP, stop_immediately) | ||
257 | 199 | |||
258 | 200 | print "Mock server running at ", 8080 | ||
259 | 201 | |||
260 | 202 | try: | ||
261 | 203 | httpd.serve_forever() | ||
262 | 204 | except: | ||
263 | 205 | pass | ||
264 | 206 | 0 | ||
265 | === renamed directory 'online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests' => 'online-accounts-provider/tests/autopilot/ubuntuone_credentials' | |||
266 | === modified file 'online-accounts-provider/tests/autopilot/ubuntuone_credentials/__init__.py' | |||
267 | --- online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/__init__.py 2013-10-10 02:39:50 +0000 | |||
268 | +++ online-accounts-provider/tests/autopilot/ubuntuone_credentials/__init__.py 2014-01-24 15:43:44 +0000 | |||
269 | @@ -1,6 +1,6 @@ | |||
270 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
271 | 2 | # | 2 | # |
273 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
274 | 4 | # | 4 | # |
275 | 5 | # This program is free software; you can redistribute it and/or modify | 5 | # This program is free software; you can redistribute it and/or modify |
276 | 6 | # it under the terms of the GNU General Public License version 3, as published | 6 | # it under the terms of the GNU General Public License version 3, as published |
277 | @@ -20,14 +20,18 @@ | |||
278 | 20 | import subprocess | 20 | import subprocess |
279 | 21 | import tempfile | 21 | import tempfile |
280 | 22 | 22 | ||
281 | 23 | import fixtures | ||
282 | 23 | from autopilot import input | 24 | from autopilot import input |
283 | 24 | from autopilot.matchers import Eventually | 25 | from autopilot.matchers import Eventually |
284 | 25 | from testtools.matchers import Equals | 26 | from testtools.matchers import Equals |
285 | 26 | from ubuntuuitoolkit import ( | 27 | from ubuntuuitoolkit import ( |
286 | 27 | base, | 28 | base, |
287 | 28 | emulators as toolkit_emulators, | 29 | emulators as toolkit_emulators, |
288 | 30 | tests as toolkit_tests | ||
289 | 29 | ) | 31 | ) |
290 | 30 | 32 | ||
291 | 33 | from ubuntuone_credentials import fixture_setup | ||
292 | 34 | |||
293 | 31 | 35 | ||
294 | 32 | def _get_module_include_path(): | 36 | def _get_module_include_path(): |
295 | 33 | return _get_path_to_source_root() | 37 | return _get_path_to_source_root() |
296 | @@ -39,19 +43,6 @@ | |||
297 | 39 | os.path.dirname(__file__), '..', '..', '..')) | 43 | os.path.dirname(__file__), '..', '..', '..')) |
298 | 40 | 44 | ||
299 | 41 | 45 | ||
300 | 42 | def _get_local_desktop_file_directory(): | ||
301 | 43 | return os.path.join(os.environ['HOME'], '.local', 'share', 'applications') | ||
302 | 44 | |||
303 | 45 | |||
304 | 46 | def _get_qmlscene_launch_command(): | ||
305 | 47 | """Return the command to launch qmlscene for autopilot tests.""" | ||
306 | 48 | # TODO replace this with the one from the ubuntu-ui-toolkit, that has just | ||
307 | 49 | # been merged to trunk. --elopio - 2013-10-08 | ||
308 | 50 | arch = subprocess.check_output( | ||
309 | 51 | ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip() | ||
310 | 52 | return '/usr/lib/' + arch + '/qt5/bin/qmlscene' | ||
311 | 53 | |||
312 | 54 | |||
313 | 55 | class TestCaseWithQMLWrapper(base.UbuntuUIToolkitAppTestCase): | 46 | class TestCaseWithQMLWrapper(base.UbuntuUIToolkitAppTestCase): |
314 | 56 | 47 | ||
315 | 57 | _DESKTOP_FILE_CONTENTS = ("""[Desktop Entry] | 48 | _DESKTOP_FILE_CONTENTS = ("""[Desktop Entry] |
316 | @@ -67,15 +58,35 @@ | |||
317 | 67 | def setUp(self): | 58 | def setUp(self): |
318 | 68 | super(TestCaseWithQMLWrapper, self).setUp() | 59 | super(TestCaseWithQMLWrapper, self).setUp() |
319 | 69 | self.pointing_device = input.Pointer(self.input_device_class.create()) | 60 | self.pointing_device = input.Pointer(self.input_device_class.create()) |
320 | 61 | self.use_qml2_import_path_for_fake_wrapper() | ||
321 | 70 | self.launch_application() | 62 | self.launch_application() |
322 | 71 | 63 | ||
323 | 64 | def use_fake_servers(self): | ||
324 | 65 | fake_sso_and_u1_server = fixture_setup.FakeSSOAndU1ServersRunning() | ||
325 | 66 | self.useFixture(fake_sso_and_u1_server) | ||
326 | 67 | self.useFixture(fixtures.EnvironmentVariable( | ||
327 | 68 | 'SSO_AUTH_BASE_URL', newvalue=fake_sso_and_u1_server.url)) | ||
328 | 69 | self.useFixture(fixtures.EnvironmentVariable( | ||
329 | 70 | 'SSO_UONE_BASE_URL', newvalue=fake_sso_and_u1_server.url)) | ||
330 | 71 | |||
331 | 72 | def use_qml2_import_path_for_fake_wrapper(self): | ||
332 | 73 | arch = subprocess.check_output( | ||
333 | 74 | ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip() | ||
334 | 75 | system_settings_path = ( | ||
335 | 76 | '/usr/lib/{}/ubuntu-system-settings/private'.format(arch)) | ||
336 | 77 | qml_credentials_path = os.path.join( | ||
337 | 78 | _get_path_to_source_root(), 'qml-credentials-service') | ||
338 | 79 | self.useFixture(fixtures.EnvironmentVariable( | ||
339 | 80 | 'QML2_IMPORT_PATH', | ||
340 | 81 | newvalue=':'.join([system_settings_path, qml_credentials_path]))) | ||
341 | 82 | |||
342 | 72 | def launch_application(self): | 83 | def launch_application(self): |
343 | 73 | qml_file_path = os.path.join( | 84 | qml_file_path = os.path.join( |
344 | 74 | os.path.dirname(__file__), self.test_qml_wrapper_file_name) | 85 | os.path.dirname(__file__), self.test_qml_wrapper_file_name) |
345 | 75 | desktop_file_path = self._write_test_desktop_file() | 86 | desktop_file_path = self._write_test_desktop_file() |
346 | 76 | self.addCleanup(os.remove, desktop_file_path) | 87 | self.addCleanup(os.remove, desktop_file_path) |
347 | 77 | self.app = self.launch_test_application( | 88 | self.app = self.launch_test_application( |
349 | 78 | _get_qmlscene_launch_command(), | 89 | base.get_qmlscene_launch_command(), |
350 | 79 | '-I' + _get_module_include_path(), | 90 | '-I' + _get_module_include_path(), |
351 | 80 | qml_file_path, | 91 | qml_file_path, |
352 | 81 | '--desktop_file_hint={0}'.format(desktop_file_path), | 92 | '--desktop_file_hint={0}'.format(desktop_file_path), |
353 | @@ -86,7 +97,7 @@ | |||
354 | 86 | self.main_view.visible, Eventually(Equals(True))) | 97 | self.main_view.visible, Eventually(Equals(True))) |
355 | 87 | 98 | ||
356 | 88 | def _write_test_desktop_file(self): | 99 | def _write_test_desktop_file(self): |
358 | 89 | desktop_file_dir = _get_local_desktop_file_directory() | 100 | desktop_file_dir = toolkit_tests.get_local_desktop_file_directory() |
359 | 90 | if not os.path.exists(desktop_file_dir): | 101 | if not os.path.exists(desktop_file_dir): |
360 | 91 | os.makedirs(desktop_file_dir) | 102 | os.makedirs(desktop_file_dir) |
361 | 92 | desktop_file = tempfile.NamedTemporaryFile( | 103 | desktop_file = tempfile.NamedTemporaryFile( |
362 | 93 | 104 | ||
363 | === modified file 'online-accounts-provider/tests/autopilot/ubuntuone_credentials/test_existing_account.py' | |||
364 | --- online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_existing_account.py 2013-10-08 23:45:57 +0000 | |||
365 | +++ online-accounts-provider/tests/autopilot/ubuntuone_credentials/test_existing_account.py 2014-01-24 15:43:44 +0000 | |||
366 | @@ -1,6 +1,6 @@ | |||
367 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
368 | 2 | # | 2 | # |
370 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
371 | 4 | # | 4 | # |
372 | 5 | # This program is free software; you can redistribute it and/or modify | 5 | # This program is free software; you can redistribute it and/or modify |
373 | 6 | # it under the terms of the GNU General Public License version 3, as published | 6 | # it under the terms of the GNU General Public License version 3, as published |
374 | @@ -14,17 +14,25 @@ | |||
375 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
376 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
377 | 16 | 16 | ||
378 | 17 | import os | ||
379 | 18 | |||
380 | 17 | from autopilot.matchers import Eventually | 19 | from autopilot.matchers import Eventually |
381 | 18 | from testtools.matchers import Equals | 20 | from testtools.matchers import Equals |
382 | 19 | 21 | ||
388 | 20 | import UbuntuOneCredentialsProviderAutopilotTests | 22 | import ubuntuone_credentials |
389 | 21 | 23 | ||
390 | 22 | 24 | ||
391 | 23 | class ExistingUOAAccountTests( | 25 | class ExistingUOAAccountTestCase(ubuntuone_credentials.TestCaseWithQMLWrapper): |
387 | 24 | UbuntuOneCredentialsProviderAutopilotTests.TestCaseWithQMLWrapper): | ||
392 | 25 | 26 | ||
393 | 26 | test_qml_wrapper_file_name = 'TestWrapperExisting.qml' | 27 | test_qml_wrapper_file_name = 'TestWrapperExisting.qml' |
394 | 27 | 28 | ||
395 | 29 | def setUp(self): | ||
396 | 30 | # Start the fake server before launching the application. | ||
397 | 31 | if (os.environ.get('SSO_AUTH_BASE_URL') == 'fake' and | ||
398 | 32 | os.environ.get('SSO_UONE_BASE_URL') == 'fake'): | ||
399 | 33 | self.use_fake_servers() | ||
400 | 34 | super(ExistingUOAAccountTestCase, self).setUp() | ||
401 | 35 | |||
402 | 28 | def test_show_remove_account_dialog(self): | 36 | def test_show_remove_account_dialog(self): |
403 | 29 | remove_account_button = self.main_view.select_single( | 37 | remove_account_button = self.main_view.select_single( |
404 | 30 | objectName='removeAccountButton') | 38 | objectName='removeAccountButton') |
405 | 31 | 39 | ||
406 | === modified file 'online-accounts-provider/tests/autopilot/ubuntuone_credentials/test_new_account.py' | |||
407 | --- online-accounts-provider/tests/autopilot/UbuntuOneCredentialsProviderAutopilotTests/test_new_account.py 2013-10-29 17:25:31 +0000 | |||
408 | +++ online-accounts-provider/tests/autopilot/ubuntuone_credentials/test_new_account.py 2014-01-24 15:43:44 +0000 | |||
409 | @@ -1,6 +1,6 @@ | |||
410 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
411 | 2 | # | 2 | # |
413 | 3 | # Copyright (C) 2013 Canonical Ltd. | 3 | # Copyright (C) 2013-2014 Canonical Ltd. |
414 | 4 | # | 4 | # |
415 | 5 | # This program is free software; you can redistribute it and/or modify | 5 | # This program is free software; you can redistribute it and/or modify |
416 | 6 | # it under the terms of the GNU General Public License version 3, as published | 6 | # it under the terms of the GNU General Public License version 3, as published |
417 | @@ -14,12 +14,16 @@ | |||
418 | 14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
419 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
420 | 16 | 16 | ||
421 | 17 | import os | ||
422 | 18 | |||
423 | 17 | from autopilot.matchers import Eventually | 19 | from autopilot.matchers import Eventually |
424 | 18 | from testtools.matchers import Equals, Not | 20 | from testtools.matchers import Equals, Not |
425 | 19 | from ubuntuuitoolkit import emulators as toolkit_emulators | 21 | from ubuntuuitoolkit import emulators as toolkit_emulators |
426 | 20 | 22 | ||
429 | 21 | from UbuntuOneCredentialsProviderAutopilotTests import (emulators, | 23 | from ubuntuone_credentials import ( |
430 | 22 | TestCaseWithQMLWrapper) | 24 | emulators, |
431 | 25 | TestCaseWithQMLWrapper | ||
432 | 26 | ) | ||
433 | 23 | 27 | ||
434 | 24 | 28 | ||
435 | 25 | class NewUbuntuOneOnlineAccountTestCase(TestCaseWithQMLWrapper): | 29 | class NewUbuntuOneOnlineAccountTestCase(TestCaseWithQMLWrapper): |
436 | @@ -78,6 +82,13 @@ | |||
437 | 78 | ('failure', | 82 | ('failure', |
438 | 79 | dict(email='not-ok@te.st', password='password', success=False))] | 83 | dict(email='not-ok@te.st', password='password', success=False))] |
439 | 80 | 84 | ||
440 | 85 | def setUp(self): | ||
441 | 86 | # Start the fake server before launching the application. | ||
442 | 87 | if (os.environ.get('SSO_AUTH_BASE_URL') == 'fake' and | ||
443 | 88 | os.environ.get('SSO_UONE_BASE_URL') == 'fake'): | ||
444 | 89 | self.use_fake_servers() | ||
445 | 90 | super(SimpleLogInTestCase, self).setUp() | ||
446 | 91 | |||
447 | 81 | def test_simple_login(self): | 92 | def test_simple_login(self): |
448 | 82 | """Test that success pops the NewAccount main page, and | 93 | """Test that success pops the NewAccount main page, and |
449 | 83 | failure shows the error label. | 94 | failure shows the error label. |
450 | @@ -103,6 +114,13 @@ | |||
451 | 103 | twoFactorCode='bad', success=False)) | 114 | twoFactorCode='bad', success=False)) |
452 | 104 | ] | 115 | ] |
453 | 105 | 116 | ||
454 | 117 | def setUp(self): | ||
455 | 118 | # Start the fake server before launching the application. | ||
456 | 119 | if (os.environ.get('SSO_AUTH_BASE_URL') == 'fake' and | ||
457 | 120 | os.environ.get('SSO_UONE_BASE_URL') == 'fake'): | ||
458 | 121 | self.use_fake_servers() | ||
459 | 122 | super(TwoFactorLogInTestCase, self).setUp() | ||
460 | 123 | |||
461 | 106 | def test_twofactor_login(self): | 124 | def test_twofactor_login(self): |
462 | 107 | "Test that success pops the NewAccount main page." | 125 | "Test that success pops the NewAccount main page." |
463 | 108 | 126 | ||
464 | @@ -158,6 +176,13 @@ | |||
465 | 158 | success=False)) | 176 | success=False)) |
466 | 159 | ] | 177 | ] |
467 | 160 | 178 | ||
468 | 179 | def setUp(self): | ||
469 | 180 | # Start the fake server before launching the application. | ||
470 | 181 | if (os.environ.get('SSO_AUTH_BASE_URL') == 'fake' and | ||
471 | 182 | os.environ.get('SSO_UONE_BASE_URL') == 'fake'): | ||
472 | 183 | self.use_fake_servers() | ||
473 | 184 | super(RegisterNewU1AccountTestCase, self).setUp() | ||
474 | 185 | |||
475 | 161 | def test_register_new_account(self): | 186 | def test_register_new_account(self): |
476 | 162 | "Test that registering a new account pops the main page." | 187 | "Test that registering a new account pops the main page." |
477 | 163 | 188 |
PASSED: Continuous integration, rev:88 jenkins. qa.ubuntu. com/job/ ubuntuone- credentials- ci/78/ jenkins. qa.ubuntu. com/job/ ubuntuone- credentials- trusty- amd64-ci/ 8 jenkins. qa.ubuntu. com/job/ ubuntuone- credentials- trusty- armhf-ci/ 8 jenkins. qa.ubuntu. com/job/ ubuntuone- credentials- trusty- armhf-ci/ 8/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntuone- credentials- ci/78/rebuild
http://