@@ -32,7 +32,7 @@ def model_from_resource_type(
3232 return None
3333
3434
35- def fill_with_random_values (obj : type [ Resource ] ) -> type [ Resource ] :
35+ def fill_with_random_values (obj : Resource ) -> Resource :
3636 for field_name , field in obj .model_fields .items ():
3737 if field .default :
3838 continue
@@ -55,6 +55,11 @@ def fill_with_random_values(obj: type[Resource]) -> type[Resource]:
5555 ExternalReference ,
5656 URIReference ,
5757 ):
58+ if (
59+ obj .__class__ .get_field_annotation (field_name , Required )
60+ == Required .true
61+ ):
62+ return None
5863 continue
5964
6065 value = f"https://{ str (uuid .uuid4 ())} .test"
@@ -67,12 +72,10 @@ def fill_with_random_values(obj: type[Resource]) -> type[Resource]:
6772 value = random .choice (list (field_type ))
6873
6974 elif isclass (field_type ) and issubclass (field_type , ComplexAttribute ):
70- value = field_type ()
71- fill_with_random_values (value )
75+ value = fill_with_random_values (field_type ())
7276
7377 elif isclass (field_type ) and issubclass (field_type , Extension ):
74- value = field_type ()
75- fill_with_random_values (value )
78+ value = fill_with_random_values (field_type ())
7679
7780 else :
7881 value = str (uuid .uuid4 ())
@@ -207,8 +210,7 @@ def check_resource_type(
207210 ]
208211
209212 results = []
210- obj = model ()
211- fill_with_random_values (obj )
213+ obj = fill_with_random_values (model ())
212214
213215 result = check_object_creation (conf , obj )
214216 results .append (result )
0 commit comments