Skip to content

Commit 3d6e567

Browse files
committed
feat: implement BaseSCIMClient.register_naive_resource_types
1 parent 456b549 commit 3d6e567

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

doc/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Changelog
1010

1111
- :class:`~scim2_client.BaseSCIMClient` takes a mandatory :paramref:`~scim2_client.BaseSCIMClient.resource_types` parameter.
1212

13+
Added
14+
^^^^^
15+
- Implement :meth:`~scim2_client.BaseSCIMClient.register_naive_resource_types`.
16+
1317
[0.3.3] - 2024-11-29
1418
--------------------
1519

scim2_client/client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@ def resource_endpoint(self, resource_model: Optional[type[Resource]]) -> str:
187187

188188
raise SCIMRequestError(f"No ResourceType is matching the schema: {schema}")
189189

190+
def register_naive_resource_types(self):
191+
"""Register a *naive* :class:`~scim2_models.ResourceType` for each :paramref:`resource_model <scim2_client.BaseSCIMClient.resource_models>`.
192+
193+
This fills the :class:`~scim2_models.ResourceType` with generic values.
194+
The endpoint is the resource name with a *s* suffix.
195+
For instance, the :class:`~scim2_models.User` will have a `/Users` endpoint.
196+
"""
197+
self.resource_types = [
198+
ResourceType.from_resource(model)
199+
for model in self.resource_models
200+
if model not in (ResourceType, Schema, ServiceProviderConfig)
201+
]
202+
190203
def check_response(
191204
self,
192205
payload: Optional[dict],

tests/conftest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
from httpx import Client
33
from scim2_models import Group
4-
from scim2_models import ResourceType
54
from scim2_models import User
65

76
from scim2_client.engines.httpx import SyncSCIMClient
@@ -13,9 +12,6 @@ def sync_client(httpserver):
1312
scim_client = SyncSCIMClient(
1413
client,
1514
resource_models=[User, Group],
16-
resource_types=[
17-
ResourceType.from_resource(User),
18-
ResourceType.from_resource(Group),
19-
],
2015
)
16+
scim_client.register_naive_resource_types()
2117
return scim_client

0 commit comments

Comments
 (0)