Merge lp:~elopio/reminders-app/fix_with_account into lp:reminders-app
- fix_with_account
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~elopio/reminders-app/fix_with_account |
Merge into: | lp:reminders-app |
Diff against target: |
557 lines (+218/-88) 9 files modified
manifest.json (+2/-2) tests/autopilot/reminders/__init__.py (+7/-0) tests/autopilot/reminders/credentials.py (+58/-14) tests/autopilot/reminders/evernote.py (+1/-0) tests/autopilot/reminders/fake_services.py (+1/-0) tests/autopilot/reminders/tests/__init__.py (+74/-63) tests/autopilot/reminders/tests/test_credentials.py (+70/-0) tests/autopilot/reminders/tests/test_evernote.py (+1/-0) tests/autopilot/reminders/tests/test_reminders.py (+4/-9) |
To merge this branch: | bzr merge lp:~elopio/reminders-app/fix_with_account |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Nicholas Skaggs (community) | Approve | ||
Review via email: mp+224221@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-06-25.
Commit message
Added logging messages and tests to the credentials autopilot tests helpers.
Description of the change
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:165
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
This still fails on the desktop for me.. no account created :-(
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:168
http://
Executed test runs:
UNSTABLE: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:169
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:169
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:169
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:171
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:172
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 173. By Leo Arias
-
Log all accounts
- 174. By Leo Arias
-
Fixed the call to manager.
- 175. By Leo Arias
-
Log more.
- 176. By Leo Arias
-
Log the id of the deleted account.
- 177. By Leo Arias
-
Kill signond everytime we instantiate a new Account Manager.
- 178. By Leo Arias
-
Removed the extra sleep.
- 179. By Leo Arias
-
Make sure signond is killed.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:175
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:179
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
These greatly improves things, though still has some interesting behaviours that can be observed running the tests.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:185
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:186
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
Preview Diff
1 | === modified file 'manifest.json' |
2 | --- manifest.json 2014-05-16 08:53:45 +0000 |
3 | +++ manifest.json 2014-06-25 23:28:42 +0000 |
4 | @@ -12,10 +12,10 @@ |
5 | "maintainer": "Ubuntu Reminders app developers <ubuntu-phone@lists.launchpad.net>", |
6 | "name": "com.ubuntu.reminders", |
7 | "title": "Reminders", |
8 | - "version": "0.5.@BZR_REVNO@", |
9 | + "version": "0.5.185", |
10 | "x-source": { |
11 | "vcs-bzr": "lp:reminders-app", |
12 | - "vcs-bzr-revno": "@BZR_REVNO@" |
13 | + "vcs-bzr-revno": "185" |
14 | }, |
15 | "x-test": { |
16 | "autopilot": "reminders" |
17 | |
18 | === modified file 'tests/autopilot/reminders/__init__.py' |
19 | --- tests/autopilot/reminders/__init__.py 2014-06-24 00:01:51 +0000 |
20 | +++ tests/autopilot/reminders/__init__.py 2014-06-25 23:28:42 +0000 |
21 | @@ -33,10 +33,12 @@ |
22 | |
23 | |
24 | class RemindersAppException(Exception): |
25 | + |
26 | """Exception raised when there's an error in the Reminders App.""" |
27 | |
28 | |
29 | class RemindersApp(object): |
30 | + |
31 | """Autopilot helper object for the Reminders application.""" |
32 | |
33 | def __init__(self, app_proxy): |
34 | @@ -55,6 +57,7 @@ |
35 | |
36 | |
37 | class MainView(toolkit_emulators.MainView): |
38 | + |
39 | """Autopilot custom proxy object for the MainView.""" |
40 | |
41 | def __init__(self, *args): |
42 | @@ -76,6 +79,7 @@ |
43 | |
44 | |
45 | class NoAccountDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
46 | + |
47 | """Autopilot custom proxy object for the no account dialog.""" |
48 | |
49 | @classmethod |
50 | @@ -110,10 +114,12 @@ |
51 | |
52 | |
53 | class PulldownListView(ubuntuuitoolkit.QQuickListView): |
54 | + |
55 | """Autopilot custom proxy object for the PulldownListView.""" |
56 | |
57 | |
58 | class NotebooksPage(_Page): |
59 | + |
60 | """Autopilot custom proxy object for the Notebooks page.""" |
61 | |
62 | def add_notebook(self, title): |
63 | @@ -164,6 +170,7 @@ |
64 | |
65 | |
66 | class NotebooksDelegate(toolkit_emulators.UbuntuUIToolkitEmulatorBase): |
67 | + |
68 | """Autopilot custom proxy object for the NotebooksDelegate.""" |
69 | |
70 | def get_title(self): |
71 | |
72 | === modified file 'tests/autopilot/reminders/credentials.py' |
73 | --- tests/autopilot/reminders/credentials.py 2014-05-14 16:18:22 +0000 |
74 | +++ tests/autopilot/reminders/credentials.py 2014-06-25 23:28:42 +0000 |
75 | @@ -14,17 +14,23 @@ |
76 | # You should have received a copy of the GNU General Public License |
77 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
78 | |
79 | - |
80 | +import logging |
81 | +import time |
82 | import threading |
83 | |
84 | from gi.repository import Accounts, GLib, Signon |
85 | |
86 | |
87 | +logger = logging.getLogger(__name__) |
88 | + |
89 | + |
90 | class CredentialsException(Exception): |
91 | + |
92 | """Exception for credentials problems.""" |
93 | |
94 | |
95 | class AccountManager(object): |
96 | + |
97 | """Manager for online accounts.""" |
98 | |
99 | def __init__(self): |
100 | @@ -50,6 +56,7 @@ |
101 | :param oauth_token: The oauth token of the account. |
102 | |
103 | """ |
104 | + logger.debug('Add an evernote account.') |
105 | self._start_main_loop() |
106 | |
107 | account = self._create_account() |
108 | @@ -63,11 +70,17 @@ |
109 | |
110 | self._join_main_loop() |
111 | |
112 | + # XXX Sometimes, the account fails to be enabled. This sleep seems to |
113 | + # fix it but we haven't yet found the reason. --elopio - 2014-06-25 |
114 | + time.sleep(10) |
115 | self._enable_evernote_service(account) |
116 | |
117 | + logger.info('Created the account with id: {}.'.format(account.id)) |
118 | + self._log_accounts_info() |
119 | return account |
120 | |
121 | def _create_account(self): |
122 | + logger.debug('Creating the Evernote account.') |
123 | account = self._manager.create_account('evernote') |
124 | account.set_enabled(True) |
125 | account.store(self._on_account_created, None) |
126 | @@ -75,8 +88,12 @@ |
127 | |
128 | def _on_account_created(self, account, error, _): |
129 | if error: |
130 | - self.error = error |
131 | - self._main_loop.quit() |
132 | + self._quit_main_loop_on_error(error, 'storing account') |
133 | + |
134 | + def _quit_main_loop_on_error(self, error, step): |
135 | + logger.error('Error {}.'.format(step)) |
136 | + self.error = error |
137 | + self._main_loop.quit() |
138 | |
139 | def _get_identity_info(self, user_name, password): |
140 | info = Signon.IdentityInfo.new() |
141 | @@ -88,9 +105,10 @@ |
142 | def _set_credentials_id_to_account( |
143 | self, identity, id_, error, account_dict): |
144 | if error: |
145 | - self.error = error |
146 | - self._main_loop.quit() |
147 | + self._quit_main_loop_on_error( |
148 | + error, 'storing credentials with info') |
149 | |
150 | + logger.debug('Setting credentials to account.') |
151 | account = account_dict.get('account') |
152 | oauth_token = account_dict.get('oauth_token') |
153 | account.set_variant('CredentialsId', GLib.Variant('u', id_)) |
154 | @@ -98,9 +116,10 @@ |
155 | |
156 | def _process_session(self, account, error, oauth_token): |
157 | if error: |
158 | - self.error = error |
159 | - self._main_loop.quit() |
160 | + self._quit_main_loop_on_error( |
161 | + error, 'setting credentials id to account') |
162 | |
163 | + logger.debug('Processing session.') |
164 | account_service = Accounts.AccountService.new(account, None) |
165 | auth_data = account_service.get_auth_data() |
166 | identity = auth_data.get_credentials_id() |
167 | @@ -117,15 +136,39 @@ |
168 | |
169 | def _on_login_processed(self, session, reply, error, userdata): |
170 | if error: |
171 | - self.error = error |
172 | + self._quit_main_loop_on_error(error, 'processing session') |
173 | |
174 | - self._main_loop.quit() |
175 | + else: |
176 | + self._main_loop.quit() |
177 | |
178 | def _enable_evernote_service(self, account): |
179 | + logger.debug('Enabling evernote service.') |
180 | service = self._manager.get_service('evernote') |
181 | account.select_service(service) |
182 | account.set_enabled(True) |
183 | - account.store(self._on_account_created, None) |
184 | + account.store(self._on_service_enabled, None) |
185 | + |
186 | + def _on_service_enabled(self, account, error, _): |
187 | + if error: |
188 | + self._quit_main_loop_on_error(error, 'enabling service') |
189 | + |
190 | + def _log_accounts_info(self): |
191 | + account_ids = self._manager.list() |
192 | + logger.debug('Existing accounts: {}.'.format(account_ids)) |
193 | + for id_ in account_ids: |
194 | + account = self._manager.get_account(id_) |
195 | + self._log_account_info(account) |
196 | + |
197 | + def _log_account_info(self, account): |
198 | + logger.debug('Account info:') |
199 | + logger.debug('id: {}'.format(account.id)) |
200 | + logger.debug('provider: {}'.format(account.get_provider_name())) |
201 | + logger.debug('enabled: {}'.format(account.get_enabled())) |
202 | + logger.debug('Account services:') |
203 | + for service in account.list_services(): |
204 | + logger.debug('name: {}'.format(service.get_name())) |
205 | + account_service = Accounts.AccountService.new(account, service) |
206 | + logger.debug('enabled: {}'.format(account_service.get_enabled())) |
207 | |
208 | def delete_account(self, account): |
209 | """Delete an account. |
210 | @@ -133,13 +176,14 @@ |
211 | :param account: The account to delete. |
212 | |
213 | """ |
214 | + logger.info('Deleting the account with id {}.'.format(account.id)) |
215 | self._start_main_loop() |
216 | account.delete() |
217 | account.store(self._on_account_deleted, None) |
218 | self._join_main_loop() |
219 | |
220 | - def _on_account_deleted(self, account, error, userdata): |
221 | + def _on_account_deleted(self, account, error, _): |
222 | if error: |
223 | - self.error = error |
224 | - |
225 | - self._main_loop.quit() |
226 | + self._quit_main_loop_on_error(error, 'deleting account') |
227 | + else: |
228 | + self._main_loop.quit() |
229 | |
230 | === modified file 'tests/autopilot/reminders/evernote.py' |
231 | --- tests/autopilot/reminders/evernote.py 2014-05-15 07:02:41 +0000 |
232 | +++ tests/autopilot/reminders/evernote.py 2014-06-25 23:28:42 +0000 |
233 | @@ -30,6 +30,7 @@ |
234 | |
235 | |
236 | class SandboxEvernoteClient(client.EvernoteClient): |
237 | + |
238 | """Client to access the Evernote API on the sandbox server.""" |
239 | |
240 | def __init__(self): |
241 | |
242 | === modified file 'tests/autopilot/reminders/fake_services.py' |
243 | --- tests/autopilot/reminders/fake_services.py 2014-04-24 19:26:51 +0000 |
244 | +++ tests/autopilot/reminders/fake_services.py 2014-06-25 23:28:42 +0000 |
245 | @@ -25,6 +25,7 @@ |
246 | |
247 | |
248 | class FakeURLDispatcherService(object): |
249 | + |
250 | """Fake URL Dispatcher service using a dbusmock interface.""" |
251 | |
252 | def __init__(self): |
253 | |
254 | === modified file 'tests/autopilot/reminders/tests/__init__.py' |
255 | --- tests/autopilot/reminders/tests/__init__.py 2014-05-23 07:11:23 +0000 |
256 | +++ tests/autopilot/reminders/tests/__init__.py 2014-06-25 23:28:42 +0000 |
257 | @@ -16,14 +16,13 @@ |
258 | |
259 | """Reminders app autopilot tests.""" |
260 | |
261 | +import logging |
262 | import os |
263 | import shutil |
264 | -import logging |
265 | +import subprocess |
266 | |
267 | import fixtures |
268 | from autopilot import logging as autopilot_logging |
269 | -from autopilot.input import Mouse, Touch, Pointer |
270 | -from autopilot.platform import model |
271 | from autopilot.testcase import AutopilotTestCase |
272 | from ubuntuuitoolkit import ( |
273 | emulators as toolkit_emulators, |
274 | @@ -35,14 +34,13 @@ |
275 | logger = logging.getLogger(__name__) |
276 | |
277 | |
278 | -class RemindersAppTestCase(AutopilotTestCase): |
279 | - """A common test case class that provides several useful methods for |
280 | - reminders-app tests.""" |
281 | - |
282 | - if model() == 'Desktop': |
283 | - scenarios = [('with mouse', dict(input_device_class=Mouse))] |
284 | - else: |
285 | - scenarios = [('with touch', dict(input_device_class=Touch))] |
286 | +class BaseTestCaseWithTempHome(AutopilotTestCase): |
287 | + |
288 | + """Base test case that patches the home directory |
289 | + |
290 | + That way we start the tests with a clean environment. |
291 | + |
292 | + """ |
293 | |
294 | local_location = os.path.dirname(os.path.dirname(os.getcwd())) |
295 | |
296 | @@ -52,7 +50,20 @@ |
297 | installed_location_binary = '/usr/bin/reminders' |
298 | installed_location_qml = '/usr/share/reminders/qml/reminders.qml' |
299 | |
300 | - def get_launcher_and_type(self): |
301 | + def setUp(self): |
302 | + self.kill_signond() |
303 | + self.addCleanup(self.kill_signond) |
304 | + super(BaseTestCaseWithTempHome, self).setUp() |
305 | + _, test_type = self.get_launcher_method_and_type() |
306 | + self.home_dir = self._patch_home(test_type) |
307 | + |
308 | + def kill_signond(self): |
309 | + # We kill signond so it's restarted using the temporary HOME. Otherwise |
310 | + # it will remain running until it has 5 seconds of inactivity, keeping |
311 | + # reference to other directories. |
312 | + subprocess.call(['pkill', '-9', 'signond']) |
313 | + |
314 | + def get_launcher_method_and_type(self): |
315 | if os.path.exists(self.local_location_binary): |
316 | launcher = self.launch_test_local |
317 | test_type = 'local' |
318 | @@ -64,40 +75,47 @@ |
319 | test_type = 'click' |
320 | return launcher, test_type |
321 | |
322 | - def setUp(self): |
323 | - launcher, test_type = self.get_launcher_and_type() |
324 | - self.home_dir = self._patch_home(test_type) |
325 | - self.pointing_device = Pointer(self.input_device_class.create()) |
326 | - super(RemindersAppTestCase, self).setUp() |
327 | - |
328 | - self.app = reminders.RemindersApp(launcher()) |
329 | - |
330 | - def _copy_xauthority_file(self, directory): |
331 | - """ Copy .Xauthority file to directory, if it exists in /home |
332 | - """ |
333 | - xauth = os.path.expanduser(os.path.join('~', '.Xauthority')) |
334 | - if os.path.isfile(xauth): |
335 | - logger.debug("Copying .Xauthority to " + directory) |
336 | - shutil.copyfile( |
337 | - os.path.expanduser(os.path.join('~', '.Xauthority')), |
338 | - os.path.join(directory, '.Xauthority')) |
339 | + @autopilot_logging.log_action(logger.info) |
340 | + def launch_test_local(self): |
341 | + self.useFixture(fixtures.EnvironmentVariable( |
342 | + 'QML2_IMPORT_PATH', |
343 | + newvalue=os.path.join(self.local_location, 'src/plugin'))) |
344 | + return self.launch_test_application( |
345 | + self.local_location_binary, |
346 | + '-q', self.local_location_qml, |
347 | + app_type='qt', |
348 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
349 | + |
350 | + @autopilot_logging.log_action(logger.info) |
351 | + def launch_test_installed(self): |
352 | + return self.launch_test_application( |
353 | + self.installed_location_binary, |
354 | + '-q ' + self.installed_location_qml, |
355 | + '--desktop_file_hint=/usr/share/applications/' |
356 | + 'reminders.desktop', |
357 | + app_type='qt', |
358 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
359 | + |
360 | + @autopilot_logging.log_action(logger.info) |
361 | + def launch_test_click(self): |
362 | + return self.launch_click_package( |
363 | + 'com.ubuntu.reminders', |
364 | + emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
365 | |
366 | def _patch_home(self, test_type): |
367 | - """ mock /home for testing purposes to preserve user data |
368 | - """ |
369 | temp_dir_fixture = fixtures.TempDir() |
370 | self.useFixture(temp_dir_fixture) |
371 | temp_dir = temp_dir_fixture.path |
372 | temp_xdg_config_home = os.path.join(temp_dir, '.config') |
373 | |
374 | - #If running under xvfb, as jenkins does, |
375 | - #xsession will fail to start without xauthority file |
376 | - #Thus if the Xauthority file is in the home directory |
377 | - #make sure we copy it to our temp home directory |
378 | + # If running under xvfb, as jenkins does, |
379 | + # xsession will fail to start without xauthority file |
380 | + # Thus if the Xauthority file is in the home directory |
381 | + # make sure we copy it to our temp home directory |
382 | self._copy_xauthority_file(temp_dir) |
383 | |
384 | - #click requires using initctl env (upstart), but the desktop can set |
385 | - #an environment variable instead |
386 | + # click requires using initctl env (upstart), but the desktop can set |
387 | + # an environment variable instead |
388 | if test_type == 'click': |
389 | self.useFixture( |
390 | toolkit_fixtures.InitctlEnvironmentVariable( |
391 | @@ -113,29 +131,22 @@ |
392 | |
393 | return temp_dir |
394 | |
395 | - @autopilot_logging.log_action(logger.info) |
396 | - def launch_test_local(self): |
397 | - self.useFixture(fixtures.EnvironmentVariable( |
398 | - 'QML2_IMPORT_PATH', |
399 | - newvalue=os.path.join(self.local_location, 'src/plugin'))) |
400 | - return self.launch_test_application( |
401 | - self.local_location_binary, |
402 | - '-q', self.local_location_qml, |
403 | - app_type='qt', |
404 | - emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
405 | - |
406 | - @autopilot_logging.log_action(logger.info) |
407 | - def launch_test_installed(self): |
408 | - return self.launch_test_application( |
409 | - self.installed_location_binary, |
410 | - '-q ' + self.installed_location_qml, |
411 | - '--desktop_file_hint=/usr/share/applications/' |
412 | - 'reminders.desktop', |
413 | - app_type='qt', |
414 | - emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
415 | - |
416 | - @autopilot_logging.log_action(logger.info) |
417 | - def launch_test_click(self): |
418 | - return self.launch_click_package( |
419 | - 'com.ubuntu.reminders', |
420 | - emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase) |
421 | + def _copy_xauthority_file(self, directory): |
422 | + """ Copy .Xauthority file to directory, if it exists in /home |
423 | + """ |
424 | + xauth = os.path.expanduser(os.path.join('~', '.Xauthority')) |
425 | + if os.path.isfile(xauth): |
426 | + logger.debug("Copying .Xauthority to " + directory) |
427 | + shutil.copyfile( |
428 | + os.path.expanduser(os.path.join('~', '.Xauthority')), |
429 | + os.path.join(directory, '.Xauthority')) |
430 | + |
431 | + |
432 | +class RemindersAppTestCase(BaseTestCaseWithTempHome): |
433 | + |
434 | + """Base test case that launches the reminders-app.""" |
435 | + |
436 | + def setUp(self): |
437 | + super(RemindersAppTestCase, self).setUp() |
438 | + launcher_method, _ = self.get_launcher_method_and_type() |
439 | + self.app = reminders.RemindersApp(launcher_method()) |
440 | |
441 | === added file 'tests/autopilot/reminders/tests/test_credentials.py' |
442 | --- tests/autopilot/reminders/tests/test_credentials.py 1970-01-01 00:00:00 +0000 |
443 | +++ tests/autopilot/reminders/tests/test_credentials.py 2014-06-25 23:28:42 +0000 |
444 | @@ -0,0 +1,70 @@ |
445 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
446 | +# |
447 | +# Copyright (C) 2014 Canonical Ltd |
448 | +# |
449 | +# This program is free software: you can redistribute it and/or modify |
450 | +# it under the terms of the GNU General Public License version 3 as |
451 | +# published by the Free Software Foundation. |
452 | +# |
453 | +# This program is distributed in the hope that it will be useful, |
454 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
455 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
456 | +# GNU General Public License for more details. |
457 | +# |
458 | +# You should have received a copy of the GNU General Public License |
459 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
460 | + |
461 | +import logging |
462 | + |
463 | +from gi.repository import Accounts |
464 | +from testtools.matchers import HasLength |
465 | + |
466 | +from reminders import credentials, evernote, tests |
467 | + |
468 | + |
469 | +logger = logging.getLogger(__name__) |
470 | + |
471 | + |
472 | +class EvernoteCredentialsTestCase(tests.BaseTestCaseWithTempHome): |
473 | + |
474 | + def setUp(self): |
475 | + super(EvernoteCredentialsTestCase, self).setUp() |
476 | + self.account_manager = credentials.AccountManager() |
477 | + |
478 | + def add_evernote_account(self): |
479 | + account = self.account_manager.add_evernote_account( |
480 | + 'dummy', 'dummy', evernote.TEST_OAUTH_TOKEN) |
481 | + self.addCleanup(self.delete_account_and_manager, account) |
482 | + return account |
483 | + |
484 | + def delete_account_and_manager(self, account): |
485 | + if account.id in self.account_manager._manager.list(): |
486 | + self.account_manager.delete_account(account) |
487 | + del self.account_manager._manager |
488 | + del self.account_manager |
489 | + |
490 | + def test_add_evernote_account_must_enable_it(self): |
491 | + account = self.add_evernote_account() |
492 | + |
493 | + self.assertTrue(account.get_enabled()) |
494 | + |
495 | + def test_add_evernote_account_must_set_provider(self): |
496 | + account = self.add_evernote_account() |
497 | + |
498 | + self.assertEqual(account.get_provider_name(), 'evernote') |
499 | + |
500 | + def test_add_evernote_account_must_enable_evernote_service(self): |
501 | + account = self.add_evernote_account() |
502 | + services = account.list_services() |
503 | + |
504 | + self.assertThat(services, HasLength(1)) |
505 | + self.assertEqual(services[0].get_name(), 'evernote') |
506 | + service = Accounts.AccountService.new(account, services[0]) |
507 | + self.assertTrue(service.get_enabled()) |
508 | + |
509 | + def test_delete_evernote_account_must_remove_it(self): |
510 | + account = self.add_evernote_account() |
511 | + self.assertThat(self.account_manager._manager.list(), HasLength(1)) |
512 | + |
513 | + self.account_manager.delete_account(account) |
514 | + self.assertThat(self.account_manager._manager.list(), HasLength(0)) |
515 | |
516 | === modified file 'tests/autopilot/reminders/tests/test_evernote.py' |
517 | --- tests/autopilot/reminders/tests/test_evernote.py 2014-05-15 07:02:41 +0000 |
518 | +++ tests/autopilot/reminders/tests/test_evernote.py 2014-06-25 23:28:42 +0000 |
519 | @@ -24,6 +24,7 @@ |
520 | |
521 | |
522 | class EvernoteTestCase(testtools.TestCase): |
523 | + |
524 | """Test the evernote access with the SDK.""" |
525 | |
526 | def setUp(self): |
527 | |
528 | === modified file 'tests/autopilot/reminders/tests/test_reminders.py' |
529 | --- tests/autopilot/reminders/tests/test_reminders.py 2014-05-15 07:02:41 +0000 |
530 | +++ tests/autopilot/reminders/tests/test_reminders.py 2014-06-25 23:28:42 +0000 |
531 | @@ -66,6 +66,7 @@ |
532 | super(RemindersTestCaseWithAccount, self).setUp() |
533 | no_account_dialog = self.app.main_view.no_account_dialog |
534 | self.add_evernote_account() |
535 | + logger.info('Waiting for the Evernote account to be created.') |
536 | no_account_dialog.wait_until_destroyed() |
537 | self.evernote_client = evernote.SandboxEvernoteClient() |
538 | |
539 | @@ -93,15 +94,9 @@ |
540 | notebooks_page.add_notebook(test_notebook_title) |
541 | |
542 | last_notebook = notebooks_page.get_notebooks()[-1] |
543 | - # TODO there's a bug with the last updated value: http://pad.lv/1318751 |
544 | - # so we can't check the full tuple. Uncomment this as soon as the bug |
545 | - # is fixed. --elopio - 2014-05-12 |
546 | - #self.assertEqual( |
547 | - # last_notebook, |
548 | - # (test_notebook_title, 'Last edited today', 'Private', 0)) |
549 | - self.assertEqual(last_notebook[0], test_notebook_title) |
550 | - self.assertEqual(last_notebook[2], 'Private') |
551 | - self.assertEqual(last_notebook[3], 0) |
552 | + self.assertEqual( |
553 | + last_notebook, |
554 | + (test_notebook_title, 'Last edited today', 'Private', 0)) |
555 | |
556 | def test_add_notebook_must_create_it_in_server(self): |
557 | """Test that an added notebook will be created on the server.""" |
PASSED: Continuous integration, rev:165 91.189. 93.70:8080/ job/reminders- app-ci/ 390/ 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 604 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 604/artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/reminders- app-utopic- amd64-ci/ 85
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/reminders- app-ci/ 390/rebuild
http://