Skip to content

Commit 94966a9

Browse files
committed
fix: improve patch operation error messages
1 parent c765a49 commit 94966a9

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

scim2_tester/checkers/patch_add.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ def check_add_attribute(
132132
check_result(
133133
context,
134134
status=Status.ERROR,
135-
reason=f"PATCH modify() returned incorrect value for '{urn}'",
135+
reason=(
136+
f"PATCH modify() returned unexpected value for '{urn}'.\n"
137+
f"Patched value: {patch_value}\n"
138+
f"Returned value: {modify_actual_value}"
139+
),
136140
resource_type=model.__name__,
137141
data={
138142
"urn": urn,
@@ -186,7 +190,11 @@ def check_add_attribute(
186190
check_result(
187191
context,
188192
status=Status.ERROR,
189-
reason=f"Attribute '{urn}' was not added or has incorrect value",
193+
reason=(
194+
f"Attribute '{urn}' was not added or has unexpected value"
195+
f"Patched value: {patch_value}\n"
196+
f"Returned value: {actual_value}"
197+
),
190198
resource_type=model.__name__,
191199
data={
192200
"urn": urn,

scim2_tester/checkers/patch_replace.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ def check_replace_attribute(
126126
check_result(
127127
context,
128128
status=Status.ERROR,
129-
reason=f"PATCH modify() returned incorrect value for '{urn}'",
129+
reason=(
130+
f"PATCH modify() returned unexpected value for '{urn}'.\n"
131+
f"Patched value: {patch_value}\n"
132+
f"Returned value: {modify_actual_value}"
133+
),
130134
resource_type=model.__name__,
131135
data={
132136
"urn": urn,
@@ -179,7 +183,11 @@ def check_replace_attribute(
179183
check_result(
180184
context,
181185
status=Status.ERROR,
182-
reason=f"Attribute '{urn}' was not replaced or has incorrect value",
186+
reason=(
187+
f"Attribute '{urn}' was not replaced or has unexpected value"
188+
f"Patched value: {patch_value}\n"
189+
f"Returned value: {actual_value}"
190+
),
183191
resource_type=model.__name__,
184192
data={
185193
"urn": urn,

tests/test_patch_add.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ def test_patch_add_modify_result_incorrect_value(testing_context):
363363
results = check_add_attribute(testing_context, User)
364364

365365
error_results = [
366-
r for r in results if r.status == Status.ERROR and "incorrect value" in r.reason
366+
r
367+
for r in results
368+
if r.status == Status.ERROR and "unexpected value" in r.reason
367369
]
368370
assert len(error_results) > 0
369371

@@ -405,7 +407,7 @@ def test_patch_add_query_failure_after_patch(httpserver, testing_context):
405407
r
406408
for r in results
407409
if r.status == Status.ERROR
408-
and "was not added or has incorrect value" in r.reason
410+
and "was not added or has unexpected value" in r.reason
409411
]
410412
assert len(error_results) > 0
411413

0 commit comments

Comments
 (0)