Merge lp:~elopio/reminders-app/fix_with_account into lp:reminders-app

Proposed by Leo Arias
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
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.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

This still fails on the desktop for me.. no account created :-(

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
170. By Leo Arias

Added account logging.

171. By Leo Arias

Also log the account id.

172. By Leo Arias

Updated the assertion, that was failing pep8 anyway.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
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.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
180. By Leo Arias

Use the fake home fixture from the toolkit.

181. By Leo Arias

Kill signond with -9,

182. By Leo Arias

Fixed flake.

183. By Leo Arias

Kill signond with subprocess.call

184. By Leo Arias

Added the sleep.

185. By Leo Arias

Reverted the json file.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

These greatly improves things, though still has some interesting behaviours that can be observed running the tests.

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
186. By Leo Arias

Reverted the patch home.

187. By Leo Arias

Merged with prerequisite.

188. By Leo Arias

Reverted manifest.json change.

189. By Leo Arias

Fixed comments.

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'manifest.json'
--- manifest.json 2014-05-16 08:53:45 +0000
+++ manifest.json 2014-06-25 23:28:42 +0000
@@ -12,10 +12,10 @@
12 "maintainer": "Ubuntu Reminders app developers <ubuntu-phone@lists.launchpad.net>",12 "maintainer": "Ubuntu Reminders app developers <ubuntu-phone@lists.launchpad.net>",
13 "name": "com.ubuntu.reminders",13 "name": "com.ubuntu.reminders",
14 "title": "Reminders",14 "title": "Reminders",
15 "version": "0.5.@BZR_REVNO@",15 "version": "0.5.185",
16 "x-source": {16 "x-source": {
17 "vcs-bzr": "lp:reminders-app",17 "vcs-bzr": "lp:reminders-app",
18 "vcs-bzr-revno": "@BZR_REVNO@"18 "vcs-bzr-revno": "185"
19 },19 },
20 "x-test": {20 "x-test": {
21 "autopilot": "reminders"21 "autopilot": "reminders"
2222
=== modified file 'tests/autopilot/reminders/__init__.py'
--- tests/autopilot/reminders/__init__.py 2014-06-24 00:01:51 +0000
+++ tests/autopilot/reminders/__init__.py 2014-06-25 23:28:42 +0000
@@ -33,10 +33,12 @@
3333
3434
35class RemindersAppException(Exception):35class RemindersAppException(Exception):
36
36 """Exception raised when there's an error in the Reminders App."""37 """Exception raised when there's an error in the Reminders App."""
3738
3839
39class RemindersApp(object):40class RemindersApp(object):
41
40 """Autopilot helper object for the Reminders application."""42 """Autopilot helper object for the Reminders application."""
4143
42 def __init__(self, app_proxy):44 def __init__(self, app_proxy):
@@ -55,6 +57,7 @@
5557
5658
57class MainView(toolkit_emulators.MainView):59class MainView(toolkit_emulators.MainView):
60
58 """Autopilot custom proxy object for the MainView."""61 """Autopilot custom proxy object for the MainView."""
5962
60 def __init__(self, *args):63 def __init__(self, *args):
@@ -76,6 +79,7 @@
7679
7780
78class NoAccountDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase):81class NoAccountDialog(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
82
79 """Autopilot custom proxy object for the no account dialog."""83 """Autopilot custom proxy object for the no account dialog."""
8084
81 @classmethod85 @classmethod
@@ -110,10 +114,12 @@
110114
111115
112class PulldownListView(ubuntuuitoolkit.QQuickListView):116class PulldownListView(ubuntuuitoolkit.QQuickListView):
117
113 """Autopilot custom proxy object for the PulldownListView."""118 """Autopilot custom proxy object for the PulldownListView."""
114119
115120
116class NotebooksPage(_Page):121class NotebooksPage(_Page):
122
117 """Autopilot custom proxy object for the Notebooks page."""123 """Autopilot custom proxy object for the Notebooks page."""
118124
119 def add_notebook(self, title):125 def add_notebook(self, title):
@@ -164,6 +170,7 @@
164170
165171
166class NotebooksDelegate(toolkit_emulators.UbuntuUIToolkitEmulatorBase):172class NotebooksDelegate(toolkit_emulators.UbuntuUIToolkitEmulatorBase):
173
167 """Autopilot custom proxy object for the NotebooksDelegate."""174 """Autopilot custom proxy object for the NotebooksDelegate."""
168175
169 def get_title(self):176 def get_title(self):
170177
=== modified file 'tests/autopilot/reminders/credentials.py'
--- tests/autopilot/reminders/credentials.py 2014-05-14 16:18:22 +0000
+++ tests/autopilot/reminders/credentials.py 2014-06-25 23:28:42 +0000
@@ -14,17 +14,23 @@
14# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
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/>.
1616
1717import logging
18import time
18import threading19import threading
1920
20from gi.repository import Accounts, GLib, Signon21from gi.repository import Accounts, GLib, Signon
2122
2223
24logger = logging.getLogger(__name__)
25
26
23class CredentialsException(Exception):27class CredentialsException(Exception):
28
24 """Exception for credentials problems."""29 """Exception for credentials problems."""
2530
2631
27class AccountManager(object):32class AccountManager(object):
33
28 """Manager for online accounts."""34 """Manager for online accounts."""
2935
30 def __init__(self):36 def __init__(self):
@@ -50,6 +56,7 @@
50 :param oauth_token: The oauth token of the account.56 :param oauth_token: The oauth token of the account.
5157
52 """58 """
59 logger.debug('Add an evernote account.')
53 self._start_main_loop()60 self._start_main_loop()
5461
55 account = self._create_account()62 account = self._create_account()
@@ -63,11 +70,17 @@
6370
64 self._join_main_loop()71 self._join_main_loop()
6572
73 # XXX Sometimes, the account fails to be enabled. This sleep seems to
74 # fix it but we haven't yet found the reason. --elopio - 2014-06-25
75 time.sleep(10)
66 self._enable_evernote_service(account)76 self._enable_evernote_service(account)
6777
78 logger.info('Created the account with id: {}.'.format(account.id))
79 self._log_accounts_info()
68 return account80 return account
6981
70 def _create_account(self):82 def _create_account(self):
83 logger.debug('Creating the Evernote account.')
71 account = self._manager.create_account('evernote')84 account = self._manager.create_account('evernote')
72 account.set_enabled(True)85 account.set_enabled(True)
73 account.store(self._on_account_created, None)86 account.store(self._on_account_created, None)
@@ -75,8 +88,12 @@
7588
76 def _on_account_created(self, account, error, _):89 def _on_account_created(self, account, error, _):
77 if error:90 if error:
78 self.error = error91 self._quit_main_loop_on_error(error, 'storing account')
79 self._main_loop.quit()92
93 def _quit_main_loop_on_error(self, error, step):
94 logger.error('Error {}.'.format(step))
95 self.error = error
96 self._main_loop.quit()
8097
81 def _get_identity_info(self, user_name, password):98 def _get_identity_info(self, user_name, password):
82 info = Signon.IdentityInfo.new()99 info = Signon.IdentityInfo.new()
@@ -88,9 +105,10 @@
88 def _set_credentials_id_to_account(105 def _set_credentials_id_to_account(
89 self, identity, id_, error, account_dict):106 self, identity, id_, error, account_dict):
90 if error:107 if error:
91 self.error = error108 self._quit_main_loop_on_error(
92 self._main_loop.quit()109 error, 'storing credentials with info')
93110
111 logger.debug('Setting credentials to account.')
94 account = account_dict.get('account')112 account = account_dict.get('account')
95 oauth_token = account_dict.get('oauth_token')113 oauth_token = account_dict.get('oauth_token')
96 account.set_variant('CredentialsId', GLib.Variant('u', id_))114 account.set_variant('CredentialsId', GLib.Variant('u', id_))
@@ -98,9 +116,10 @@
98116
99 def _process_session(self, account, error, oauth_token):117 def _process_session(self, account, error, oauth_token):
100 if error:118 if error:
101 self.error = error119 self._quit_main_loop_on_error(
102 self._main_loop.quit()120 error, 'setting credentials id to account')
103121
122 logger.debug('Processing session.')
104 account_service = Accounts.AccountService.new(account, None)123 account_service = Accounts.AccountService.new(account, None)
105 auth_data = account_service.get_auth_data()124 auth_data = account_service.get_auth_data()
106 identity = auth_data.get_credentials_id()125 identity = auth_data.get_credentials_id()
@@ -117,15 +136,39 @@
117136
118 def _on_login_processed(self, session, reply, error, userdata):137 def _on_login_processed(self, session, reply, error, userdata):
119 if error:138 if error:
120 self.error = error139 self._quit_main_loop_on_error(error, 'processing session')
121140
122 self._main_loop.quit()141 else:
142 self._main_loop.quit()
123143
124 def _enable_evernote_service(self, account):144 def _enable_evernote_service(self, account):
145 logger.debug('Enabling evernote service.')
125 service = self._manager.get_service('evernote')146 service = self._manager.get_service('evernote')
126 account.select_service(service)147 account.select_service(service)
127 account.set_enabled(True)148 account.set_enabled(True)
128 account.store(self._on_account_created, None)149 account.store(self._on_service_enabled, None)
150
151 def _on_service_enabled(self, account, error, _):
152 if error:
153 self._quit_main_loop_on_error(error, 'enabling service')
154
155 def _log_accounts_info(self):
156 account_ids = self._manager.list()
157 logger.debug('Existing accounts: {}.'.format(account_ids))
158 for id_ in account_ids:
159 account = self._manager.get_account(id_)
160 self._log_account_info(account)
161
162 def _log_account_info(self, account):
163 logger.debug('Account info:')
164 logger.debug('id: {}'.format(account.id))
165 logger.debug('provider: {}'.format(account.get_provider_name()))
166 logger.debug('enabled: {}'.format(account.get_enabled()))
167 logger.debug('Account services:')
168 for service in account.list_services():
169 logger.debug('name: {}'.format(service.get_name()))
170 account_service = Accounts.AccountService.new(account, service)
171 logger.debug('enabled: {}'.format(account_service.get_enabled()))
129172
130 def delete_account(self, account):173 def delete_account(self, account):
131 """Delete an account.174 """Delete an account.
@@ -133,13 +176,14 @@
133 :param account: The account to delete.176 :param account: The account to delete.
134177
135 """178 """
179 logger.info('Deleting the account with id {}.'.format(account.id))
136 self._start_main_loop()180 self._start_main_loop()
137 account.delete()181 account.delete()
138 account.store(self._on_account_deleted, None)182 account.store(self._on_account_deleted, None)
139 self._join_main_loop()183 self._join_main_loop()
140184
141 def _on_account_deleted(self, account, error, userdata):185 def _on_account_deleted(self, account, error, _):
142 if error:186 if error:
143 self.error = error187 self._quit_main_loop_on_error(error, 'deleting account')
144188 else:
145 self._main_loop.quit()189 self._main_loop.quit()
146190
=== modified file 'tests/autopilot/reminders/evernote.py'
--- tests/autopilot/reminders/evernote.py 2014-05-15 07:02:41 +0000
+++ tests/autopilot/reminders/evernote.py 2014-06-25 23:28:42 +0000
@@ -30,6 +30,7 @@
3030
3131
32class SandboxEvernoteClient(client.EvernoteClient):32class SandboxEvernoteClient(client.EvernoteClient):
33
33 """Client to access the Evernote API on the sandbox server."""34 """Client to access the Evernote API on the sandbox server."""
3435
35 def __init__(self):36 def __init__(self):
3637
=== modified file 'tests/autopilot/reminders/fake_services.py'
--- tests/autopilot/reminders/fake_services.py 2014-04-24 19:26:51 +0000
+++ tests/autopilot/reminders/fake_services.py 2014-06-25 23:28:42 +0000
@@ -25,6 +25,7 @@
2525
2626
27class FakeURLDispatcherService(object):27class FakeURLDispatcherService(object):
28
28 """Fake URL Dispatcher service using a dbusmock interface."""29 """Fake URL Dispatcher service using a dbusmock interface."""
2930
30 def __init__(self):31 def __init__(self):
3132
=== modified file 'tests/autopilot/reminders/tests/__init__.py'
--- tests/autopilot/reminders/tests/__init__.py 2014-05-23 07:11:23 +0000
+++ tests/autopilot/reminders/tests/__init__.py 2014-06-25 23:28:42 +0000
@@ -16,14 +16,13 @@
1616
17"""Reminders app autopilot tests."""17"""Reminders app autopilot tests."""
1818
19import logging
19import os20import os
20import shutil21import shutil
21import logging22import subprocess
2223
23import fixtures24import fixtures
24from autopilot import logging as autopilot_logging25from autopilot import logging as autopilot_logging
25from autopilot.input import Mouse, Touch, Pointer
26from autopilot.platform import model
27from autopilot.testcase import AutopilotTestCase26from autopilot.testcase import AutopilotTestCase
28from ubuntuuitoolkit import (27from ubuntuuitoolkit import (
29 emulators as toolkit_emulators,28 emulators as toolkit_emulators,
@@ -35,14 +34,13 @@
35logger = logging.getLogger(__name__)34logger = logging.getLogger(__name__)
3635
3736
38class RemindersAppTestCase(AutopilotTestCase):37class BaseTestCaseWithTempHome(AutopilotTestCase):
39 """A common test case class that provides several useful methods for38
40 reminders-app tests."""39 """Base test case that patches the home directory
4140
42 if model() == 'Desktop':41 That way we start the tests with a clean environment.
43 scenarios = [('with mouse', dict(input_device_class=Mouse))]42
44 else:43 """
45 scenarios = [('with touch', dict(input_device_class=Touch))]
4644
47 local_location = os.path.dirname(os.path.dirname(os.getcwd()))45 local_location = os.path.dirname(os.path.dirname(os.getcwd()))
4846
@@ -52,7 +50,20 @@
52 installed_location_binary = '/usr/bin/reminders'50 installed_location_binary = '/usr/bin/reminders'
53 installed_location_qml = '/usr/share/reminders/qml/reminders.qml'51 installed_location_qml = '/usr/share/reminders/qml/reminders.qml'
5452
55 def get_launcher_and_type(self):53 def setUp(self):
54 self.kill_signond()
55 self.addCleanup(self.kill_signond)
56 super(BaseTestCaseWithTempHome, self).setUp()
57 _, test_type = self.get_launcher_method_and_type()
58 self.home_dir = self._patch_home(test_type)
59
60 def kill_signond(self):
61 # We kill signond so it's restarted using the temporary HOME. Otherwise
62 # it will remain running until it has 5 seconds of inactivity, keeping
63 # reference to other directories.
64 subprocess.call(['pkill', '-9', 'signond'])
65
66 def get_launcher_method_and_type(self):
56 if os.path.exists(self.local_location_binary):67 if os.path.exists(self.local_location_binary):
57 launcher = self.launch_test_local68 launcher = self.launch_test_local
58 test_type = 'local'69 test_type = 'local'
@@ -64,40 +75,47 @@
64 test_type = 'click'75 test_type = 'click'
65 return launcher, test_type76 return launcher, test_type
6677
67 def setUp(self):78 @autopilot_logging.log_action(logger.info)
68 launcher, test_type = self.get_launcher_and_type()79 def launch_test_local(self):
69 self.home_dir = self._patch_home(test_type)80 self.useFixture(fixtures.EnvironmentVariable(
70 self.pointing_device = Pointer(self.input_device_class.create())81 'QML2_IMPORT_PATH',
71 super(RemindersAppTestCase, self).setUp()82 newvalue=os.path.join(self.local_location, 'src/plugin')))
7283 return self.launch_test_application(
73 self.app = reminders.RemindersApp(launcher())84 self.local_location_binary,
7485 '-q', self.local_location_qml,
75 def _copy_xauthority_file(self, directory):86 app_type='qt',
76 """ Copy .Xauthority file to directory, if it exists in /home87 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
77 """88
78 xauth = os.path.expanduser(os.path.join('~', '.Xauthority'))89 @autopilot_logging.log_action(logger.info)
79 if os.path.isfile(xauth):90 def launch_test_installed(self):
80 logger.debug("Copying .Xauthority to " + directory)91 return self.launch_test_application(
81 shutil.copyfile(92 self.installed_location_binary,
82 os.path.expanduser(os.path.join('~', '.Xauthority')),93 '-q ' + self.installed_location_qml,
83 os.path.join(directory, '.Xauthority'))94 '--desktop_file_hint=/usr/share/applications/'
95 'reminders.desktop',
96 app_type='qt',
97 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
98
99 @autopilot_logging.log_action(logger.info)
100 def launch_test_click(self):
101 return self.launch_click_package(
102 'com.ubuntu.reminders',
103 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
84104
85 def _patch_home(self, test_type):105 def _patch_home(self, test_type):
86 """ mock /home for testing purposes to preserve user data
87 """
88 temp_dir_fixture = fixtures.TempDir()106 temp_dir_fixture = fixtures.TempDir()
89 self.useFixture(temp_dir_fixture)107 self.useFixture(temp_dir_fixture)
90 temp_dir = temp_dir_fixture.path108 temp_dir = temp_dir_fixture.path
91 temp_xdg_config_home = os.path.join(temp_dir, '.config')109 temp_xdg_config_home = os.path.join(temp_dir, '.config')
92110
93 #If running under xvfb, as jenkins does,111 # If running under xvfb, as jenkins does,
94 #xsession will fail to start without xauthority file112 # xsession will fail to start without xauthority file
95 #Thus if the Xauthority file is in the home directory113 # Thus if the Xauthority file is in the home directory
96 #make sure we copy it to our temp home directory114 # make sure we copy it to our temp home directory
97 self._copy_xauthority_file(temp_dir)115 self._copy_xauthority_file(temp_dir)
98116
99 #click requires using initctl env (upstart), but the desktop can set117 # click requires using initctl env (upstart), but the desktop can set
100 #an environment variable instead118 # an environment variable instead
101 if test_type == 'click':119 if test_type == 'click':
102 self.useFixture(120 self.useFixture(
103 toolkit_fixtures.InitctlEnvironmentVariable(121 toolkit_fixtures.InitctlEnvironmentVariable(
@@ -113,29 +131,22 @@
113131
114 return temp_dir132 return temp_dir
115133
116 @autopilot_logging.log_action(logger.info)134 def _copy_xauthority_file(self, directory):
117 def launch_test_local(self):135 """ Copy .Xauthority file to directory, if it exists in /home
118 self.useFixture(fixtures.EnvironmentVariable(136 """
119 'QML2_IMPORT_PATH',137 xauth = os.path.expanduser(os.path.join('~', '.Xauthority'))
120 newvalue=os.path.join(self.local_location, 'src/plugin')))138 if os.path.isfile(xauth):
121 return self.launch_test_application(139 logger.debug("Copying .Xauthority to " + directory)
122 self.local_location_binary,140 shutil.copyfile(
123 '-q', self.local_location_qml,141 os.path.expanduser(os.path.join('~', '.Xauthority')),
124 app_type='qt',142 os.path.join(directory, '.Xauthority'))
125 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)143
126144
127 @autopilot_logging.log_action(logger.info)145class RemindersAppTestCase(BaseTestCaseWithTempHome):
128 def launch_test_installed(self):146
129 return self.launch_test_application(147 """Base test case that launches the reminders-app."""
130 self.installed_location_binary,148
131 '-q ' + self.installed_location_qml,149 def setUp(self):
132 '--desktop_file_hint=/usr/share/applications/'150 super(RemindersAppTestCase, self).setUp()
133 'reminders.desktop',151 launcher_method, _ = self.get_launcher_method_and_type()
134 app_type='qt',152 self.app = reminders.RemindersApp(launcher_method())
135 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
136
137 @autopilot_logging.log_action(logger.info)
138 def launch_test_click(self):
139 return self.launch_click_package(
140 'com.ubuntu.reminders',
141 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
142153
=== added file 'tests/autopilot/reminders/tests/test_credentials.py'
--- tests/autopilot/reminders/tests/test_credentials.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/reminders/tests/test_credentials.py 2014-06-25 23:28:42 +0000
@@ -0,0 +1,70 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import logging
18
19from gi.repository import Accounts
20from testtools.matchers import HasLength
21
22from reminders import credentials, evernote, tests
23
24
25logger = logging.getLogger(__name__)
26
27
28class EvernoteCredentialsTestCase(tests.BaseTestCaseWithTempHome):
29
30 def setUp(self):
31 super(EvernoteCredentialsTestCase, self).setUp()
32 self.account_manager = credentials.AccountManager()
33
34 def add_evernote_account(self):
35 account = self.account_manager.add_evernote_account(
36 'dummy', 'dummy', evernote.TEST_OAUTH_TOKEN)
37 self.addCleanup(self.delete_account_and_manager, account)
38 return account
39
40 def delete_account_and_manager(self, account):
41 if account.id in self.account_manager._manager.list():
42 self.account_manager.delete_account(account)
43 del self.account_manager._manager
44 del self.account_manager
45
46 def test_add_evernote_account_must_enable_it(self):
47 account = self.add_evernote_account()
48
49 self.assertTrue(account.get_enabled())
50
51 def test_add_evernote_account_must_set_provider(self):
52 account = self.add_evernote_account()
53
54 self.assertEqual(account.get_provider_name(), 'evernote')
55
56 def test_add_evernote_account_must_enable_evernote_service(self):
57 account = self.add_evernote_account()
58 services = account.list_services()
59
60 self.assertThat(services, HasLength(1))
61 self.assertEqual(services[0].get_name(), 'evernote')
62 service = Accounts.AccountService.new(account, services[0])
63 self.assertTrue(service.get_enabled())
64
65 def test_delete_evernote_account_must_remove_it(self):
66 account = self.add_evernote_account()
67 self.assertThat(self.account_manager._manager.list(), HasLength(1))
68
69 self.account_manager.delete_account(account)
70 self.assertThat(self.account_manager._manager.list(), HasLength(0))
071
=== modified file 'tests/autopilot/reminders/tests/test_evernote.py'
--- tests/autopilot/reminders/tests/test_evernote.py 2014-05-15 07:02:41 +0000
+++ tests/autopilot/reminders/tests/test_evernote.py 2014-06-25 23:28:42 +0000
@@ -24,6 +24,7 @@
2424
2525
26class EvernoteTestCase(testtools.TestCase):26class EvernoteTestCase(testtools.TestCase):
27
27 """Test the evernote access with the SDK."""28 """Test the evernote access with the SDK."""
2829
29 def setUp(self):30 def setUp(self):
3031
=== modified file 'tests/autopilot/reminders/tests/test_reminders.py'
--- tests/autopilot/reminders/tests/test_reminders.py 2014-05-15 07:02:41 +0000
+++ tests/autopilot/reminders/tests/test_reminders.py 2014-06-25 23:28:42 +0000
@@ -66,6 +66,7 @@
66 super(RemindersTestCaseWithAccount, self).setUp()66 super(RemindersTestCaseWithAccount, self).setUp()
67 no_account_dialog = self.app.main_view.no_account_dialog67 no_account_dialog = self.app.main_view.no_account_dialog
68 self.add_evernote_account()68 self.add_evernote_account()
69 logger.info('Waiting for the Evernote account to be created.')
69 no_account_dialog.wait_until_destroyed()70 no_account_dialog.wait_until_destroyed()
70 self.evernote_client = evernote.SandboxEvernoteClient()71 self.evernote_client = evernote.SandboxEvernoteClient()
7172
@@ -93,15 +94,9 @@
93 notebooks_page.add_notebook(test_notebook_title)94 notebooks_page.add_notebook(test_notebook_title)
9495
95 last_notebook = notebooks_page.get_notebooks()[-1]96 last_notebook = notebooks_page.get_notebooks()[-1]
96 # TODO there's a bug with the last updated value: http://pad.lv/131875197 self.assertEqual(
97 # so we can't check the full tuple. Uncomment this as soon as the bug98 last_notebook,
98 # is fixed. --elopio - 2014-05-1299 (test_notebook_title, 'Last edited today', 'Private', 0))
99 #self.assertEqual(
100 # last_notebook,
101 # (test_notebook_title, 'Last edited today', 'Private', 0))
102 self.assertEqual(last_notebook[0], test_notebook_title)
103 self.assertEqual(last_notebook[2], 'Private')
104 self.assertEqual(last_notebook[3], 0)
105100
106 def test_add_notebook_must_create_it_in_server(self):101 def test_add_notebook_must_create_it_in_server(self):
107 """Test that an added notebook will be created on the server."""102 """Test that an added notebook will be created on the server."""

Subscribers

People subscribed via source and target branches