12
12
srcpath = os .path .join (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))),'src' ) #To delete when src is a package
13
13
sys .path .insert (0 ,srcpath ) #To delete when src is a package
14
14
15
- from hres_ic import get_start_time , replace_input_file_with_tmp_input_file , parse_arguments
15
+ from hres_ic import get_start_time , replace_input_file_with_tmp_input_file , parse_arguments , set_replace_function
16
16
17
17
del sys .path [0 ] #To delete when src is a package
18
18
@@ -48,7 +48,7 @@ def test_parse_arguments_with_type():
48
48
args = parse_arguments ()
49
49
assert args .type == 'newtype'
50
50
51
- @patch ('sys.argv' , ['program_name' , '--file' , 'file_path' , '--start' , '2024-08-12 ' ])
51
+ @patch ('sys.argv' , ['program_name' , '--file' , 'file_path' , '--start' , '202408121230 ' ])
52
52
def test_parse_arguments_missing_mask ():
53
53
with pytest .raises (SystemExit ):
54
54
parse_arguments ()
@@ -61,4 +61,18 @@ def test_parse_arguments_missing_file():
61
61
@patch ('sys.argv' , ['program_name' , '--mask' , 'mask_path' , '--file' , 'file_path' ])
62
62
def test_parse_arguments_missing_start ():
63
63
with pytest .raises (SystemExit ):
64
- parse_arguments ()
64
+ parse_arguments ()
65
+
66
+ @patch ('replace_landsurface_with_ERA5land_IC.swap_land_era5land' )
67
+ def test_set_replace_function_era5land (mock_era5land ):
68
+ result = set_replace_function ("era5land" )
69
+ assert result == mock_era5land
70
+
71
+ @patch ('replace_landsurface_with_BARRA2R_IC.swap_land_barra' )
72
+ def test_set_replace_function_barra (mock_barra ):
73
+ result = set_replace_function ("barra" )
74
+ assert result == mock_barra
75
+
76
+ def test_set_replace_function_unknown ():
77
+ result = set_replace_function ("unknown" )
78
+ assert result is None
0 commit comments