> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.testing.session_conformance

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

| Name                                                                                                         | Description                                                                                         |
| ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| [`check_resources_session_contract`](#nemo_gym-testing-session_conformance-check_resources_session_contract) | Seed, re-seed, and close a session through `app`, and raise AssertionError on a contract violation. |

### API

```python
nemo_gym.testing.session_conformance.check_resources_session_contract(
    app: fastapi.FastAPI,
    seed: nemo_gym.base_resources_server.ResourcesSeedSessionRequest,
    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.