from __future__ import annotations import importlib.util import sys from pathlib import Path def _load_tree_module(): path = Path(__file__).resolve().parent.parent / "scripts" / "two_user_flow_tree.py" spec = importlib.util.spec_from_file_location("two_user_flow_tree", path) assert spec and spec.loader mod = importlib.util.module_from_spec(spec) sys.modules[spec.name] = mod spec.loader.exec_module(mod) return mod def test_two_user_flow_tree_smoke(tmp_path: Path) -> None: mod = _load_tree_module() report = mod.run_simulation( max_depth=1, workdir=tmp_path / "tree", seed_plays_per_user=50, check_recommendations=True, ) assert report["checked_edges"] >= 18 assert report["seed_plays_per_user"] == 50 assert report["check_recommendations"] is True assert report["unique_states"] >= 10 assert any(edge["expected_ok"] is False and edge["actual_ok"] is False for edge in report["edges"]) assert all(edge["invariants_ok"] for edge in report["edges"])