def test_refresh_failure(self):
"""
Failure to refresh the access token should be treated as auth error.
"""
def raise_invalid_grant(*args, **kwargs):
raise AccessTokenRefreshError()
with mock.patch('sndlatr.models.get_credentials') as getter, \
self.notify_mock() as notify:
cred = mock.MagicMock(spec=OAuth2Credentials)
getter.return_value = cred
cred.refresh.side_effect = raise_invalid_grant
job = self.create_job(error_cnt=self.JOB_MAX_RETRIES)
resp = self._post_send(job)
self.assertEquals(resp.status_int, 200)
notify.assert_called_with(job, 'auth')
评论列表
文章目录