Updating for changes related to NotConnectedToServerErrors
This commit is contained in:
parent
8ed76b4baf
commit
baf0ff9a11
2 changed files with 7 additions and 16 deletions
|
|
@ -35,7 +35,7 @@ from PIL import Image
|
|||
from pydantic import BaseModel, BeforeValidator
|
||||
|
||||
import labthings_fastapi as lt
|
||||
from labthings_fastapi.exceptions import NotConnectedToServerError
|
||||
from labthings_fastapi.exceptions import ServerNotRunningError
|
||||
|
||||
from openflexure_microscope_server.background_detect import ChannelBlankError
|
||||
from openflexure_microscope_server.ui import (
|
||||
|
|
@ -160,13 +160,13 @@ class StreamingPiCamera2(BaseCamera):
|
|||
# connected to the server if tuning is saved to disk.
|
||||
try:
|
||||
self.tuning = copy.deepcopy(self.default_tuning)
|
||||
except NotConnectedToServerError:
|
||||
except ServerNotRunningError:
|
||||
# This will throw an error after setting as we are not connected to
|
||||
# a server. But we know this, so we ignore the error.
|
||||
pass
|
||||
|
||||
# Also set the colour gains based on the tuning. Set to _colour_gains to not
|
||||
# trigger a NotConnectedToServerError
|
||||
# trigger a ServerNotRunningError
|
||||
self._colour_gains = tf_utils.get_colour_gains_from_lst(self.tuning)
|
||||
|
||||
stream_resolution: tuple[int, int] = lt.property(default=(820, 616))
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ from hypothesis import HealthCheck, given, settings
|
|||
from hypothesis import strategies as st
|
||||
|
||||
import labthings_fastapi as lt
|
||||
from labthings_fastapi.exceptions import NotConnectedToServerError
|
||||
from labthings_fastapi.testing import create_thing_without_server
|
||||
|
||||
from openflexure_microscope_server.things.stage import (
|
||||
|
|
@ -86,18 +85,10 @@ def test_override_base_movement():
|
|||
create_thing_without_server(BadStage2)
|
||||
|
||||
|
||||
def _set_axis_direction(dummy_stage, direction):
|
||||
"""Set the axis direction directly even if not connected to server."""
|
||||
try:
|
||||
dummy_stage.axis_inverted = direction
|
||||
except NotConnectedToServerError:
|
||||
pass
|
||||
|
||||
|
||||
def test_apply_axis_direction_all_pos(dummy_stage):
|
||||
"""Test the apply axis direction function behaves as expected when axis +v3."""
|
||||
# Directly create a stage not through a ThingServer to access private methods
|
||||
_set_axis_direction(dummy_stage, {"x": False, "y": False, "z": False})
|
||||
dummy_stage.axis_inverted = {"x": False, "y": False, "z": False}
|
||||
|
||||
# A list of positions to try
|
||||
positions = [
|
||||
|
|
@ -117,7 +108,7 @@ def test_apply_axis_direction_all_pos(dummy_stage):
|
|||
def test_apply_axis_direction_mixed(dummy_stage):
|
||||
"""Test the apply axis direction function behaves as expected when axis dirs are mixed."""
|
||||
# Make x and z negative
|
||||
_set_axis_direction(dummy_stage, {"x": True, "y": False, "z": True})
|
||||
dummy_stage.axis_inverted = {"x": True, "y": False, "z": True}
|
||||
|
||||
# A list of (input position, output position) to try
|
||||
position_pairs = [
|
||||
|
|
@ -210,7 +201,7 @@ def _test_move_relative(dummy_stage, axis_inverted, path):
|
|||
:param path: The 3d path to move over, generated by hypothesis.
|
||||
"""
|
||||
cancel = MockCancel()
|
||||
_set_axis_direction(dummy_stage, axis_inverted)
|
||||
dummy_stage.axis_inverted = axis_inverted
|
||||
# Explicitly do axes calculation here to check logic in main code.
|
||||
x_dir = -1 if axis_inverted["x"] else 1
|
||||
y_dir = -1 if axis_inverted["y"] else 1
|
||||
|
|
@ -267,7 +258,7 @@ def _test_move_absolute(dummy_stage, axis_inverted, path):
|
|||
:param path: The 3d path to move over, generated by hypothesis.
|
||||
"""
|
||||
cancel = MockCancel()
|
||||
_set_axis_direction(dummy_stage, axis_inverted)
|
||||
dummy_stage.axis_inverted = axis_inverted
|
||||
# Explicitly do axes calculation here to check logic in main code.
|
||||
x_dir = -1 if axis_inverted["x"] else 1
|
||||
y_dir = -1 if axis_inverted["y"] else 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue