Skip to content

Commit e2dbe76

Browse files
committed
fix: error and critical check results directly raise an exception when raise_exceptions=True
1 parent af6cb95 commit e2dbe76

18 files changed

+182
-194
lines changed

doc/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
[0.2.3] - Unreleased
5+
--------------------
6+
7+
Fixed
8+
^^^^^
9+
- Error and critical check results directly raise an exception when ``raise_exceptions=True``.
10+
411
[0.2.2] - 2025-08-13
512
--------------------
613

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ requires-python = ">= 3.10"
2828
dependencies = [
2929
"scim2-client>=0.6.1",
3030
"scim2-models>=0.4.2",
31-
"exceptiongroup>=1.0.0 ; python_full_version < '3.11'",
3231
]
3332

3433
[project.urls]

scim2_tester/checkers/_discovery_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ..utils import CheckContext
66
from ..utils import CheckResult
77
from ..utils import Status
8+
from ..utils import check_result
89

910

1011
def _test_discovery_endpoint_methods(
@@ -36,23 +37,26 @@ def _test_discovery_endpoint_methods(
3637
)
3738
if response.status_code == 405:
3839
results.append(
39-
CheckResult(
40+
check_result(
41+
context,
4042
status=Status.SUCCESS,
4143
reason=f"{method} {endpoint} correctly returned 405 Method Not Allowed",
4244
data=response,
4345
)
4446
)
4547
else:
4648
results.append(
47-
CheckResult(
49+
check_result(
50+
context,
4851
status=Status.ERROR,
4952
reason=f"{method} {endpoint} returned {response.status_code} instead of 405",
5053
data=response,
5154
)
5255
)
5356
except SCIMClientError as e:
5457
results.append(
55-
CheckResult(
58+
check_result(
59+
context,
5660
status=Status.ERROR,
5761
reason=f"{method} {endpoint} failed: {str(e)}",
5862
)

scim2_tester/checkers/misc.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ..utils import CheckContext
77
from ..utils import CheckResult
88
from ..utils import Status
9+
from ..utils import check_result
910
from ..utils import checker
1011

1112

@@ -38,7 +39,8 @@ def random_url(context: CheckContext) -> list[CheckResult]:
3839

3940
if not isinstance(response, Error):
4041
return [
41-
CheckResult(
42+
check_result(
43+
context,
4244
status=Status.ERROR,
4345
reason=f"{probably_invalid_url} did not return an Error object",
4446
data=response,
@@ -47,15 +49,17 @@ def random_url(context: CheckContext) -> list[CheckResult]:
4749

4850
if response.status != 404:
4951
return [
50-
CheckResult(
52+
check_result(
53+
context,
5154
status=Status.ERROR,
5255
reason=f"{probably_invalid_url} did return an object, but the status code is {response.status}",
5356
data=response,
5457
)
5558
]
5659

5760
return [
58-
CheckResult(
61+
check_result(
62+
context,
5963
status=Status.SUCCESS,
6064
reason=f"{probably_invalid_url} correctly returned a 404 error",
6165
data=response,

scim2_tester/checkers/patch_add.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from ..utils import CheckContext
1717
from ..utils import CheckResult
1818
from ..utils import Status
19+
from ..utils import check_result
1920
from ..utils import checker
2021
from ..utils import compare_field
2122

@@ -50,7 +51,8 @@ def check_add_attribute(
5051
and not context.client.service_provider_config.patch.supported
5152
):
5253
return [
53-
CheckResult(
54+
check_result(
55+
context,
5456
status=Status.SKIPPED,
5557
reason="PATCH operations not supported by server",
5658
resource_type=model.__name__,
@@ -74,7 +76,8 @@ def check_add_attribute(
7476

7577
if not all_urns:
7678
return [
77-
CheckResult(
79+
check_result(
80+
context,
7881
status=Status.SKIPPED,
7982
reason=f"No addable attributes found for {model.__name__}",
8083
resource_type=model.__name__,
@@ -105,7 +108,8 @@ def check_add_attribute(
105108
)
106109
except SCIMClientError as exc:
107110
results.append(
108-
CheckResult(
111+
check_result(
112+
context,
109113
status=Status.ERROR,
110114
reason=f"Failed to add attribute '{urn}': {exc}",
111115
resource_type=model.__name__,
@@ -125,7 +129,8 @@ def check_add_attribute(
125129
or compare_field(patch_value, modify_actual_value)
126130
):
127131
results.append(
128-
CheckResult(
132+
check_result(
133+
context,
129134
status=Status.ERROR,
130135
reason=f"PATCH modify() returned incorrect value for '{urn}'",
131136
resource_type=model.__name__,
@@ -145,7 +150,8 @@ def check_add_attribute(
145150
)
146151
except SCIMClientError as exc:
147152
results.append(
148-
CheckResult(
153+
check_result(
154+
context,
149155
status=Status.ERROR,
150156
reason=f"Failed to query resource after add on '{urn}': {exc}",
151157
resource_type=model.__name__,
@@ -164,7 +170,8 @@ def check_add_attribute(
164170
patch_value, actual_value
165171
):
166172
results.append(
167-
CheckResult(
173+
check_result(
174+
context,
168175
status=Status.SUCCESS,
169176
reason=f"Successfully added attribute '{urn}'",
170177
resource_type=model.__name__,
@@ -176,7 +183,8 @@ def check_add_attribute(
176183
)
177184
else:
178185
results.append(
179-
CheckResult(
186+
check_result(
187+
context,
180188
status=Status.ERROR,
181189
reason=f"Attribute '{urn}' was not added or has incorrect value",
182190
resource_type=model.__name__,

scim2_tester/checkers/patch_remove.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ..utils import CheckContext
1616
from ..utils import CheckResult
1717
from ..utils import Status
18+
from ..utils import check_result
1819
from ..utils import checker
1920

2021

@@ -49,7 +50,8 @@ def check_remove_attribute(
4950
and not context.client.service_provider_config.patch.supported
5051
):
5152
return [
52-
CheckResult(
53+
check_result(
54+
context,
5355
status=Status.SKIPPED,
5456
reason="PATCH operations not supported by server",
5557
resource_type=model.__name__,
@@ -69,7 +71,8 @@ def check_remove_attribute(
6971

7072
if not all_urns:
7173
return [
72-
CheckResult(
74+
check_result(
75+
context,
7376
status=Status.SKIPPED,
7477
reason=f"No removable attributes found for {model.__name__}",
7578
resource_type=model.__name__,
@@ -101,7 +104,8 @@ def check_remove_attribute(
101104
)
102105
except SCIMClientError as exc:
103106
results.append(
104-
CheckResult(
107+
check_result(
108+
context,
105109
status=Status.ERROR,
106110
reason=f"Failed to remove attribute '{urn}': {exc}",
107111
resource_type=model.__name__,
@@ -121,7 +125,8 @@ def check_remove_attribute(
121125
and modify_actual_value is not None
122126
):
123127
results.append(
124-
CheckResult(
128+
check_result(
129+
context,
125130
status=Status.ERROR,
126131
reason=f"PATCH modify() did not remove attribute '{urn}'",
127132
resource_type=model.__name__,
@@ -141,7 +146,8 @@ def check_remove_attribute(
141146
)
142147
except SCIMClientError as exc:
143148
results.append(
144-
CheckResult(
149+
check_result(
150+
context,
145151
status=Status.ERROR,
146152
reason=f"Failed to query resource after remove on '{urn}': {exc}",
147153
resource_type=model.__name__,
@@ -157,7 +163,8 @@ def check_remove_attribute(
157163
actual_value = get_value_by_urn(updated_resource, urn)
158164
if mutability == Mutability.write_only or actual_value is None:
159165
results.append(
160-
CheckResult(
166+
check_result(
167+
context,
161168
status=Status.SUCCESS,
162169
reason=f"Successfully removed attribute '{urn}'",
163170
resource_type=model.__name__,
@@ -169,7 +176,8 @@ def check_remove_attribute(
169176
)
170177
else:
171178
results.append(
172-
CheckResult(
179+
check_result(
180+
context,
173181
status=Status.ERROR,
174182
reason=f"Attribute '{urn}' was not removed",
175183
resource_type=model.__name__,

scim2_tester/checkers/patch_replace.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ..utils import CheckContext
1616
from ..utils import CheckResult
1717
from ..utils import Status
18+
from ..utils import check_result
1819
from ..utils import checker
1920
from ..utils import compare_field
2021

@@ -49,7 +50,8 @@ def check_replace_attribute(
4950
and not context.client.service_provider_config.patch.supported
5051
):
5152
return [
52-
CheckResult(
53+
check_result(
54+
context,
5355
status=Status.SKIPPED,
5456
reason="PATCH operations not supported by server",
5557
resource_type=model.__name__,
@@ -68,7 +70,8 @@ def check_replace_attribute(
6870

6971
if not all_urns:
7072
return [
71-
CheckResult(
73+
check_result(
74+
context,
7275
status=Status.SKIPPED,
7376
reason=f"No replaceable attributes found for {model.__name__}",
7477
resource_type=model.__name__,
@@ -99,7 +102,8 @@ def check_replace_attribute(
99102
)
100103
except SCIMClientError as exc:
101104
results.append(
102-
CheckResult(
105+
check_result(
106+
context,
103107
status=Status.ERROR,
104108
reason=f"Failed to replace attribute '{urn}': {exc}",
105109
resource_type=model.__name__,
@@ -119,7 +123,8 @@ def check_replace_attribute(
119123
or compare_field(patch_value, modify_actual_value)
120124
):
121125
results.append(
122-
CheckResult(
126+
check_result(
127+
context,
123128
status=Status.ERROR,
124129
reason=f"PATCH modify() returned incorrect value for '{urn}'",
125130
resource_type=model.__name__,
@@ -139,7 +144,8 @@ def check_replace_attribute(
139144
)
140145
except SCIMClientError as exc:
141146
results.append(
142-
CheckResult(
147+
check_result(
148+
context,
143149
status=Status.ERROR,
144150
reason=f"Failed to query resource after replace on '{urn}': {exc}",
145151
resource_type=model.__name__,
@@ -157,7 +163,8 @@ def check_replace_attribute(
157163
patch_value, actual_value
158164
):
159165
results.append(
160-
CheckResult(
166+
check_result(
167+
context,
161168
status=Status.SUCCESS,
162169
reason=f"Successfully replaced attribute '{urn}'",
163170
resource_type=model.__name__,
@@ -169,7 +176,8 @@ def check_replace_attribute(
169176
)
170177
else:
171178
results.append(
172-
CheckResult(
179+
check_result(
180+
context,
173181
status=Status.ERROR,
174182
reason=f"Attribute '{urn}' was not replaced or has incorrect value",
175183
resource_type=model.__name__,

scim2_tester/checkers/resource.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from ..utils import CheckContext
44
from ..utils import CheckResult
55
from ..utils import Status
6+
from ..utils import check_result
67
from .patch_add import check_add_attribute
78
from .patch_remove import check_remove_attribute
89
from .patch_replace import check_replace_attribute
@@ -38,7 +39,8 @@ def resource_type_tests(
3839
model = _model_from_resource_type(context, resource_type)
3940
if not model:
4041
return [
41-
CheckResult(
42+
check_result(
43+
context,
4244
status=Status.ERROR,
4345
reason=f"No Schema matching the ResourceType {resource_type.id}",
4446
)

scim2_tester/checkers/resource_delete.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ..utils import CheckContext
77
from ..utils import CheckResult
88
from ..utils import Status
9+
from ..utils import check_result
910
from ..utils import checker
1011

1112

@@ -43,7 +44,8 @@ def object_deletion(
4344
try:
4445
context.client.query(model, test_obj.id)
4546
return [
46-
CheckResult(
47+
check_result(
48+
context,
4749
status=Status.ERROR,
4850
reason=f"{model.__name__} object with id {test_obj.id} still exists after deletion",
4951
)
@@ -52,7 +54,8 @@ def object_deletion(
5254
pass
5355

5456
return [
55-
CheckResult(
57+
check_result(
58+
context,
5659
status=Status.SUCCESS,
5760
reason=f"Successfully deleted {model.__name__} object with id {test_obj.id}",
5861
)

0 commit comments

Comments
 (0)