generated from ImperialCollegeLondon/pip-tools-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98ec548
commit b77d136
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Integration test for the swmmanywhere command-line interface.""" | ||
import sys | ||
import tempfile | ||
import yaml | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from swmmanywhere import __main__ | ||
|
||
def test_swmmanywhere_cli(capsys): | ||
"""Test that the CLI can successfully run with an actual configuration.""" | ||
|
||
with tempfile.TemporaryDirectory() as tempdir: | ||
base_dir = Path(tempdir) | ||
# Define minimum viable config | ||
config = { | ||
"base_dir": str(base_dir), | ||
"project": "my_first_swmm", | ||
"bbox": [1.52740, 42.50524, 1.54273, 42.51259], | ||
} | ||
|
||
config_path = base_dir / "config.yml" | ||
with config_path.open("w") as config_file: | ||
yaml.dump(config, config_file) | ||
|
||
# Mock sys.argv to simulate command-line arguments | ||
sys.argv = [ | ||
"swmmanywhere", | ||
"--config_path", str(config_path), | ||
"--verbose", "True" | ||
] | ||
|
||
# Run the CLI entry point | ||
__main__.run() | ||
|
||
# Capture the output | ||
captured = capsys.readouterr() | ||
expected = "No real network provided, returning SWMM .inp file." | ||
assert expected in captured.out |