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