Skip to content

Commit 3119fe5

Browse files
committed
feat: raise_scim_errors is True by default
1 parent fc5e2c9 commit 3119fe5

File tree

8 files changed

+26
-18
lines changed

8 files changed

+26
-18
lines changed

doc/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Added
88
^^^^^
99
- Replace :code:`check_status_code` parameter by :code:`expected_status_codes`.
1010

11+
Changed
12+
^^^^^^^
13+
- :code:`raise_scim_errors` is :data:`True` by default.
14+
1115
[0.1.11] - 2024-08-31
1216
---------------------
1317

doc/tutorial.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ However sometimes you want to accept invalid inputs and outputs.
6363
To achieve this, all the methods provide the following parameters, all are :data:`True` by default:
6464

6565
- :code:`check_request_payload`:
66-
If :data:`True` a :class:`~pydantic.ValidationError` will be raised if the input does not respect the SCIM standard.
66+
If :data:`True` (the default) a :class:`~pydantic.ValidationError` will be raised if the input does not respect the SCIM standard.
6767
If :data:`False`, input is expected to be a :data:`dict` that will be passed as-is in the request.
6868
- :code:`check_response_payload`:
69-
If :data:`True` a :class:`~pydantic.ValidationError` will be raised if the server response does not respect the SCIM standard.
69+
If :data:`True` (the default) a :class:`~pydantic.ValidationError` will be raised if the server response does not respect the SCIM standard.
7070
If :data:`False` the server response is returned as-is.
7171
- :code:`expected_status_codes`: The list of expected status codes in the response.
7272
If :data:`None` any status code is accepted.
7373
If an unexpected status code is returned, a :class:`~scim2_client.errors.UnexpectedStatusCode` exception is raised.
74-
- :code:`raise_scim_errors`: If :data:`True` and the server returned an :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject` exception will be raised.
74+
- :code:`raise_scim_errors`: If :data:`True` (the default) and the server returned an :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject` exception will be raised.
7575
If :data:`False` the error object is returned.
7676

7777

