Skip to content

Commit 4b48f97

Browse files
committed
chore: improve CheckResult repr
don't include descriptions, as they can be quite long
1 parent 6234e6d commit 4b48f97

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

scim2_tester/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ class CheckResult:
149149
resource_type: str | None = None
150150
"""The resource type name if this check is related to a specific resource."""
151151

152+
def __repr__(self):
153+
"""Return string representation without verbose description field."""
154+
parts = [f"CheckResult(status={self.status!r}"]
155+
if self.title:
156+
parts.append(f"title={self.title!r}")
157+
if self.reason:
158+
parts.append(f"reason={self.reason!r}")
159+
if self.data is not None:
160+
parts.append(f"data={self.data!r}")
161+
if self.tags:
162+
parts.append(f"tags={self.tags!r}")
163+
if self.resource_type:
164+
parts.append(f"resource_type={self.resource_type!r}")
165+
return ", ".join(parts) + ")"
166+
152167

153168
class ResourceManager:
154169
"""Manages SCIM resources with automatic cleanup for tests."""

tests/test_utils.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,35 @@ def test_compare_field_with_none_values():
413413

414414
# Test when both are None
415415
assert compare_field(None, None) is False
416+
417+
418+
def test_check_result_repr():
419+
"""Test CheckResult __repr__ excludes description field."""
420+
result = CheckResult(
421+
status=Status.SUCCESS,
422+
title="Test",
423+
description="Long verbose description that should not appear",
424+
)
425+
repr_str = repr(result)
426+
assert "description" not in repr_str
427+
assert "Status.SUCCESS" in repr_str
428+
assert "title='Test'" in repr_str
429+
430+
result = CheckResult(
431+
status=Status.ERROR,
432+
title="Complex Check",
433+
description="Very long description",
434+
reason="Failed",
435+
data={"key": "value"},
436+
tags={"crud:read"},
437+
resource_type="User",
438+
)
439+
repr_str = repr(result)
440+
assert "description" not in repr_str
441+
assert "Status.ERROR" in repr_str
442+
assert "title='Complex Check'" in repr_str
443+
assert "reason='Failed'" in repr_str
444+
assert "data={'key': 'value'}" in repr_str
445+
assert "tags={'crud:read'}" in repr_str
446+
assert "resource_type='User'" in repr_str
447+
assert result.description == "Very long description"

0 commit comments

Comments
 (0)