polyguard-openenv / tests /test_env_reset.py
TheJackBright's picture
Deploy PolyGuard OpenEnv Space
877add7 verified
from app.env.env_core import PolyGuardEnv
def test_env_reset_deterministic_patient_id() -> None:
env = PolyGuardEnv()
obs1 = env.reset(seed=123, difficulty="easy")
pid1 = obs1.patient_summary["patient_id"]
contract1 = obs1.deterministic_contract
obs2 = env.reset(seed=123, difficulty="easy")
pid2 = obs2.patient_summary["patient_id"]
contract2 = obs2.deterministic_contract
assert pid1 == pid2
assert contract1["seed"] == contract2["seed"] == 123
assert contract1["difficulty"] == contract2["difficulty"] == "easy"
def test_env_reset_with_explicit_sub_environment() -> None:
env = PolyGuardEnv()
obs = env.reset(seed=9, difficulty="hard", sub_environment="LONGITUDINAL_DEPRESCRIBING")
assert obs.sub_environment.value == "LONGITUDINAL_DEPRESCRIBING"
assert obs.step_budget_remaining <= 10