You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
588 B

  1. """Test the exceptions module."""
  2. from unittest.mock import Mock
  3. import pytest
  4. from keycloak.exceptions import KeycloakOperationError, raise_error_from_response
  5. def test_raise_error_from_response_from_dict():
  6. """Test raise error from response using a dictionary."""
  7. response = Mock()
  8. response.json.return_value = {"key": "value"}
  9. response.status_code = 408
  10. response.content = "Error"
  11. with pytest.raises(KeycloakOperationError):
  12. raise_error_from_response(
  13. response=response, error=dict(), expected_codes=[200], skip_exists=False
  14. )