Add unit test to check tuning is persistent after picamera calibration and modifying LST
This commit is contained in:
parent
ee2ef848b1
commit
e9c912d910
1 changed files with 41 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
"""Test data collection from the Raspberry Picamera."""
|
"""Test data collection from the Raspberry Picamera."""
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
@ -10,6 +11,8 @@ from openflexure_microscope_server.things.camera.picamera import (
|
||||||
MissingCalibrationError,
|
MissingCalibrationError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from .cam_test_utils import camera_test_client
|
||||||
|
|
||||||
|
|
||||||
def test_get_tuning_algo(picamera_thing):
|
def test_get_tuning_algo(picamera_thing):
|
||||||
"""Test that get_tuning algorithm retrieves tuning algorithms."""
|
"""Test that get_tuning algorithm retrieves tuning algorithms."""
|
||||||
|
|
@ -73,3 +76,41 @@ def test_calibration(picamera_thing, picamera_client):
|
||||||
# Green equalisation offset should be set to maximum.
|
# Green equalisation offset should be set to maximum.
|
||||||
assert picamera_thing.get_tuning_algo("rpi.geq")["offset"] == 65535
|
assert picamera_thing.get_tuning_algo("rpi.geq")["offset"] == 65535
|
||||||
assert picamera_thing.background_detector_status.ready
|
assert picamera_thing.background_detector_status.ready
|
||||||
|
|
||||||
|
|
||||||
|
def test_tuning_is_persistent():
|
||||||
|
"""Check that tuning file adjustments are persistent."""
|
||||||
|
# First check full auto-calibrate is persistent if same save dir is used.
|
||||||
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
|
with camera_test_client(settings_folder=tmpdir) as client:
|
||||||
|
initial_tuning = deepcopy(client.tuning)
|
||||||
|
client.full_auto_calibrate()
|
||||||
|
calibrated_tuning = deepcopy(client.tuning)
|
||||||
|
# Full auto calibrate should have saved the tuning.
|
||||||
|
assert initial_tuning != calibrated_tuning
|
||||||
|
|
||||||
|
# Reload the camera and server from scratch
|
||||||
|
with camera_test_client(settings_folder=tmpdir) as client:
|
||||||
|
initial_tuning = deepcopy(client.tuning)
|
||||||
|
# On reload the initial tuning is as it was when calibrated last run
|
||||||
|
assert initial_tuning == calibrated_tuning
|
||||||
|
# Set the lens shading to be flat
|
||||||
|
client.flat_lens_shading()
|
||||||
|
flat_tuning = deepcopy(client.tuning)
|
||||||
|
assert flat_tuning != calibrated_tuning
|
||||||
|
|
||||||
|
# Reload to check the flat lst persists
|
||||||
|
with camera_test_client(settings_folder=tmpdir) as client:
|
||||||
|
initial_tuning = deepcopy(client.tuning)
|
||||||
|
# On reload the initial tuning the flat tuning
|
||||||
|
assert initial_tuning == flat_tuning
|
||||||
|
# Reset the lens shading to what is in the default tuning file
|
||||||
|
client.reset_lens_shading()
|
||||||
|
flat_tuning = deepcopy(client.tuning)
|
||||||
|
assert flat_tuning != calibrated_tuning
|
||||||
|
|
||||||
|
# Reload the one more time to check the reset lst persists
|
||||||
|
with camera_test_client(settings_folder=tmpdir) as client:
|
||||||
|
initial_tuning = deepcopy(client.tuning)
|
||||||
|
# On reload the initial tuning the flat tuning
|
||||||
|
assert initial_tuning == flat_tuning
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue