Exemplo n.º 1
0
 def test_access_token_bad_response_code(self):
     responses.add(responses.POST,
                   self.base_url + '/oauth2/access_token',
                   status=500,
                   json={})
     client = OAuthAPIClient(self.base_url, self.client_id, self.client_secret)
     with self.assertRaises(requests.HTTPError):
         client._ensure_authentication()  # pylint: disable=protected-access
Exemplo n.º 2
0
    def test_access_token_request_timeout_wiring2(self, mock_access_token_post):
        mock_access_token_post.return_value.json.return_value = {'access_token': 'token', 'expires_in': 1000}

        timeout_override = (6.1, 2)
        client = OAuthAPIClient(self.base_url, self.client_id, self.client_secret, timeout=timeout_override)
        client._ensure_authentication()  # pylint: disable=protected-access

        assert mock_access_token_post.call_args.kwargs['timeout'] == timeout_override
Exemplo n.º 3
0
    def test_access_token_invalid_json_response(self):
        responses.add(responses.POST,
                      self.base_url + '/oauth2/access_token',
                      status=200,
                      body="Not JSON")
        client = OAuthAPIClient(self.base_url, self.client_id, self.client_secret)

        with self.assertRaises(requests.RequestException):
            client._ensure_authentication()  # pylint: disable=protected-access