Skip to content

Commit

Permalink
Merge pull request #44 from IGNF/test/cli_pivot_to_osm
Browse files Browse the repository at this point in the history
Test/cli pivot to osm
  • Loading branch information
jmkerloch authored Mar 9, 2023
2 parents ef43a02 + 85974c7 commit 268346f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
3 changes: 2 additions & 1 deletion tests/config/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
updated_sql2pivot.json
updated_sql2pivot.json
updated_pivot2osm.json
37 changes: 37 additions & 0 deletions tests/config/pivot2osm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"generation": {
"general":{
"id": "pivot2osm",
"logs": {"configFile": "/home/docker/config/sample_log_config.json"},
"overwrite": true,
"operation": "creation"
},
"bases": [
{
"id": "input",
"type": "bdd",
"configFile": "{src_dir}/tests/config/pivot_base.json",
"schema": "output"
}
],
"workingSpace": {
"directory": "/home/docker/data/generation/",
"baseId": "input"
},
"resource": {
"id": "pivot-osm",
"type": "osrm",
"sources": [
{
"id": "pivot-osm",
"type": "osrm",
"bbox": "-180,-90,180, 90",
"mapping":
{
"source": {"baseId": "input"}
}
}
]
}
}
}
33 changes: 30 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ def update_src_dir_json(file_path: Path, output_file_path: Path):
f.write(content)


def test_sql2pivot(init_database):
"""Test simple run of cli for pivot base creation."""

def sql2pivot():
"""Simple run of cli for pivot base creation."""
# Update input json file to indicate current source directory
update_src_dir_json(cur_dir / "config" / "sql2pivot.json", cur_dir / "config" / "updated_sql2pivot.json")

Expand All @@ -103,3 +102,31 @@ def test_sql2pivot(init_database):
config_file_path=str(cur_dir / "config" / "updated_sql2pivot.json"))
# Run conversion
cli.sql2pivot()


def test_sql2pivot(init_database):
"""Test simple run of cli for pivot base creation."""
sql2pivot()


def pivot2osm():
"""Simple run of cli for osm file creation from pivot database."""
# Update input json file to indicate current source directory
update_src_dir_json(cur_dir / "config" / "pivot2osm.json", cur_dir / "config" / "updated_pivot2osm.json")

# mock ArgumentParser for configuration file
with patch("argparse.ArgumentParser.parse_args") as parse_arg_mock:
parse_arg_mock.return_value = argparse.Namespace(
config_file_path=str(cur_dir / "config" / "updated_pivot2osm.json"))
# Run conversion
cli.pivot2osm()

assert os.path.exists("/home/docker/data/generation/pivot-osm.osm")


def test_pivot2osm(init_database):
"""Test simple run of cli for osm file creation from pivot database."""

sql2pivot()
pivot2osm()

0 comments on commit 268346f

Please sign in to comment.