예제 #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()
예제 #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()
예제 #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()
예제 #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) == ''
예제 #5
0
 def test_basic_token_with_no_secret_raises(self):
     c = Credentials('id')
     with pytest.raises(ValueError):
         c.request_client_token()
예제 #6
0
    def test_bad_arguments_raises_error(self):
        c = Credentials('id', 'secret')

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