Skip to content

Commit

Permalink
Run examples in YAML as tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dalonsoa committed Nov 15, 2023
1 parent b37b0ea commit 6112bd2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/test_example_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from pytest import mark
from pathlib import Path
import subprocess


def collect_examples() -> list[Path]:
root = Path.cwd() / "docs" / "demo" / "examples"
return list(root.glob("**/*.yaml"))


@mark.parametrize("example", collect_examples())
def test_examples(example: Path, tmp_path: Path) -> None:
result = subprocess.run(
["wsimod", str(example), "-o", str(tmp_path)],
shell=True,
check=True,
)
assert (tmp_path / "flows.csv").exists()
assert (tmp_path / "tanks.csv").exists()
assert (tmp_path / "surfaces.csv").exists()
4 changes: 2 additions & 2 deletions wsimod/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def validate_io_args(

# Valildate inputs folder
settings_["inputs"] = _validate_input_dir(
settings_.get("inputs", inputs), default=settings.parent
inputs if inputs else settings_.get("inputs", None), default=settings.parent
)

# Valildate outputs folder
settings_["outputs"] = _validate_output_dir(
settings_.get("outputs", outputs), default=settings.parent
outputs if outputs else settings_.get("outputs", None), default=settings.parent
)

return settings_
Expand Down

0 comments on commit 6112bd2

Please sign in to comment.