Further improve picamera tests to reuse fixtures and context managers.
This commit is contained in:
parent
995a464ba2
commit
2010e8eeb2
4 changed files with 51 additions and 67 deletions
33
hardware-specific-tests/picamera2/conftest.py
Normal file
33
hardware-specific-tests/picamera2/conftest.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
"""Shared fixtures for picamera tests."""
|
||||
|
||||
import pytest
|
||||
|
||||
import labthings_fastapi as lt
|
||||
|
||||
from openflexure_microscope_server.things.camera.picamera import StreamingPiCamera2
|
||||
|
||||
from .cam_test_utils import camera_test_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def picamera_thing() -> StreamingPiCamera2:
|
||||
"""Return a StreamingPiCamera2 Thing.
|
||||
|
||||
This is the Thing that the fixture picamera_client uses. It can be used to probe
|
||||
the Thing directly to check actions had the expected response.
|
||||
"""
|
||||
return StreamingPiCamera2()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def picamera_client(picamera_thing) -> lt.ThingClient:
|
||||
"""Initialise a test picamera_client for the StreamingPiCamera2 Thing.
|
||||
|
||||
This fixture:
|
||||
|
||||
* Sets up a ThingServer,
|
||||
* Registers a StreamingPiCamera2 instance at the "/camera/" endpoint
|
||||
* Provides a ThingClient for interacting with it during tests.
|
||||
"""
|
||||
with camera_test_client(cam=picamera_thing) as picamera_client:
|
||||
yield picamera_client
|
||||
Loading…
Add table
Add a link
Reference in a new issue