"""Tests for benchmark environments and runner."""


from nephrosim.benchmarks.environments import BENCHMARK_ENVS
from nephrosim.benchmarks.runner import run_benchmarks


class TestBenchmarkEnvironments:
    def test_four_envs_defined(self):
        assert len(BENCHMARK_ENVS) == 4

    def test_all_have_env_id(self):
        for bench in BENCHMARK_ENVS:
            assert "env_id" in bench
            assert bench["env_id"].startswith("nephrosim/")

    def test_all_have_category(self):
        for bench in BENCHMARK_ENVS:
            assert "category" in bench
            assert len(bench["category"]) > 0

    def test_all_have_description(self):
        for bench in BENCHMARK_ENVS:
            assert "description" in bench

    def test_unique_env_ids(self):
        ids = [b["env_id"] for b in BENCHMARK_ENVS]
        assert len(ids) == len(set(ids))


class TestBenchmarkRunner:
    def test_run_benchmarks_returns_dict(self):
        results = run_benchmarks(n_episodes=2, seed=42)
        assert isinstance(results, dict)
        assert len(results) == 4

    def test_results_have_random_and_heuristic(self):
        results = run_benchmarks(n_episodes=2, seed=42)
        for env_name, data in results.items():
            assert "random" in data
            assert "heuristic" in data
            assert "mean_reward" in data["random"]
            assert "std_reward" in data["random"]
