File: test_exceptions.py

package info (click to toggle)
python-keycloak 5.7.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,372 kB
  • sloc: python: 14,249; sh: 43; makefile: 28
file content (23 lines) | stat: -rw-r--r-- 629 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Test the exceptions module."""

from unittest.mock import Mock

import pytest

from keycloak.exceptions import KeycloakOperationError, raise_error_from_response


def test_raise_error_from_response_from_dict() -> None:
    """Test raise error from response using a dictionary."""
    response = Mock()
    response.json.return_value = {"key": "value"}
    response.status_code = 408
    response.content = "Error"

    with pytest.raises(KeycloakOperationError):
        raise_error_from_response(
            response=response,
            error={},
            expected_codes=[200],
            skip_exists=False,
        )