scim2_client/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def check_response(
163163
expected_status_codes: List[int],
164164
expected_types: Optional[Type] = None,
165165
check_response_payload: bool = True,
166-
raise_scim_errors: bool = False,
166+
raise_scim_errors: bool = True,
167167
scim_ctx: Optional[Context] = None,
168168
):
169169
if expected_status_codes and response.status_code not in expected_status_codes:
@@ -241,7 +241,7 @@ def create(
241241
check_request_payload: bool = True,
242242
check_response_payload: bool = True,
243243
expected_status_codes: Optional[List[int]] = CREATION_RESPONSE_STATUS_CODES,
244-
raise_scim_errors: bool = False,
244+
raise_scim_errors: bool = True,
245245
**kwargs,
246246
) -> Union[AnyResource, Error, Dict]:
247247
"""Perform a POST request to create, as defined in :rfc:`RFC7644 §3.3
@@ -334,7 +334,7 @@ def query(
334334
check_request_payload: bool = True,
335335
check_response_payload: bool = True,
336336
expected_status_codes: Optional[List[int]] = QUERY_RESPONSE_STATUS_CODES,
337-
raise_scim_errors: bool = False,
337+
raise_scim_errors: bool = True,
338338
**kwargs,
339339
) -> Union[AnyResource, ListResponse[AnyResource], Error, Dict]:
340340
"""Perform a GET request to read resources, as defined in :rfc:`RFC7644
@@ -460,7 +460,7 @@ def search(
460460
check_request_payload: bool = True,
461461
check_response_payload: bool = True,
462462
expected_status_codes: Optional[List[int]] = SEARCH_RESPONSE_STATUS_CODES,
463-
raise_scim_errors: bool = False,
463+
raise_scim_errors: bool = True,
464464
**kwargs,
465465
) -> Union[AnyResource, ListResponse[AnyResource], Error, Dict]:
466466
"""Perform a POST search request to read all available resources, as
@@ -540,7 +540,7 @@ def delete(
540540
id: str,
541541
check_response_payload: bool = True,
542542
expected_status_codes: Optional[List[int]] = DELETION_RESPONSE_STATUS_CODES,
543-
raise_scim_errors: bool = False,
543+
raise_scim_errors: bool = True,
544544
**kwargs,
545545
) -> Optional[Union[Error, Dict]]:
546546
"""Perform a DELETE request to create, as defined in :rfc:`RFC7644 §3.6
@@ -597,7 +597,7 @@ def replace(
597597
check_request_payload: bool = True,
598598
check_response_payload: bool = True,
599599
expected_status_codes: Optional[List[int]] = REPLACEMENT_RESPONSE_STATUS_CODES,
600-
raise_scim_errors: bool = False,
600+
raise_scim_errors: bool = True,
601601
**kwargs,
602602
) -> Union[AnyResource, Error, Dict]:
603603
"""Perform a PUT request to replace a resource, as defined in

tests/test_create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_conflict(httpserver):
211211

212212
client = Client(base_url=f"http://localhost:{httpserver.port}")
213213
scim_client = SCIMClient(client, resource_types=(User,))
214-
response = scim_client.create(user_request)
214+
response = scim_client.create(user_request, raise_scim_errors=False)
215215
assert response == Error(
216216
schemas=["urn:ietf:params:scim:api:messages:2.0:Error"],
217217
status=409,
@@ -264,7 +264,7 @@ def test_errors(httpserver, code):
264264

265265
client = Client(base_url=f"http://localhost:{httpserver.port}")
266266
scim_client = SCIMClient(client, resource_types=(User,))
267-
response = scim_client.create(user_request)
267+
response = scim_client.create(user_request, raise_scim_errors=False)
268268

269269
assert response == Error(
270270
schemas=["urn:ietf:params:scim:api:messages:2.0:Error"],

tests/test_delete.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def test_errors(httpserver, code):
3737

3838
client = Client(base_url=f"http://localhost:{httpserver.port}")
3939
scim_client = SCIMClient(client, resource_types=(User,))
40-
response = scim_client.delete(User, "2819c223-7f76-453a-919d-413861904646")
40+
response = scim_client.delete(
41+
User, "2819c223-7f76-453a-919d-413861904646", raise_scim_errors=False
42+
)
4143

4244
assert response == Error(
4345
schemas=["urn:ietf:params:scim:api:messages:2.0:Error"],

tests/test_query.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ def test_user_with_valid_id(client):
292292
Group,
293293
),
294294
)
295-
response = scim_client.query(User, "2819c223-7f76-453a-919d-413861904646")
295+
response = scim_client.query(
296+
User, "2819c223-7f76-453a-919d-413861904646", raise_scim_errors=False
297+
)
296298
assert response == User(
297299
id="2819c223-7f76-453a-919d-413861904646",
298300
user_name="[email protected]",
@@ -320,7 +322,7 @@ def test_user_with_invalid_id(client):
320322
Group,
321323
),
322324
)
323-
response = scim_client.query(User, "unknown")
325+
response = scim_client.query(User, "unknown", raise_scim_errors=False)
324326
assert response == Error(detail="Resource unknown not found", status=404)
325327

326328

@@ -434,7 +436,7 @@ def test_bad_request(client):
434436
Group,
435437
),
436438
)
437-
response = scim_client.query(User, "bad-request")
439+
response = scim_client.query(User, "bad-request", raise_scim_errors=False)
438440
assert response == Error(status=400, detail="Bad request")
439441

440442

@@ -446,7 +448,7 @@ class Foobar(Resource):
446448
pass
447449

448450
scim_client = SCIMClient(client, resource_types=(Foobar,))
449-
response = scim_client.query(Foobar)
451+
response = scim_client.query(Foobar, raise_scim_errors=False)
450452
assert response == Error(status=404, detail="Invalid Resource")
451453

452454

tests/test_replace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def test_errors(httpserver, code):
246246

247247
client = Client(base_url=f"http://localhost:{httpserver.port}")
248248
scim_client = SCIMClient(client, resource_types=(User,))
249-
response = scim_client.replace(user_request)
249+
response = scim_client.replace(user_request, raise_scim_errors=False)
250250

251251
assert response == Error(
252252
schemas=["urn:ietf:params:scim:api:messages:2.0:Error"],

tests/test_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def test_errors(httpserver, code):
238238
Group,
239239
),
240240
)
241-
response = scim_client.search()
241+
response = scim_client.search(raise_scim_errors=False)
242242

243243
assert response == Error(
244244
schemas=["urn:ietf:params:scim:api:messages:2.0:Error"],

0 commit comments

Comments
 (0)