1
1
import logging
2
2
import os
3
3
import traceback
4
+ from pathlib import Path
4
5
5
6
import pytest
6
7
from click .testing import CliRunner
@@ -34,19 +35,32 @@ def runner():
34
35
return CliRunner ()
35
36
36
37
38
+ @pytest .fixture
39
+ def default_output_file_ending ():
40
+ return "_epsg_4326.gpkg"
41
+
42
+
43
+ @pytest .fixture
44
+ def default_output_file_path (path_output_dir , default_output_file_ending ):
45
+ return Path (path_output_dir + default_output_file_ending )
46
+
47
+
37
48
def check_exit_code (result ):
38
49
"Print full traceback if the CLI runner failed"
39
50
if result .exit_code != 0 :
40
51
traceback .print_tb (result .exc_info [- 1 ])
41
52
assert result .exit_code == 0
42
53
43
54
44
- def test_cli_with_default_args (runner , config_path , toy_osm_path , path_output_dir ):
55
+ def test_cli_with_default_args (
56
+ runner , config_path , toy_osm_path , path_output_dir , default_output_file_path
57
+ ):
45
58
# Test the command with minimal arguments
46
59
result = runner .invoke (cli .run , [config_path , toy_osm_path , path_output_dir ])
47
60
48
61
check_exit_code (result )
49
62
assert result .exit_code == 0
63
+ assert default_output_file_path .exists ()
50
64
51
65
52
66
@pytest .mark .parametrize ("output_format" , ["geojson" , "geopackage" , "geoparquet" ])
@@ -57,3 +71,18 @@ def test_cli_output_formats(runner, config_path, toy_osm_path, path_output_dir,
57
71
)
58
72
check_exit_code (result )
59
73
assert result .exit_code == 0
74
+
75
+
76
+ @pytest .mark .parametrize ("crs" , ["epsg:27700" ])
77
+ def test_cli_output_crs (
78
+ runner , config_path , toy_osm_path , path_output_dir , crs , default_output_file_path
79
+ ):
80
+ result = runner .invoke (cli .run , [config_path , toy_osm_path , path_output_dir , "-crs" , crs ])
81
+ check_exit_code (result )
82
+ assert result .exit_code == 0
83
+
84
+ # test that file with default crs is still produced
85
+ assert default_output_file_path .exists ()
86
+
87
+ out_path = Path (path_output_dir + "_epsg_27700.gpkg" )
88
+ assert out_path .exists ()
0 commit comments