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 11Changelog
22=========
33
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+
412[0.3.2] - 2024-11-29
513--------------------
614
@@ -32,12 +40,12 @@ Fixed
3240Added
3341^^^^^
3442- 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 `
3745
3846Changed
3947^^^^^^^
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).
4149
4250[0.2.2] - 2024-11-12
4351--------------------
Original file line number Diff line number Diff line change 1+ import json
12from contextlib import contextmanager
23from typing import Optional
34from typing import Union
1314
1415from scim2_client .client import BaseSyncSCIMClient
1516from scim2_client .errors import SCIMClientError
17+ from scim2_client .errors import UnexpectedContentFormat
1618
1719
1820@contextmanager
1921def handle_response_error (response ):
2022 try :
2123 yield
2224
25+ except json .decoder .JSONDecodeError as exc :
26+ raise UnexpectedContentFormat (source = response ) from exc
27+
2328 except SCIMClientError as exc :
2429 exc .source = response
2530 raise exc
Original file line number Diff line number Diff line change 22from scim2_models import ResourceType
33from scim2_models import SearchRequest
44from scim2_models import User
5+ from werkzeug .wrappers import Request
6+ from werkzeug .wrappers import Response
57
68from scim2_client .engines .werkzeug import TestSCIMClient
79from scim2_client .errors import SCIMResponseErrorObject
10+ from scim2_client .errors import UnexpectedContentFormat
811
912scim2_server = pytest .importorskip ("scim2_server" )
1013from scim2_server .backend import InMemoryBackend # noqa: E402
@@ -61,3 +64,15 @@ def test_werkzeug_engine(scim_client):
6164 scim_client .delete (User , response_user .id )
6265 with pytest .raises (SCIMResponseErrorObject ):
6366 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