Exemplo n.º 1
0
 def test_it_returns_error_description(self, pyramid_request):
     context = OAuthTokenError("error description", "error_type")
     result = views.api_token_error(context, pyramid_request)
     assert result["error_description"] == "error description"
Exemplo n.º 2
0
 def test_it_skips_description_when_empty(self, pyramid_request):
     context = OAuthTokenError("", "invalid_request")
     result = views.api_token_error(context, pyramid_request)
     assert "error_description" not in result
Exemplo n.º 3
0
 def test_it_sets_the_response_status_code(self, pyramid_request):
     context = OAuthTokenError("the error message", "error_type")
     views.api_token_error(context, pyramid_request)
     assert pyramid_request.response.status_code == 401
Exemplo n.º 4
0
 def test_it_returns_the_error(self, pyramid_request):
     context = OAuthTokenError("", "error_type")
     result = views.api_token_error(context, pyramid_request)
     assert result["error"] == "error_type"
Exemplo n.º 5
0
 def test_it_returns_error_description(self, pyramid_request):
     context = OAuthTokenError("error description", "error_type")
     result = views.api_token_error(context, pyramid_request)
     assert result["error_description"] == "error description"
Exemplo n.º 6
0
 def test_it_skips_description_when_empty(self, pyramid_request):
     context = OAuthTokenError("", "invalid_request")
     result = views.api_token_error(context, pyramid_request)
     assert "error_description" not in result
Exemplo n.º 7
0
 def test_it_returns_the_error(self, pyramid_request):
     context = OAuthTokenError("", "error_type")
     result = views.api_token_error(context, pyramid_request)
     assert result["error"] == "error_type"
Exemplo n.º 8
0
 def test_it_sets_the_response_status_code(self, pyramid_request):
     context = OAuthTokenError("the error message", "error_type")
     views.api_token_error(context, pyramid_request)
     assert pyramid_request.response.status_code == 401
Exemplo n.º 9
0
 def test_it_skips_description_when_missing(self, pyramid_request):
     context = OAuthTokenError(None, 'invalid_request')
     result = views.api_token_error(context, pyramid_request)
     assert 'error_description' not in result
Exemplo n.º 10
0
 def test_it_returns_error_description(self, pyramid_request):
     context = OAuthTokenError('error description', 'error_type')
     result = views.api_token_error(context, pyramid_request)
     assert result['error_description'] == 'error description'
Exemplo n.º 11
0
 def test_it_returns_the_error(self, pyramid_request):
     context = OAuthTokenError('', 'error_type')
     result = views.api_token_error(context, pyramid_request)
     assert result['error'] == 'error_type'