@@ -333,3 +333,76 @@ def test_complex_object_creation_and_basemodel_matching():
333333
334334 result = patch .patch (group )
335335 assert result is True
336+
337+
338+ def test_patch_extension_schema_path_without_attribute ():
339+ """Test PATCH with extension schema URN as path (no specific attribute)."""
340+ user = User [EnterpriseUser ](
341+ user_name = "test" ,
342+ schemas = [
343+ "urn:ietf:params:scim:schemas:core:2.0:User" ,
344+ "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ,
345+ ],
346+ )
347+ user [EnterpriseUser ] = EnterpriseUser ()
348+
349+ patch = PatchOp [User ](
350+ operations = [
351+ PatchOperation (
352+ op = PatchOperation .Op .add ,
353+ path = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" ,
354+ value = {
355+ "costCenter" : "Engineering" ,
356+ "department" : "IT" ,
357+ "employeeNumber" : "12345" ,
358+ },
359+ )
360+ ]
361+ )
362+
363+ result = patch .patch (user )
364+ assert result is True
365+ assert user [EnterpriseUser ].cost_center == "Engineering"
366+
367+
368+ def test_patch_main_schema_path_without_attribute ():
369+ """Test PATCH with main schema URN as path (no specific attribute)."""
370+ user = User (user_name = "original" )
371+
372+ patch = PatchOp [User ](
373+ operations = [
374+ PatchOperation (
375+ op = PatchOperation .Op .add ,
376+ path = "urn:ietf:params:scim:schemas:core:2.0:User" ,
377+ value = {
378+ "displayName" : "Updated Name" ,
379+ "nickName" : "Nick" ,
380+ "title" : "Manager" ,
381+ },
382+ )
383+ ]
384+ )
385+
386+ result = patch .patch (user )
387+ assert result is True
388+ assert user .display_name == "Updated Name"
389+ assert user .nick_name == "Nick"
390+ assert user .title == "Manager"
391+
392+
393+ def test_patch_schema_path_with_invalid_value_type ():
394+ """Test PATCH with schema URN path and invalid value type (non-dict)."""
395+ user = User (user_name = "test" )
396+
397+ patch = PatchOp [User ](
398+ operations = [
399+ PatchOperation (
400+ op = PatchOperation .Op .add ,
401+ path = "urn:ietf:params:scim:schemas:core:2.0:User" ,
402+ value = "invalid string value" ,
403+ )
404+ ]
405+ )
406+
407+ with pytest .raises (ValueError , match = "path.*invalid.*malformed" ):
408+ patch .patch (user )
0 commit comments