Skip to content

Commit

Permalink
add test cli
Browse files Browse the repository at this point in the history
  • Loading branch information
barneydobson committed Oct 23, 2024
1 parent 98ec548 commit b77d136
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_cli.py
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

0 comments on commit b77d136

Please sign in to comment.