Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add write option for geopackage and geoparquet #42

Merged
merged 15 commits into from
Mar 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add CLI test traceback printer
brynpickering committed Mar 20, 2024

Verified

This commit was signed with the committer’s verified signature.
brynpickering Bryn Pickering
commit 9cfd585729e089bfab0a6dfd9c677e99b6a60c6e
40 changes: 19 additions & 21 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
import os
import logging
import os
import traceback

import pytest
from click.testing import CliRunner

from osmox import cli

logging.basicConfig(level=logging.INFO)


@pytest.fixture
def fixtures_root():
return os.path.abspath(os.path.join(os.path.dirname(__file__), "fixtures"))


@pytest.fixture
def config_path(fixtures_root):
return os.path.join(fixtures_root, "test_config.json")


@pytest.fixture
def toy_osm_path(fixtures_root):
return os.path.join(fixtures_root, "park.osm")


@pytest.fixture
def runner():
return CliRunner()


def check_exit_code(result):
"Print full traceback if the CLI runner failed"
if result.exit_code != 0:
traceback.print_tb(result.exc_info[-1])
assert result.exit_code == 0


def test_cli_with_default_args(runner, config_path, toy_osm_path):
# Test the command with minimal arguments
result = runner.invoke(
cli.run,
[
config_path,
toy_osm_path,
'output_test'
]
)
#print(result.output)
assert result.exit_code == 0
result = runner.invoke(cli.run, [config_path, toy_osm_path, "output_test"])

check_exit_code(result)
assert "geopackage" in result.exit_code
brynpickering marked this conversation as resolved.
Show resolved Hide resolved
assert "epsg:4326" in result.exit_code

@@ -44,13 +49,6 @@ def test_cli_output_formats(runner, config_path, toy_osm_path):
for output_format in ["geojson", "geopackage", "geoparquet"]:
result = runner.invoke(
brynpickering marked this conversation as resolved.
Show resolved Hide resolved
cli.run,
[
config_path,
toy_osm_path,
'output_test',
"-f", output_format,
"-crs", "epsg:4326"
]
[config_path, toy_osm_path, "output_test", "-f", output_format, "-crs", "epsg:4326"],
)
print(result.output)
assert result.exit_code == 0
check_exit_code(result)