api_tests.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:sndlatr 作者: Schibum 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号