Spaces:
Sleeping
Sleeping
Download client/python/tests/conftest.py from Wenluo/RobotTransportServer: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/spaces/Wenluo/RobotTransportServer/resolve/main/client/python/tests/conftest.py
- Command line
-
hf download hf://spaces/Wenluo/RobotTransportServer/client/python/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/Wenluo/RobotTransportServer/resolve/main/client/python/tests/conftest.py
1.89 kB
| import asyncio | |
| import pytest | |
| import pytest_asyncio | |
| from lerobot_arena_client import RoboticsConsumer, RoboticsProducer | |
| # Default server URL for tests | |
| TEST_SERVER_URL = "http://localhost:8000" | |
| def event_loop(): | |
| """Create an instance of the default event loop for the test session.""" | |
| loop = asyncio.get_event_loop_policy().new_event_loop() | |
| yield loop | |
| loop.close() | |
| async def producer(): | |
| """Create a RoboticsProducer instance for testing.""" | |
| client = RoboticsProducer(TEST_SERVER_URL) | |
| yield client | |
| if client.is_connected(): | |
| await client.disconnect() | |
| async def consumer(): | |
| """Create a RoboticsConsumer instance for testing.""" | |
| client = RoboticsConsumer(TEST_SERVER_URL) | |
| yield client | |
| if client.is_connected(): | |
| await client.disconnect() | |
| async def test_room(producer): | |
| """Create a test room and clean up after test.""" | |
| room_id = await producer.create_room() | |
| yield room_id | |
| # Cleanup: delete the room after test | |
| try: | |
| await producer.delete_room(room_id) | |
| except Exception: | |
| pass # Room might already be deleted | |
| async def connected_producer(producer, test_room): | |
| """Create a connected producer in a test room.""" | |
| await producer.connect(test_room) | |
| yield producer, test_room | |
| async def connected_consumer(consumer, test_room): | |
| """Create a connected consumer in a test room.""" | |
| await consumer.connect(test_room) | |
| yield consumer, test_room | |
| async def producer_consumer_pair(producer, consumer, test_room): | |
| """Create a connected producer-consumer pair in the same room.""" | |
| await producer.connect(test_room) | |
| await consumer.connect(test_room) | |
| yield producer, consumer, test_room | |