Skip to content

Commit 2de1928

Browse files
authored
refactor: use the new scim-models Path object (#45)
1 parent 5c69b38 commit 2de1928

18 files changed

+902
-2979
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.5] - Unreleased
5+
--------------------
6+
7+
Changed
8+
^^^^^^^
9+
- Use scim2-models native path management.
10+
411
[0.2.4] - 2025-10-10
512
--------------------
613

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "uv_build"
55
[project]
66
name = "scim2-tester"
77
version = "0.2.4"
8-
description = " Check SCIM RFCs server compliance"
8+
description = "Check SCIM RFCs server compliance"
99
authors = [{name="Yaal Coop", email="contact@yaal.coop"}]
1010
license = {file = "LICENSE.md"}
1111
readme = "README.md"
@@ -27,8 +27,8 @@ classifiers = [
2727

2828
requires-python = ">= 3.10"
2929
dependencies = [
30-
"scim2-client>=0.6.1",
31-
"scim2-models>=0.5.0",
30+
"scim2-client>=0.7.0",
31+
"scim2-models>=0.6.1",
3232
]
3333

3434
[project.urls]

scim2_tester/checkers/patch_add.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
from scim2_models import PatchOperation
99
from scim2_models import Required
1010
from scim2_models import Resource
11+
from scim2_models.path import Path
1112

1213
from ..filling import generate_random_value
13-
from ..urns import get_annotation_by_urn
14-
from ..urns import get_value_by_urn
15-
from ..urns import iter_all_urns
1614
from ..utils import CheckContext
1715
from ..utils import CheckResult
1816
from ..utils import Status
@@ -60,21 +58,19 @@ def check_add_attribute(
6058
]
6159

6260
results = []
63-
all_urns = list(
64-
iter_all_urns(
65-
model,
61+
all_paths = list(
62+
Path[model].iter_paths(
6663
required=[Required.false],
6764
mutability=[
6865
Mutability.read_write,
6966
Mutability.write_only,
7067
Mutability.immutable,
7168
],
72-
# Not supported until filters are implemented in scim2_models
7369
include_subattributes=False,
7470
)
7571
)
7672

77-
if not all_urns:
73+
if not all_paths:
7874
return [
7975
check_result(
8076
context,
@@ -86,15 +82,16 @@ def check_add_attribute(
8682

8783
base_resource = context.resource_manager.create_and_register(model)
8884

89-
for urn, source_model in all_urns:
90-
patch_value = generate_random_value(context, urn=urn, model=source_model)
91-
mutability = get_annotation_by_urn(Mutability, urn, source_model)
85+
for path in all_paths:
86+
urn = str(path)
87+
patch_value = generate_random_value(context, path=path)
88+
mutability = path.get_annotation(Mutability)
9289

9390
patch_op = PatchOp[type(base_resource)](
9491
operations=[
9592
PatchOperation(
9693
op=PatchOperation.Op.add,
97-
path=urn,
94+
path=path,
9895
value=patch_value,
9996
)
10097
]
@@ -123,7 +120,7 @@ def check_add_attribute(
123120
continue
124121

125122
if modify_result is not None:
126-
modify_actual_value = get_value_by_urn(modify_result, urn)
123+
modify_actual_value = path.get(modify_result)
127124
if mutability != Mutability.write_only and not fields_equality(
128125
patch_value, modify_actual_value
129126
):
@@ -167,7 +164,7 @@ def check_add_attribute(
167164
)
168165
continue
169166

170-
actual_value = get_value_by_urn(updated_resource, urn)
167+
actual_value = path.get(updated_resource)
171168

172169
if mutability == Mutability.write_only or fields_equality(
173170
patch_value, actual_value

scim2_tester/checkers/patch_remove.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
from scim2_models import PatchOperation
99
from scim2_models import Required
1010
from scim2_models import Resource
11+
from scim2_models.path import Path
1112

12-
from ..urns import get_annotation_by_urn
13-
from ..urns import get_value_by_urn
14-
from ..urns import iter_all_urns
1513
from ..utils import CheckContext
1614
from ..utils import CheckResult
1715
from ..utils import Status
@@ -59,17 +57,15 @@ def check_remove_attribute(
5957
]
6058

6159
results = []
62-
all_urns = list(
63-
iter_all_urns(
64-
model,
60+
all_paths = list(
61+
Path[model].iter_paths(
6562
required=[Required.false],
6663
mutability=[Mutability.read_write, Mutability.write_only],
67-
# Not supported until filters are implemented in scim2_models
6864
include_subattributes=False,
6965
)
7066
)
7167

72-
if not all_urns:
68+
if not all_paths:
7369
return [
7470
check_result(
7571
context,
@@ -81,17 +77,18 @@ def check_remove_attribute(
8177

8278
full_resource = context.resource_manager.create_and_register(model, fill_all=True)
8379

84-
for urn, source_model in all_urns:
85-
initial_value = get_value_by_urn(full_resource, urn)
86-
mutability = get_annotation_by_urn(Mutability, urn, source_model)
80+
for path in all_paths:
81+
urn = str(path)
82+
initial_value = path.get(full_resource)
83+
mutability = path.get_annotation(Mutability)
8784
if initial_value is None:
8885
continue
8986

9087
remove_op = PatchOp[type(full_resource)](
9188
operations=[
9289
PatchOperation(
9390
op=PatchOperation.Op.remove,
94-
path=urn,
91+
path=path,
9592
)
9693
]
9794
)
@@ -119,7 +116,7 @@ def check_remove_attribute(
119116
continue
120117

121118
if modify_result is not None:
122-
if modify_actual_value := get_value_by_urn(modify_result, urn):
119+
if modify_actual_value := path.get(modify_result):
123120
if (
124121
mutability != Mutability.write_only
125122
and modify_actual_value is not None
@@ -160,7 +157,7 @@ def check_remove_attribute(
160157
)
161158
continue
162159

163-
actual_value = get_value_by_urn(updated_resource, urn)
160+
actual_value = path.get(updated_resource)
164161
if mutability == Mutability.write_only or actual_value is None:
165162
results.append(
166163
check_result(

scim2_tester/checkers/patch_replace.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
from scim2_models import PatchOp
88
from scim2_models import PatchOperation
99
from scim2_models import Resource
10+
from scim2_models.path import Path
1011

1112
from ..filling import generate_random_value
12-
from ..urns import get_annotation_by_urn
13-
from ..urns import get_value_by_urn
14-
from ..urns import iter_all_urns
1513
from ..utils import CheckContext
1614
from ..utils import CheckResult
1715
from ..utils import Status
@@ -59,16 +57,14 @@ def check_replace_attribute(
5957
]
6058

6159
results = []
62-
all_urns = list(
63-
iter_all_urns(
64-
model,
60+
all_paths = list(
61+
Path[model].iter_paths(
6562
mutability=[Mutability.read_write, Mutability.write_only],
66-
# Not supported until filters are implemented in scim2_models
6763
include_subattributes=False,
6864
)
6965
)
7066

71-
if not all_urns:
67+
if not all_paths:
7268
return [
7369
check_result(
7470
context,
@@ -80,15 +76,16 @@ def check_replace_attribute(
8076

8177
base_resource = context.resource_manager.create_and_register(model)
8278

83-
for urn, source_model in all_urns:
84-
patch_value = generate_random_value(context, urn=urn, model=source_model)
85-
mutability = get_annotation_by_urn(Mutability, urn, source_model)
79+
for path in all_paths:
80+
urn = str(path)
81+
patch_value = generate_random_value(context, path=path)
82+
mutability = path.get_annotation(Mutability)
8683

8784
patch_op = PatchOp[type(base_resource)](
8885
operations=[
8986
PatchOperation(
9087
op=PatchOperation.Op.replace_,
91-
path=urn,
88+
path=path,
9289
value=patch_value,
9390
)
9491
]
@@ -117,7 +114,7 @@ def check_replace_attribute(
117114
continue
118115

119116
if modify_result is not None:
120-
modify_actual_value = get_value_by_urn(modify_result, urn)
117+
modify_actual_value = path.get(modify_result)
121118
if mutability != Mutability.write_only and not fields_equality(
122119
patch_value, modify_actual_value
123120
):
@@ -161,7 +158,7 @@ def check_replace_attribute(
161158
)
162159
continue
163160

164-
actual_value = get_value_by_urn(updated_resource, urn)
161+
actual_value = path.get(updated_resource)
165162
if mutability == Mutability.write_only or fields_equality(
166163
patch_value, actual_value
167164
):

scim2_tester/checkers/resource_get.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _model_from_resource_type(
1919
corresponding Python model class registered in the SCIM client.
2020
"""
2121
for resource_model in context.client.resource_models:
22-
if resource_model.model_fields["schemas"].default[0] == resource_type.schema_:
22+
if resource_model.__schema__ == resource_type.schema_:
2323
return resource_model
2424

2525
return None

0 commit comments

Comments
 (0)