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


Python http.HttpMockSequence类代码示例

本文整理汇总了Python中apiclient.http.HttpMockSequence的典型用法代码示例。如果您正苦于以下问题:Python HttpMockSequence类的具体用法?Python HttpMockSequence怎么用?Python HttpMockSequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_assertion_refresh

 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(content["authorization"], "OAuth 1/3w")
开发者ID:cezarexxi,项目名称:google-api-python-client,代码行数:7,代码来源:test_oauth2client.py

示例2: test_auth_header_sent

 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:peter-saltin,项目名称:GoogleApiPython3x,代码行数:7,代码来源:test_oauth2client.py

示例3: test_set_user_agent_nested

    def test_set_user_agent_nested(self):
        http = HttpMockSequence([({"status": "200"}, "echo_request_headers")])

        http = set_user_agent(http, "my_app/5.5")
        http = set_user_agent(http, "my_library/0.1")
        resp, content = http.request("http://example.com")
        self.assertEqual("my_app/5.5 my_library/0.1", content["user-agent"])
开发者ID:eac2192,项目名称:ticket_scalper,代码行数:7,代码来源:test_http.py

示例4: testPost

  def testPost(self):
    request = webapp2.Request.blank("/step1", POST={
      'domain': 'demo-123.resold.richieforeman.net'
    })
    from mock import MagicMock

    http = HttpMockSequence([
      ({'status': '200'}, RESELLER_DISCOVERY),
      ({'status': '200'}, json.dumps({}))
    ])

    # wrap http.request so we can spy on it.
    http.request = MagicMock(wraps=http.request)

    with patch('main.get_authorized_http', return_value=http):
      response = request.get_response(app)

      self.assertTrue(http.request.called)
      discovery_call = http.request.call_args_list[0]
      create_customer = http.request.call_args_list[1]

      # ensure that a discovery call occured.
      (url,), args = discovery_call
      self.assertEqual(url, RESELLER_DISCOVERY_URL)

      # ensure that a customer was created via the POST api.
      (url, method), args = create_customer
      self.assertEqual(url,
                       'https://www.googleapis'
                       '.com/apps/reseller/v1/customers?alt=json')
      self.assertEqual(method, 'POST')
开发者ID:EduardoDuarte,项目名称:enterprise-deployments,代码行数:31,代码来源:handlers_test.py

示例5: test_non_401_error_response

 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:peter-saltin,项目名称:GoogleApiPython3x,代码行数:7,代码来源:test_oauth2client.py

示例6: test_set_user_agent

  def test_set_user_agent(self):
    http = HttpMockSequence([
      ({'status': '200'}, 'echo_request_headers'),
      ])

    http = set_user_agent(http, "my_app/5.5")
    resp, content = http.request("http://example.com")
    self.assertEqual(content['user-agent'], 'my_app/5.5')
开发者ID:GeomancerProject,项目名称:Software,代码行数:8,代码来源:test_http.py

示例7: test_assertion_refresh

 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:peter-saltin,项目名称:GoogleApiPython3x,代码行数:8,代码来源:test_oauth2client.py

示例8: test_token_refresh_failure

 def test_token_refresh_failure(self):
     http = HttpMockSequence([({"status": "401"}, ""), ({"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
开发者ID:cezarexxi,项目名称:google-api-python-client,代码行数:8,代码来源:test_oauth2client.py

示例9: test_add_requestor_to_uri

 def test_add_requestor_to_uri(self):
   http = HttpMockSequence([
     ({'status': '200'}, 'echo_request_uri'),
     ])
   http = self.credentials.authorize(http)
   resp, content = http.request("http://example.com")
   self.assertEqual('http://example.com?xoauth_requestor_id=test%40example.org',
                    content)
开发者ID:Blurjp,项目名称:HuangDaxi,代码行数:8,代码来源:test_oauth.py

示例10: test_token_refresh_success

 def test_token_refresh_success(self):
   http = HttpMockSequence([
     ({'status': '401'}, ''),
     ({'status': '200'}, '{"access_token":"1/3w","expires_in":3600}'),
     ({'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:Blurjp,项目名称:HuangDaxi,代码行数:9,代码来源:test_oauth2client.py

示例11: _credentials_refresh

 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)
   resp, content = http.request('http://example.org')
   return content
开发者ID:fmoga,项目名称:google-api-python-client,代码行数:10,代码来源:test_oauth2client_jwt.py

示例12: test_invalid_token

 def test_invalid_token(self):
   http = HttpMockSequence([
     ({'status': '401'}, ''),
     ])
   http = self.credentials.authorize(http)
   try:
     resp, content = http.request("http://example.com")
     self.fail('should raise CredentialsInvalidError')
   except CredentialsInvalidError:
     pass
开发者ID:Blurjp,项目名称:HuangDaxi,代码行数:10,代码来源:test_oauth.py

示例13: test_token_refresh_success

 def test_token_refresh_success(self):
     http = HttpMockSequence([({"status": "401"}, "")])
     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:cezarexxi,项目名称:google-api-python-client,代码行数:10,代码来源:test_oauth2client.py

示例14: test_set_user_agent_nested

  def test_set_user_agent_nested(self):
    http = HttpMockSequence([
      ({'status': '200'}, 'echo_request_headers'),
      ])

    http = set_user_agent(http, "my_app/5.5")
    http = set_user_agent(http, "my_library/0.1")
    resp, content = http.request("http://example.com")
    content = simplejson.loads(content.decode())
    self.assertEqual('my_app/5.5 my_library/0.1', content['user-agent'])
开发者ID:antholo,项目名称:GoogleApiPython3x,代码行数:10,代码来源:test_http.py

示例15: test_no_requestor

 def test_no_requestor(self):
   self.credentials.requestor = None
   http = HttpMockSequence([
     ({'status': '401'}, ''),
     ])
   http = self.credentials.authorize(http)
   try:
     resp, content = http.request("http://example.com")
     self.fail('should raise MissingParameter')
   except MissingParameter:
     pass
开发者ID:Blurjp,项目名称:HuangDaxi,代码行数:11,代码来源:test_oauth.py


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