Spaces:
Sleeping
Sleeping
Download tests/test_server.py from SandyTheAdventurer/coenv: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/SandyTheAdventurer/coenv/resolve/main/tests/test_server.py
- Command line
-
hf download hf://spaces/SandyTheAdventurer/coenv/tests/test_server.py
-
curl -L -o test_server.py https://huggingface.co/spaces/SandyTheAdventurer/coenv/resolve/main/tests/test_server.py
1.22 kB
| from ..client import CoEnv | |
| from ..models import CoenvAction | |
| import pytest | |
| async def test_client_step_and_state(): | |
| async with CoEnv(base_url="http://localhost:8000") as client: | |
| # Test reset and initial state | |
| reset_result = await client.reset() | |
| assert hasattr(reset_result.observation, "step") | |
| assert hasattr(reset_result.observation, "done") | |
| assert reset_result.observation.step == 0 | |
| assert reset_result.done is False | |
| # Test step with a sample action | |
| action = CoenvAction(action_type="describe", resource_type="pod", name="test-pod") | |
| step_result = await client.step(action) | |
| assert hasattr(step_result.observation, "step") | |
| assert step_result.observation.step == 1 | |
| # Test state retrieval | |
| step_result = await client.step(action) | |
| state_attr = getattr(client, "state") | |
| state = await state_attr() if callable(state_attr) else state_attr | |
| if isinstance(state, dict): | |
| step_count = state.get("step_count", state.get("step", -1)) | |
| else: | |
| step_count = getattr(state, "step_count", getattr(state, "step", -1)) | |
| assert step_count == 2 |