File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 1
1
Changelog
2
2
=========
3
3
4
+ [0.3.3] - Unreleased
5
+ --------------------
6
+
7
+ Added
8
+ ^^^^^
9
+ - :class: `~scim2_client.engines.werkzeug.TestSCIMClient ` raise a
10
+ :class: `~scim2_client.UnexpectedContentFormat ` exception when response is not JSON.
11
+
4
12
[0.3.2] - 2024-11-29
5
13
--------------------
6
14
@@ -32,12 +40,12 @@ Fixed
32
40
Added
33
41
^^^^^
34
42
- The `Unknown resource type ` request error keeps a reference to the faulty payload.
35
- - New ` werkzeug ` request engine for application development purpose.
36
- - New ` AsyncSCIMClient ` request engine. :issue: `1 `
43
+ - New :class: ` ~scim2_client.engines. werkzeug.TestSCIMClient ` request engine for application development purpose.
44
+ - New :class: ` ~scim2_client.engines.httpx. AsyncSCIMClient ` request engine. :issue: `1 `
37
45
38
46
Changed
39
47
^^^^^^^
40
- - Separate httpx network code and SCIM code in separate file as a basis for async support (and maybe other request engines).
48
+ - Separate httpx network code and SCIM code in separate file as a basis for async support (and other request engines).
41
49
42
50
[0.2.2] - 2024-11-12
43
51
--------------------
Original file line number Diff line number Diff line change
1
+ import json
1
2
from contextlib import contextmanager
2
3
from typing import Optional
3
4
from typing import Union
13
14
14
15
from scim2_client .client import BaseSyncSCIMClient
15
16
from scim2_client .errors import SCIMClientError
17
+ from scim2_client .errors import UnexpectedContentFormat
16
18
17
19
18
20
@contextmanager
19
21
def handle_response_error (response ):
20
22
try :
21
23
yield
22
24
25
+ except json .decoder .JSONDecodeError as exc :
26
+ raise UnexpectedContentFormat (source = response ) from exc
27
+
23
28
except SCIMClientError as exc :
24
29
exc .source = response
25
30
raise exc
Original file line number Diff line number Diff line change 2
2
from scim2_models import ResourceType
3
3
from scim2_models import SearchRequest
4
4
from scim2_models import User
5
+ from werkzeug .wrappers import Request
6
+ from werkzeug .wrappers import Response
5
7
6
8
from scim2_client .engines .werkzeug import TestSCIMClient
7
9
from scim2_client .errors import SCIMResponseErrorObject
10
+ from scim2_client .errors import UnexpectedContentFormat
8
11
9
12
scim2_server = pytest .importorskip ("scim2_server" )
10
13
from scim2_server .backend import InMemoryBackend # noqa: E402
@@ -61,3 +64,15 @@ def test_werkzeug_engine(scim_client):
61
64
scim_client .delete (User , response_user .id )
62
65
with pytest .raises (SCIMResponseErrorObject ):
63
66
scim_client .query (User , response_user .id )
67
+
68
+
69
+ def test_no_json ():
70
+ """Test that pages that do not return JSON raise an UnexpectedContentFormat error."""
71
+
72
+ @Request .application
73
+ def application (request ):
74
+ return Response ("Hello, World!" , content_type = "application/scim+json" )
75
+
76
+ client = TestSCIMClient (app = application , resource_models = (User ,))
77
+ with pytest .raises (UnexpectedContentFormat ):
78
+ client .query (url = "/" )
You can’t perform that action at this time.
0 commit comments