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
=== modified file 'tests/autopilot/reminders/credentials.py'
--- tests/autopilot/reminders/credentials.py 2014-10-01 11:38:52 +0000
+++ tests/autopilot/reminders/credentials.py 2014-10-16 02:50:19 +0000
@@ -46,7 +46,7 @@
46 def _join_main_loop(self):46 def _join_main_loop(self):
47 self._main_loop_thread.join()47 self._main_loop_thread.join()
48 if self.error is not None:48 if self.error is not None:
49 raise CredentialsException(self.error.message)49 raise CredentialsException(self.error)
5050
51 def add_evernote_account(self, user_name, password, oauth_token):51 def add_evernote_account(self, user_name, password, oauth_token):
52 """Add an evernote account.52 """Add an evernote account.
@@ -60,6 +60,11 @@
60 self._start_main_loop()60 self._start_main_loop()
6161
62 account = self._create_account()62 account = self._create_account()
63 logger.debug('account %s' % account.get_settings_dict())
64
65 if not account.get_settings_dict():
66 self._delete_account_on_error(account)
67 self._quit_main_loop_on_error('account is blank', 'add account')
6368
64 info = self._get_identity_info(user_name, password)69 info = self._get_identity_info(user_name, password)
6570
@@ -67,6 +72,9 @@
67 identity.store_credentials_with_info(72 identity.store_credentials_with_info(
68 info, self._set_credentials_id_to_account,73 info, self._set_credentials_id_to_account,
69 {'account': account, 'oauth_token': oauth_token})74 {'account': account, 'oauth_token': oauth_token})
75 logger.debug('identity %s' % identity.list_properties())
76
77 logger.debug('Joining loop')
7078
71 self._join_main_loop()79 self._join_main_loop()
7280
@@ -91,10 +99,21 @@
91 if error:99 if error:
92 self._quit_main_loop_on_error(error, 'storing account')100 self._quit_main_loop_on_error(error, 'storing account')
93101
102 def _delete_account_on_error(self, account):
103 # attempt to clean up after ourselves, since normal
104 # addCleanups will not run in this case
105 try:
106 logger.debug('Cleaning up account %s' % account.id)
107 account.delete()
108 account.store(self._on_account_deleted, None)
109 except:
110 logger.warn('Failed to cleanup account')
111
94 def _quit_main_loop_on_error(self, error, step):112 def _quit_main_loop_on_error(self, error, step):
95 logger.error('Error {}.'.format(step))113 logger.error('Error {}.'.format(step))
96 self.error = error114 self.error = error
97 self._main_loop.quit()115 self._main_loop.quit()
116 raise CredentialsException(error)
98117
99 def _get_identity_info(self, user_name, password):118 def _get_identity_info(self, user_name, password):
100 info = Signon.IdentityInfo.new()119 info = Signon.IdentityInfo.new()
@@ -114,6 +133,7 @@
114 oauth_token = account_dict.get('oauth_token')133 oauth_token = account_dict.get('oauth_token')
115 account.set_variant('CredentialsId', GLib.Variant('u', id_))134 account.set_variant('CredentialsId', GLib.Variant('u', id_))
116 account.store(self._process_session, oauth_token)135 account.store(self._process_session, oauth_token)
136 logger.debug('Account stored')
117137
118 def _process_session(self, account, error, oauth_token):138 def _process_session(self, account, error, oauth_token):
119 if error:139 if error:
@@ -122,18 +142,28 @@
122142
123 logger.debug('Processing session.')143 logger.debug('Processing session.')
124 account_service = Accounts.AccountService.new(account, None)144 account_service = Accounts.AccountService.new(account, None)
145 logger.debug('account_service %s' % account_service.list_properties())
125 auth_data = account_service.get_auth_data()146 auth_data = account_service.get_auth_data()
147 logger.debug('auth_data %s' % auth_data.get_parameters())
126 identity = auth_data.get_credentials_id()148 identity = auth_data.get_credentials_id()
127 method = auth_data.get_method()149 method = auth_data.get_method()
150 if method is None:
151 self._delete_account_on_error(account)
152 self._quit_main_loop_on_error('Method is none',
153 'processing auth data')
128 mechanism = auth_data.get_mechanism()154 mechanism = auth_data.get_mechanism()
129 session_data = auth_data.get_parameters()155 session_data = auth_data.get_parameters()
130 session_data['ProvidedTokens'] = GLib.Variant('a{sv}', {156 session_data['ProvidedTokens'] = GLib.Variant('a{sv}', {
131 'TokenSecret': GLib.Variant('s', 'dummy'),157 'TokenSecret': GLib.Variant('s', 'dummy'),
132 'AccessToken': GLib.Variant('s', oauth_token),158 'AccessToken': GLib.Variant('s', oauth_token),
133 })159 })
160 logger.debug('session_data %s' % session_data)
161 logger.debug('Authenticating session %s, %s' % (identity, method))
134 session = Signon.AuthSession.new(identity, method)162 session = Signon.AuthSession.new(identity, method)
163 logger.debug('Send session %s' % session)
135 session.process(164 session.process(
136 session_data, mechanism, self._on_login_processed, None)165 session_data, mechanism, self._on_login_processed, None)
166 logger.debug('Session processed')
137167
138 def _on_login_processed(self, session, reply, error, userdata):168 def _on_login_processed(self, session, reply, error, userdata):
139 if error:169 if error:

Subscribers

People subscribed via source and target branches