from pathlib import Path
import runpy


def workspace_root_path() -> Path:
    return Path(__file__).resolve().parents[3]


def load_demo_module(file_name: str):
    demo_path = workspace_root_path() / "src" / "python" / "demos" / file_name
    return runpy.run_path(str(demo_path))


def test_demo_region_runs_with_region_metrics_object() -> None:
    demo_module = load_demo_module("demo_region.py")
    demo_module["main"](total_ticks=2, log_every=1)


def test_region_demo_runs_with_region_metrics_object() -> None:
    demo_module = load_demo_module("region_demo.py")
    demo_module["main"](total_steps=2, log_every=1, rng_seed=1234)


def test_image_io_demo_runs_with_two_d_tick_path() -> None:
    demo_module = load_demo_module("image_io_demo.py")
    demo_module["run_demo"](total_steps=1, log_every=1, rng_seed=42)
