@@ -100,6 +100,24 @@ def location_expansion_multiple_ranges_bad_syntax(root_location: dict) -> dict:
100100 return location
101101
102102
103+ @pytest .fixture
104+ def location_with_non_dict_parameters (root_location : dict ) -> dict :
105+ data = [{"name" : "Mexico" , "type" : "Country" }]
106+ location = root_location .copy ()
107+ location ["spec" ]["data" ] = data
108+ location ["spec" ]["parameters" ] = "not_a_dict"
109+ return location
110+
111+
112+ @pytest .fixture
113+ def location_with_empty_parameters (root_location : dict ) -> dict :
114+ data = [{"name" : "Mexico" , "type" : "Country" }]
115+ location = root_location .copy ()
116+ location ["spec" ]["data" ] = data
117+ location ["spec" ]["parameters" ] = {}
118+ return location
119+
120+
103121async def test_validate_object (client : InfrahubClient , schema_query_01_data : dict , location_mexico_01 ) -> None :
104122 client .schema .set_cache (schema = schema_query_01_data , branch = "main" )
105123 obj = ObjectFile (location = "some/path" , content = location_mexico_01 )
@@ -221,3 +239,27 @@ async def test_get_relationship_info_tags(
221239 rel_info = await get_relationship_info (client_with_schema_01 , location_schema , "tags" , data )
222240 assert rel_info .is_valid == is_valid
223241 assert rel_info .format == format
242+
243+
244+ async def test_parameters_top_level (client_with_schema_01 : InfrahubClient , location_expansion ) -> None :
245+ obj = ObjectFile (location = "some/path" , content = location_expansion )
246+ await obj .validate_format (client = client_with_schema_01 )
247+ assert obj .spec .parameters .expand_range is True
248+
249+
250+ async def test_parameters_missing (client_with_schema_01 : InfrahubClient , location_mexico_01 ) -> None :
251+ obj = ObjectFile (location = "some/path" , content = location_mexico_01 )
252+ await obj .validate_format (client = client_with_schema_01 )
253+ assert hasattr (obj .spec .parameters , "expand_range" )
254+
255+
256+ async def test_parameters_empty_dict (client_with_schema_01 : InfrahubClient , location_with_empty_parameters ) -> None :
257+ obj = ObjectFile (location = "some/path" , content = location_with_empty_parameters )
258+ await obj .validate_format (client = client_with_schema_01 )
259+ assert hasattr (obj .spec .parameters , "expand_range" )
260+
261+
262+ async def test_parameters_non_dict (client_with_schema_01 : InfrahubClient , location_with_non_dict_parameters ) -> None :
263+ obj = ObjectFile (location = "some/path" , content = location_with_non_dict_parameters )
264+ with pytest .raises (ValidationError ):
265+ await obj .validate_format (client = client_with_schema_01 )
0 commit comments