@@ -67,6 +67,7 @@ def check_replace_attribute(
6767
6868 for urn , source_model in all_urns :
6969 patch_value = generate_random_value (context , urn = urn , model = source_model )
70+ mutability = get_annotation_by_urn (Mutability , urn , source_model )
7071
7172 patch_op = PatchOp [type (base_resource )](
7273 operations = [
@@ -79,8 +80,7 @@ def check_replace_attribute(
7980 )
8081
8182 try :
82- # Perform the PATCH replace operation
83- updated_resource = context .client .modify (
83+ modify_result = context .client .modify (
8484 resource_model = type (base_resource ),
8585 id = base_resource .id ,
8686 patch_op = patch_op ,
@@ -100,11 +100,50 @@ def check_replace_attribute(
100100 )
101101 continue
102102
103- actual_value = get_value_by_urn (updated_resource , urn )
103+ if modify_result is not None :
104+ if modify_actual_value := get_value_by_urn (modify_result , urn ):
105+ if not (
106+ mutability == Mutability .write_only
107+ or compare_field (patch_value , modify_actual_value )
108+ ):
109+ results .append (
110+ CheckResult (
111+ status = Status .ERROR ,
112+ reason = f"PATCH modify() returned incorrect value for '{ urn } '" ,
113+ resource_type = model .__name__ ,
114+ data = {
115+ "urn" : urn ,
116+ "expected" : patch_value ,
117+ "modify_actual" : modify_actual_value ,
118+ },
119+ )
120+ )
121+ continue
122+
123+ try :
124+ updated_resource = context .client .query (
125+ type (base_resource ),
126+ base_resource .id ,
127+ )
128+ except SCIMClientError as exc :
129+ results .append (
130+ CheckResult (
131+ status = Status .ERROR ,
132+ reason = f"Failed to query resource after replace on '{ urn } ': { exc } " ,
133+ resource_type = model .__name__ ,
134+ data = {
135+ "urn" : urn ,
136+ "error" : exc ,
137+ "patch_value" : patch_value ,
138+ },
139+ )
140+ )
141+ continue
104142
105- if get_annotation_by_urn (
106- Mutability , urn , source_model
107- ) == Mutability .write_only or compare_field (patch_value , actual_value ):
143+ actual_value = get_value_by_urn (updated_resource , urn )
144+ if mutability == Mutability .write_only or compare_field (
145+ patch_value , actual_value
146+ ):
108147 results .append (
109148 CheckResult (
110149 status = Status .SUCCESS ,
0 commit comments