"""Tests for training configuration."""


from nephrosim.training.configs import ENV_CONFIGS


class TestEnvConfigs:
    def test_all_envs_present(self):
        expected = [
            "nephrosim/UreaClearing-v0",
            "nephrosim/UltrafiltrationControl-v0",
            "nephrosim/PhosphateMgmt-v0",
            "nephrosim/FullDialysisSession-v0",
        ]
        for env_id in expected:
            assert env_id in ENV_CONFIGS

    def test_timesteps_positive(self):
        for env_id, config in ENV_CONFIGS.items():
            assert config["total_timesteps"] > 0

    def test_learning_rate_reasonable(self):
        for env_id, config in ENV_CONFIGS.items():
            assert 1e-6 < config["learning_rate"] < 1e-2

    def test_gamma_between_zero_and_one(self):
        for env_id, config in ENV_CONFIGS.items():
            assert 0.0 < config["gamma"] <= 1.0

    def test_batch_size_positive(self):
        for env_id, config in ENV_CONFIGS.items():
            assert config["batch_size"] > 0

    def test_full_session_has_more_timesteps(self):
        assert (
            ENV_CONFIGS["nephrosim/FullDialysisSession-v0"]["total_timesteps"]
            > ENV_CONFIGS["nephrosim/UreaClearing-v0"]["total_timesteps"]
        )

    def test_seed_consistent(self):
        for env_id, config in ENV_CONFIGS.items():
            assert config["seed"] == 42

    def test_required_keys_present(self):
        required = [
            "total_timesteps", "learning_rate", "n_steps",
            "batch_size", "gamma", "gae_lambda", "clip_range",
            "ent_coef", "seed",
        ]
        for env_id, config in ENV_CONFIGS.items():
            for key in required:
                assert key in config, f"{key} missing from {env_id}"
