Beispiel #1
0
 def test_client_error_without_description(self):
     c = Credentials('id', 'secret')
     error = {'error': 'Bad thing'}
     response = mock_response(400, error)
     c.send = MagicMock(return_value=response)
     with pytest.raises(HTTPError):
         c.request_client_token()
Beispiel #2
0
 def test_server_error_raises_http_error(self):
     c = Credentials('id', 'secret')
     response = mock_response(500, {})
     c.send = MagicMock(return_value=response)
     with pytest.raises(HTTPError):
         c.request_client_token()
     c.close()
Beispiel #3
0
 def test_auto_refresh_client_token(self):
     c = Credentials('id', 'secret')
     token = make_token({'refresh_token': None})
     c.request_client_token = MagicMock(return_value=token)
     c.refresh(token)
     c.request_client_token.assert_called_once()
     c.close()
Beispiel #4
0
 def test_request_client_token(self, app_env):
     c = Credentials(app_env[0], app_env[1])
     token = c.request_client_token()
     assert token.refresh_token is None
     assert str(token.scope) == ''
Beispiel #5
0
 def test_basic_token_with_no_secret_raises(self):
     c = Credentials('id')
     with pytest.raises(ValueError):
         c.request_client_token()
Beispiel #6
0
    def test_bad_arguments_raises_error(self):
        c = Credentials('id', 'secret')

        with pytest.raises(HTTPError):
            c.request_client_token()