File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 11Changelog
22=========
33
4+ [0.2.11] - Unreleased
5+ ---------------------
6+ Added
7+ ^^^^^
8+ - Implement :meth: `Schema.get_attribute <scim2_models.Schema.get_attribute> `.
9+
410[0.2.10] - 2024-12-02
511---------------------
612
Original file line number Diff line number Diff line change @@ -266,3 +266,10 @@ class Schema(Resource):
266266 def urn_id (cls , value : str ) -> str :
267267 """Ensure that schema ids are URI, as defined in RFC7643 §7."""
268268 return str (Url (value ))
269+
270+ def get_attribute (self , attribute_name : str ) -> Optional [Attribute ]:
271+ """Find an attribute by its name."""
272+ for attribute in self .attributes or []:
273+ if attribute .name == attribute_name :
274+ return attribute
275+ return None
Original file line number Diff line number Diff line change @@ -85,3 +85,11 @@ def test_uri_ids():
8585 Schema (id = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" )
8686 with pytest .raises (ValidationError ):
8787 Schema (id = "invalid\n uri" )
88+
89+
90+ def test_get_attribute (load_sample ):
91+ """Test the Schema.get_attribute method."""
92+ payload = load_sample ("rfc7643-8.7.1-schema-user.json" )
93+ schema = Schema .model_validate (payload )
94+ assert schema .get_attribute ("invalid" ) is None
95+ assert isinstance (schema .get_attribute ("userName" ), Attribute )
You can’t perform that action at this time.
0 commit comments