Skip to content

Commit f10f4a1

Browse files
committed
cli crs test and file writing
1 parent 37b0d28 commit f10f4a1

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

tests/test_cli.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import os
33
import traceback
4+
from pathlib import Path
45

56
import pytest
67
from click.testing import CliRunner
@@ -34,19 +35,32 @@ def runner():
3435
return CliRunner()
3536

3637

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+
3748
def check_exit_code(result):
3849
"Print full traceback if the CLI runner failed"
3950
if result.exit_code != 0:
4051
traceback.print_tb(result.exc_info[-1])
4152
assert result.exit_code == 0
4253

4354

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+
):
4558
# Test the command with minimal arguments
4659
result = runner.invoke(cli.run, [config_path, toy_osm_path, path_output_dir])
4760

4861
check_exit_code(result)
4962
assert result.exit_code == 0
63+
assert default_output_file_path.exists()
5064

5165

5266
@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,
5771
)
5872
check_exit_code(result)
5973
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

Comments
 (0)