当前位置: 首页>>代码示例>>Python>>正文


Python HttpMockSequence.request方法代码示例

本文整理汇总了Python中http_mock.HttpMockSequence.request方法的典型用法代码示例。如果您正苦于以下问题:Python HttpMockSequence.request方法的具体用法?Python HttpMockSequence.request怎么用?Python HttpMockSequence.request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在http_mock.HttpMockSequence的用法示例。


在下文中一共展示了HttpMockSequence.request方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_token_refresh_failure

# 需要导入模块: from http_mock import HttpMockSequence [as 别名]
# 或者: from http_mock.HttpMockSequence import request [as 别名]
 def test_token_refresh_failure(self):
   for status_code in REFRESH_STATUS_CODES:
     http = HttpMockSequence([
       ({'status': status_code}, ''),
       ({'status': '400'}, '{"error":"access_denied"}'),
       ])
     http = self.credentials.authorize(http)
     try:
       http.request('http://example.com')
       self.fail('should raise AccessTokenRefreshError exception')
     except AccessTokenRefreshError:
       pass
     self.assertTrue(self.credentials.access_token_expired)
     self.assertEqual(None, self.credentials.token_response)
开发者ID:Alexander-Attar,项目名称:oauth2client,代码行数:16,代码来源:test_oauth2client.py

示例2: test_auth_header_sent

# 需要导入模块: from http_mock import HttpMockSequence [as 别名]
# 或者: from http_mock.HttpMockSequence import request [as 别名]
 def test_auth_header_sent(self):
   http = HttpMockSequence([
     ({'status': '200'}, 'echo_request_headers'),
     ])
   http = self.credentials.authorize(http)
   resp, content = http.request('http://example.com')
   self.assertEqual('Bearer foo', content['Authorization'])
开发者ID:Alexander-Attar,项目名称:oauth2client,代码行数:9,代码来源:test_oauth2client.py

示例3: test_non_401_error_response

# 需要导入模块: from http_mock import HttpMockSequence [as 别名]
# 或者: from http_mock.HttpMockSequence import request [as 别名]
 def test_non_401_error_response(self):
   http = HttpMockSequence([
     ({'status': '400'}, ''),
     ])
   http = self.credentials.authorize(http)
   resp, content = http.request('http://example.com')
   self.assertEqual(400, resp.status)
开发者ID:Alexander-Attar,项目名称:oauth2client,代码行数:9,代码来源:test_oauth2client.py

示例4: test_assertion_refresh

# 需要导入模块: from http_mock import HttpMockSequence [as 别名]
# 或者: from http_mock.HttpMockSequence import request [as 别名]
 def test_assertion_refresh(self):
   http = HttpMockSequence([
     ({'status': '200'}, '{"access_token":"1/3w"}'),
     ({'status': '200'}, 'echo_request_headers'),
     ])
   http = self.credentials.authorize(http)
   resp, content = http.request('http://example.com')
   self.assertEqual('Bearer 1/3w', content['Authorization'])
开发者ID:Alexander-Attar,项目名称:oauth2client,代码行数:10,代码来源:test_oauth2client.py

示例5: _credentials_refresh

# 需要导入模块: from http_mock import HttpMockSequence [as 别名]
# 或者: from http_mock.HttpMockSequence import request [as 别名]
 def _credentials_refresh(self, credentials):
   http = HttpMockSequence([
       ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),
       ({'status': '401'}, ''),
       ({'status': '200'}, '{"access_token":"3/3w","expires_in":3600}'),
       ({'status': '200'}, 'echo_request_headers'),
   ])
   http = credentials.authorize(http)
   _, content = http.request('http://example.org')
   return content
开发者ID:avivien,项目名称:oauth2client,代码行数:12,代码来源:test_jwt.py

示例6: test_token_refresh_success

# 需要导入模块: from http_mock import HttpMockSequence [as 别名]
# 或者: from http_mock.HttpMockSequence import request [as 别名]
 def test_token_refresh_success(self):
   for status_code in REFRESH_STATUS_CODES:
     http = HttpMockSequence([
       ({'status': status_code}, ''),
       ])
     http = self.credentials.authorize(http)
     try:
       resp, content = http.request('http://example.com')
       self.fail('should throw exception if token expires')
     except AccessTokenCredentialsError:
       pass
     except Exception:
       self.fail('should only throw AccessTokenCredentialsError')
开发者ID:Alexander-Attar,项目名称:oauth2client,代码行数:15,代码来源:test_oauth2client.py

示例7: test_credentials_good

# 需要导入模块: from http_mock import HttpMockSequence [as 别名]
# 或者: from http_mock.HttpMockSequence import request [as 别名]
 def test_credentials_good(self):
   private_key = datafile('privatekey.%s' % self.format)
   credentials = SignedJwtAssertionCredentials(
       '[email protected]',
       private_key,
       scope='read+write',
       sub='[email protected]')
   http = HttpMockSequence([
       ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),
       ({'status': '200'}, 'echo_request_headers'),
   ])
   http = credentials.authorize(http)
   _, content = http.request('http://example.org')
   self.assertEqual('Bearer 1/3w', content['Authorization'])
开发者ID:avivien,项目名称:oauth2client,代码行数:16,代码来源:test_jwt.py


注:本文中的http_mock.HttpMockSequence.request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。