@@ -625,26 +625,35 @@ def test_check_protected_parameters(delete_operation) -> None:
625625
626626
627627@pytest .mark .parametrize (
628- ["model" , "field " ],
628+ ["model" , "fields " ],
629629 [
630- ("background_parameters" , "source" ),
631- ("resolution_parameters" , "source" ),
632- ("parameters" , "roughness" ),
633- ("data" , "data" ),
634- ("backgrounds" , "background" ),
635- ("bulk_in" , "bulk_in" ),
636- ("bulk_out" , "bulk_out" ),
637- ("scalefactors" , "scalefactor" ),
638- ("resolutions" , "resolution" ),
630+ ("background_parameters" , ["source" ]),
631+ ("resolution_parameters" , ["source" ]),
632+ ("parameters" , ["roughness" ]),
633+ ("data" , ["data" , "source" , "source" ]),
634+ ("custom_files" , ["source" , "source" ]),
635+ ("backgrounds" , ["background" ]),
636+ ("bulk_in" , ["bulk_in" ]),
637+ ("bulk_out" , ["bulk_out" ]),
638+ ("scalefactors" , ["scalefactor" ]),
639+ ("resolutions" , ["resolution" ]),
639640 ],
640641)
641- def test_rename_models (test_project , model : str , field : str ) -> None :
642+ def test_rename_models (test_project , model : str , fields : list [ str ] ) -> None :
642643 """When renaming a model in the project, the new name should be recorded when that model is referred to elsewhere
643644 in the project.
644645 """
646+ if model == "data" :
647+ test_project .backgrounds [0 ] = RATapi .models .Background (type = "data" , source = "Simulation" )
648+ test_project .resolutions [0 ] = RATapi .models .Resolution (type = "data" , source = "Simulation" )
649+ if model == "custom_files" :
650+ test_project .backgrounds [0 ] = RATapi .models .Background (type = "function" , source = "Test Custom File" )
651+ test_project .resolutions [0 ] = RATapi .models .Resolution (type = "function" , source = "Test Custom File" )
645652 getattr (test_project , model ).set_fields (- 1 , name = "New Name" )
646- attribute = RATapi .project .model_names_used_in [model ].attribute
647- assert getattr (getattr (test_project , attribute )[- 1 ], field ) == "New Name"
653+ model_name_lists = RATapi .project .model_names_used_in [model ]
654+ for model_name_list , field in zip (model_name_lists , fields ):
655+ attribute = model_name_list .attribute
656+ assert getattr (getattr (test_project , attribute )[- 1 ], field ) == "New Name"
648657
649658
650659@pytest .mark .parametrize (
@@ -1197,7 +1206,7 @@ def test_wrap_del(test_project, class_list: str, parameter: str, field: str) ->
11971206 pydantic .ValidationError ,
11981207 match = f"1 validation error for Project\n Value error, The value "
11991208 f'"{ parameter } " in the "{ field } " field of '
1200- f'"{ RATapi .project .model_names_used_in [class_list ].attribute } " '
1209+ f'"{ RATapi .project .model_names_used_in [class_list ][ 0 ] .attribute } " '
12011210 f'must be defined in "{ class_list } ".' ,
12021211 ):
12031212 del test_attribute [index ]
@@ -1405,7 +1414,7 @@ def test_wrap_pop(test_project, class_list: str, parameter: str, field: str) ->
14051414 pydantic .ValidationError ,
14061415 match = f"1 validation error for Project\n Value error, The value "
14071416 f'"{ parameter } " in the "{ field } " field of '
1408- f'"{ RATapi .project .model_names_used_in [class_list ].attribute } " '
1417+ f'"{ RATapi .project .model_names_used_in [class_list ][ 0 ] .attribute } " '
14091418 f'must be defined in "{ class_list } ".' ,
14101419 ):
14111420 test_attribute .pop (index )
@@ -1437,7 +1446,7 @@ def test_wrap_remove(test_project, class_list: str, parameter: str, field: str)
14371446 pydantic .ValidationError ,
14381447 match = f"1 validation error for Project\n Value error, The value "
14391448 f'"{ parameter } " in the "{ field } " field of '
1440- f'"{ RATapi .project .model_names_used_in [class_list ].attribute } " '
1449+ f'"{ RATapi .project .model_names_used_in [class_list ][ 0 ] .attribute } " '
14411450 f'must be defined in "{ class_list } ".' ,
14421451 ):
14431452 test_attribute .remove (parameter )
@@ -1469,7 +1478,7 @@ def test_wrap_clear(test_project, class_list: str, parameter: str, field: str) -
14691478 pydantic .ValidationError ,
14701479 match = f"1 validation error for Project\n Value error, The value "
14711480 f'"{ parameter } " in the "{ field } " field of '
1472- f'"{ RATapi .project .model_names_used_in [class_list ].attribute } " '
1481+ f'"{ RATapi .project .model_names_used_in [class_list ][ 0 ] .attribute } " '
14731482 f'must be defined in "{ class_list } ".' ,
14741483 ):
14751484 test_attribute .clear ()
0 commit comments