Beispiel #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"
Beispiel #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
Beispiel #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
Beispiel #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"
Beispiel #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"
Beispiel #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
Beispiel #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"
Beispiel #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
Beispiel #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
Beispiel #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'
Beispiel #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'