2525 remove_additional_datasets ,
2626 update_recipe_file ,
2727)
28- from pathlib import Path
2928import shutil
3029import yaml
3130
32-
33- mock_data_dir = Path (__file__ ).parent .parent .parent / "unittest" / "mock_data"
34- recipe_format_file = mock_data_dir / "recipe_paths.yml"
35- model_runs_yml_fp = mock_data_dir / "model_runs.yml"
36- cmip6_datasets_yml_fp = mock_data_dir / "cmip6_datasets.yml"
37- original_recipe_fp = mock_data_dir / "original_recipe_radiation_budget.yml"
38- extra_ds_in_recipe_fp = mock_data_dir / "recipe_with_additional_datasets.yml"
39- updated_recipe_fp = mock_data_dir / "updated_recipe_radiation_budget.yml"
40-
41- kgo_dir = Path (__file__ ).parent .parent .parent / "unittest" / "kgo"
42- no_ds_in_recipe_fp = kgo_dir / "blank_recipe_radiation_budget.yml"
43- no_extras_in_recipe_fp = kgo_dir / "recipe_additional_datasets_removed.yml"
44- extended_recipe_fp = kgo_dir / "extended_radiation_budget_recipe.yml"
31+ from configure_for_conftest import (
32+ recipe_paths_yml_fp ,
33+ model_runs_yml_fp ,
34+ cmip6_datasets_yml_fp ,
35+ original_recipe_radiation_budget_fp ,
36+ recipe_with_additional_datasets_yml_fp ,
37+ updated_recipe_radiation_budget_yml_fp ,
38+ no_ds_in_recipe_fp ,
39+ recipe_additional_datasets_removed_yml_fp ,
40+ extended_radiation_budget_recipe_yml_fp ,
41+ )
4542
4643
4744def test_return_blank_recipe ():
48- with open (no_ds_in_recipe_fp , "r" ) as file_handle :
45+ with open (str ( no_ds_in_recipe_fp ()) , "r" ) as file_handle :
4946 expected = yaml .safe_load (file_handle )
50- actual = return_blank_recipe (str (original_recipe_fp ))
47+ actual = return_blank_recipe (str (original_recipe_radiation_budget_fp () ))
5148 assert actual == expected
5249
5350
5451def test_add_extra_datasets ():
55- with open (extended_recipe_fp , "r" ) as file_handle_1 :
52+ with open (
53+ str (extended_radiation_budget_recipe_yml_fp ()), "r"
54+ ) as file_handle_1 :
5655 expected = yaml .safe_load (file_handle_1 )
5756
58- with open (updated_recipe_fp , "r" ) as file_handle_2 :
57+ with open (
58+ str (updated_recipe_radiation_budget_yml_fp ()), "r"
59+ ) as file_handle_2 :
5960 pre_recipe = yaml .safe_load (file_handle_2 )
6061
6162 # Using str(filepath) here as update_recipe_file.py uses os, not pathlib
62- actual = add_extra_datasets (pre_recipe , str (cmip6_datasets_yml_fp ))
63+ actual = add_extra_datasets (pre_recipe , str (cmip6_datasets_yml_fp () ))
6364 assert actual == expected
6465
6566
6667def test_remove_additional_datasets ():
6768 recipe_id = "mock_entry"
68- with open (no_extras_in_recipe_fp , "r" ) as file_handle_1 :
69+ with open (
70+ str (recipe_additional_datasets_removed_yml_fp ()), "r"
71+ ) as file_handle_1 :
6972 expected = yaml .safe_load (file_handle_1 )
7073
71- with open (extra_ds_in_recipe_fp , "r" ) as file_handle_2 :
74+ with open (
75+ str (recipe_with_additional_datasets_yml_fp ()), "r"
76+ ) as file_handle_2 :
7277 pre_recipe = yaml .safe_load (file_handle_2 )
7378
7479 # Using str(filepath) here as update_recipe_file.py uses os, not pathlib
7580 actual = remove_additional_datasets (
76- pre_recipe , recipe_id , str (recipe_format_file )
81+ pre_recipe , recipe_id , str (recipe_paths_yml_fp () )
7782 )
7883 assert actual == expected
7984
@@ -83,7 +88,9 @@ def test_update_recipe_file(tmp_path):
8388 # Copy the original recipe to a tmp_path location to allow it to be
8489 # overwritten.
8590 path_to_temp_recipe = tmp_path / "tmp_recipe.yml"
86- shutil .copy (original_recipe_fp , path_to_temp_recipe )
91+ shutil .copy (
92+ str (original_recipe_radiation_budget_fp ()), path_to_temp_recipe
93+ )
8794
8895 # Mock the environmental variable 'RECIPE PATH' to the tmp_path location
8996 # where the original recipe is stored.
@@ -94,16 +101,18 @@ def test_update_recipe_file(tmp_path):
94101
95102 update_recipe_file (
96103 recipe_path ,
97- model_runs_yml_fp ,
98- cmip6_datasets_yml_fp ,
104+ str ( model_runs_yml_fp ()) ,
105+ str ( cmip6_datasets_yml_fp ()) ,
99106 recipe_id ,
100- recipe_format_file ,
107+ str ( recipe_paths_yml_fp ()) ,
101108 )
102109
103110 with open (path_to_temp_recipe , "r" ) as file_handle_1 :
104111 actual_lines = file_handle_1 .readlines ()
105112
106- with open (extended_recipe_fp , "r" ) as file_handle_2 :
113+ with open (
114+ str (extended_radiation_budget_recipe_yml_fp ()), "r"
115+ ) as file_handle_2 :
107116 kgo_with_comment = file_handle_2 .readlines ()
108117
109118 # Remove the five comment lines at the top of
0 commit comments