Updating for changes related to NotConnectedToServerErrors

This commit is contained in:
Julian Stirling 2025-12-15 17:18:30 +00:00
parent 8ed76b4baf
commit baf0ff9a11
2 changed files with 7 additions and 16 deletions

View file

@ -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