Merge lp:~nskaggs/reminders-app/fix-1381828 into lp:reminders-app

Proposed by Nicholas Skaggs
Status: Merged
Approved by: David Planella
Approved revision: 284
Merged at revision: 280
Proposed branch: lp:~nskaggs/reminders-app/fix-1381828
Merge into: lp:reminders-app
Diff against target: 93 lines (+31/-1)
1 file modified
tests/autopilot/reminders/credentials.py (+31/-1)
To merge this branch: bzr merge lp:~nskaggs/reminders-app/fix-1381828
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Ubuntu Notes app developers Pending
Review via email: mp+238519@code.launchpad.net

Commit message

Fix tests never finishing because of a failure to setup an account.

Description of the change

Fix tests never finishing because of a failure to setup an account. This also adds lots of debug prints as the online account setup has prone to be quite fragile. The debug prints should hopefully be useful in the future should further issues appear.

To post a comment you must log in.
280. By Nicholas Skaggs

fix mispelling

281. By Nicholas Skaggs

cleanup method check

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)
282. By Nicholas Skaggs

add account cleanup during errors

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
283. By Nicholas Skaggs

flake8 happiness

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

undo pot file changes

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
Leo Arias (elopio) :
review: Approve
Revision history for this message
David Planella (dpm) wrote :

Top-approving as per Leo's +1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/reminders/credentials.py'
2--- tests/autopilot/reminders/credentials.py 2014-10-01 11:38:52 +0000
3+++ tests/autopilot/reminders/credentials.py 2014-10-16 02:50:19 +0000
4@@ -46,7 +46,7 @@
5 def _join_main_loop(self):
6 self._main_loop_thread.join()
7 if self.error is not None:
8- raise CredentialsException(self.error.message)
9+ raise CredentialsException(self.error)
10
11 def add_evernote_account(self, user_name, password, oauth_token):
12 """Add an evernote account.
13@@ -60,6 +60,11 @@
14 self._start_main_loop()
15
16 account = self._create_account()
17+ logger.debug('account %s' % account.get_settings_dict())
18+
19+ if not account.get_settings_dict():
20+ self._delete_account_on_error(account)
21+ self._quit_main_loop_on_error('account is blank', 'add account')
22
23 info = self._get_identity_info(user_name, password)
24
25@@ -67,6 +72,9 @@
26 identity.store_credentials_with_info(
27 info, self._set_credentials_id_to_account,
28 {'account': account, 'oauth_token': oauth_token})
29+ logger.debug('identity %s' % identity.list_properties())
30+
31+ logger.debug('Joining loop')
32
33 self._join_main_loop()
34
35@@ -91,10 +99,21 @@
36 if error:
37 self._quit_main_loop_on_error(error, 'storing account')
38
39+ def _delete_account_on_error(self, account):
40+ # attempt to clean up after ourselves, since normal
41+ # addCleanups will not run in this case
42+ try:
43+ logger.debug('Cleaning up account %s' % account.id)
44+ account.delete()
45+ account.store(self._on_account_deleted, None)
46+ except:
47+ logger.warn('Failed to cleanup account')
48+
49 def _quit_main_loop_on_error(self, error, step):
50 logger.error('Error {}.'.format(step))
51 self.error = error
52 self._main_loop.quit()
53+ raise CredentialsException(error)
54
55 def _get_identity_info(self, user_name, password):
56 info = Signon.IdentityInfo.new()
57@@ -114,6 +133,7 @@
58 oauth_token = account_dict.get('oauth_token')
59 account.set_variant('CredentialsId', GLib.Variant('u', id_))
60 account.store(self._process_session, oauth_token)
61+ logger.debug('Account stored')
62
63 def _process_session(self, account, error, oauth_token):
64 if error:
65@@ -122,18 +142,28 @@
66
67 logger.debug('Processing session.')
68 account_service = Accounts.AccountService.new(account, None)
69+ logger.debug('account_service %s' % account_service.list_properties())
70 auth_data = account_service.get_auth_data()
71+ logger.debug('auth_data %s' % auth_data.get_parameters())
72 identity = auth_data.get_credentials_id()
73 method = auth_data.get_method()
74+ if method is None:
75+ self._delete_account_on_error(account)
76+ self._quit_main_loop_on_error('Method is none',
77+ 'processing auth data')
78 mechanism = auth_data.get_mechanism()
79 session_data = auth_data.get_parameters()
80 session_data['ProvidedTokens'] = GLib.Variant('a{sv}', {
81 'TokenSecret': GLib.Variant('s', 'dummy'),
82 'AccessToken': GLib.Variant('s', oauth_token),
83 })
84+ logger.debug('session_data %s' % session_data)
85+ logger.debug('Authenticating session %s, %s' % (identity, method))
86 session = Signon.AuthSession.new(identity, method)
87+ logger.debug('Send session %s' % session)
88 session.process(
89 session_data, mechanism, self._on_login_processed, None)
90+ logger.debug('Session processed')
91
92 def _on_login_processed(self, session, reply, error, userdata):
93 if error:

Subscribers

People subscribed via source and target branches