test_urllib3.py 文件源码

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

项目:google-auth-library-python 作者: GoogleCloudPlatform 项目源码 文件源码
def test_urlopen_refresh(self):
        credentials = mock.Mock(wraps=CredentialsStub())
        final_response = ResponseStub(status=http_client.OK)
        # First request will 401, second request will succeed.
        http = HttpStub([
            ResponseStub(status=http_client.UNAUTHORIZED),
            final_response])

        authed_http = google.auth.transport.urllib3.AuthorizedHttp(
            credentials, http=http)

        authed_http = authed_http.urlopen('GET', 'http://example.com')

        assert authed_http == final_response
        assert credentials.before_request.call_count == 2
        assert credentials.refresh.called
        assert http.requests == [
            ('GET', self.TEST_URL, None, {'authorization': 'token'}, {}),
            ('GET', self.TEST_URL, None, {'authorization': 'token1'}, {})]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号