Split up generic camera tests and simulation specific ones.
This commit is contained in:
parent
fa89f24477
commit
dfe50f5c56
2 changed files with 33 additions and 10 deletions
|
|
@ -1,4 +1,9 @@
|
||||||
"""Use the Simulation camera to test base camera functionality."""
|
"""Use the Simulated camera to test base camera functionality.
|
||||||
|
|
||||||
|
For tests of functionality specific to the simulated camera see
|
||||||
|
test_simulated_camera.py and for testing the consistency of camera APIs see
|
||||||
|
test_cameras.py.
|
||||||
|
"""
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -58,12 +63,3 @@ def test_handle_broken_frame(test_env):
|
||||||
for _i in range(15):
|
for _i in range(15):
|
||||||
array = camera.grab_as_array()
|
array = camera.grab_as_array()
|
||||||
assert isinstance(array, np.ndarray)
|
assert isinstance(array, np.ndarray)
|
||||||
|
|
||||||
|
|
||||||
def test_simulation_cam_calibration(test_env):
|
|
||||||
"""Test that the simulated camera can be calibrated and reports calibration correctly."""
|
|
||||||
camera = test_env.get_thing_by_type(SimulatedCamera)
|
|
||||||
assert camera.calibration_required
|
|
||||||
camera.full_auto_calibrate()
|
|
||||||
assert not camera.calibration_required
|
|
||||||
assert camera.background_detector_status.ready
|
|
||||||
27
tests/unit_tests/test_simulated_camera.py
Normal file
27
tests/unit_tests/test_simulated_camera.py
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
"""Test the functionality specific to the simulated camera."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
import labthings_fastapi as lt
|
||||||
|
|
||||||
|
from openflexure_microscope_server.things.camera.simulation import SimulatedCamera
|
||||||
|
from openflexure_microscope_server.things.stage.dummy import DummyStage
|
||||||
|
|
||||||
|
from ..shared_utils.lt_test_utils import LabThingsTestEnv
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def test_env() -> lt.ThingClient:
|
||||||
|
"""Yield a test environment with the Simulated Camera and Dummy Stage."""
|
||||||
|
thing_conf = {"camera": SimulatedCamera, "stage": DummyStage}
|
||||||
|
with LabThingsTestEnv(things=thing_conf) as env:
|
||||||
|
yield env
|
||||||
|
|
||||||
|
|
||||||
|
def test_simulation_cam_calibration(test_env):
|
||||||
|
"""Test that the simulated camera can be calibrated and reports calibration correctly."""
|
||||||
|
camera = test_env.get_thing_by_type(SimulatedCamera)
|
||||||
|
assert camera.calibration_required
|
||||||
|
camera.full_auto_calibrate()
|
||||||
|
assert not camera.calibration_required
|
||||||
|
assert camera.background_detector_status.ready
|
||||||
Loading…
Add table
Add a link
Reference in a new issue