nemo_gym.testing.session_conformance

View as Markdown

Integration test for a Resources Server’s Environment Server session lifecycle.

check_resources_session_contract drives the app a server builds through its real HTTP routes and middleware, in process, the way an Environment Server calls a deployed server: typed seed, repeated seed, close, repeated close, close of a never-seeded session, and a seed after close. Call it from the server’s own tests. Because it goes through the routes, it also catches a route that another registration shadows.

Module Contents

Functions

NameDescription
check_resources_session_contractSeed, re-seed, and close a session through app, and raise AssertionError on a contract violation.

API

nemo_gym.testing.session_conformance.check_resources_session_contract(
app: fastapi.FastAPI,
keeps_state: bool
) -> None

Seed, re-seed, and close a session through app, and raise AssertionError on a contract violation.

seed must use a resources_session_id the app has not seen. With keeps_state, a seed that arrives after its session closed, or after a close for an ID that was never seeded, must be rejected; a server that keeps no state has nothing such a seed could recreate.