mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 07:26:18 -05:00
Testing importing multiple map pbf files.
This commit is contained in:
parent
83d1d3270d
commit
b43677e674
2 changed files with 12 additions and 7 deletions
|
|
@ -189,7 +189,6 @@ async def run_import_command(*paths: Path) -> int:
|
|||
paths = list(map(str, paths))
|
||||
# Run with sudo so renderd can be restarted.
|
||||
cmd = (SUDO_BIN, f'{PROJECT_DIR}/scripts/import_map.sh', *paths)
|
||||
import_logger.warning(f'Running map import command: {cmd}')
|
||||
result = await run_command(cmd, debug=True)
|
||||
|
||||
success = 'Successful' if result.return_code == 0 else 'Unsuccessful'
|
||||
|
|
|
|||
|
|
@ -27,13 +27,14 @@ async def test_run_import_command(test_directory, mock_run_command, run_command_
|
|||
Import map files. Files to import are checked for validity before importing. Any errors returned by
|
||||
asyncio.create_subprocess_shell are caught and reported.
|
||||
"""
|
||||
pbf_file = test_directory / 'foo.osm.pbf'
|
||||
foo_pbf = test_directory / 'foo.osm.pbf'
|
||||
bar_pbf = test_directory / 'bar.osm.pbf'
|
||||
with pytest.raises(ValueError):
|
||||
await lib.run_import_command(pbf_file)
|
||||
await lib.run_import_command(foo_pbf)
|
||||
|
||||
pbf_file.touch()
|
||||
foo_pbf.touch()
|
||||
with pytest.raises(ValueError):
|
||||
await lib.run_import_command(pbf_file)
|
||||
await lib.run_import_command(foo_pbf)
|
||||
|
||||
dump_file = test_directory / 'dumpy.dump'
|
||||
dump_file.touch()
|
||||
|
|
@ -41,14 +42,19 @@ async def test_run_import_command(test_directory, mock_run_command, run_command_
|
|||
with mock.patch('modules.map.lib.is_pbf_file') as mock_is_pbf_file:
|
||||
# Run the import, it succeeds.
|
||||
mock_is_pbf_file.return_value = True
|
||||
await lib.run_import_command(pbf_file)
|
||||
await lib.run_import_command(foo_pbf)
|
||||
|
||||
# Can import more than one pbf.
|
||||
with mock.patch('modules.map.lib.is_pbf_file') as mock_is_pbf_file:
|
||||
mock_is_pbf_file.return_value = True
|
||||
await lib.run_import_command(foo_pbf, bar_pbf)
|
||||
|
||||
with mock.patch('modules.map.lib.is_pbf_file') as mock_is_pbf_file:
|
||||
# Run the import, it fails.
|
||||
mock_run_command(run_command_bad_result)
|
||||
mock_is_pbf_file.return_value = True
|
||||
with pytest.raises(ValueError):
|
||||
await lib.run_import_command(pbf_file)
|
||||
await lib.run_import_command(foo_pbf)
|
||||
|
||||
with pytest.raises(ValueError) as e:
|
||||
await lib.run_import_command()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue