Skip to content

Commit d33c073

Browse files
committed
tests: check invalid attribute inclusion/exclusion on serialization
1 parent f489fb1 commit d33c073

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/test_model_serialization.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,51 @@ def test_dump_default_response(ret_resource):
191191
}
192192

193193

194+
def test_invalid_attributes():
195+
"""Test error handling for invalid attributes parameter."""
196+
resource = SupRetResource(id="id", always_returned="x", default_returned="x")
197+
198+
with pytest.raises(ValueError):
199+
resource.model_dump(
200+
scim_ctx=Context.RESOURCE_QUERY_RESPONSE, attributes={"invalidAttribute"}
201+
)
202+
203+
with pytest.raises(ValueError):
204+
resource.model_dump(
205+
scim_ctx=Context.RESOURCE_QUERY_RESPONSE,
206+
attributes={"org:example:SupRetResource:invalidAttribute"},
207+
)
208+
209+
with pytest.raises(ValueError):
210+
resource.model_dump(
211+
scim_ctx=Context.RESOURCE_QUERY_RESPONSE,
212+
attributes={"urn:invalid:schema:invalidAttribute"},
213+
)
214+
215+
216+
def test_invalid_excluded_attributes():
217+
"""Test error handling for invalid excluded_attributes parameter."""
218+
resource = SupRetResource(id="id", always_returned="x", default_returned="x")
219+
220+
with pytest.raises(ValueError):
221+
resource.model_dump(
222+
scim_ctx=Context.RESOURCE_QUERY_RESPONSE,
223+
excluded_attributes={"invalidAttribute"},
224+
)
225+
226+
with pytest.raises(ValueError):
227+
resource.model_dump(
228+
scim_ctx=Context.RESOURCE_QUERY_RESPONSE,
229+
excluded_attributes={"org:example:SupRetResource:invalidAttribute"},
230+
)
231+
232+
with pytest.raises(ValueError):
233+
resource.model_dump(
234+
scim_ctx=Context.RESOURCE_QUERY_RESPONSE,
235+
excluded_attributes={"urn:invalid:schema:invalidAttribute"},
236+
)
237+
238+
194239
@pytest.mark.parametrize(
195240
"context",
196241
[

0 commit comments

Comments
 (0)