Update legacy_api.py test_sangaboard and test_server_cli so tests pass for labthings-fastapi 0.0.12

This commit is contained in:
Julian Stirling 2025-12-14 20:53:33 +00:00
parent 70fc3516e6
commit dec90f5b6b
3 changed files with 7 additions and 5 deletions

View file

@ -4,6 +4,8 @@ import logging
import pytest
from labthings_fastapi.testing import create_thing_without_server
from openflexure_microscope_server.things.stage.sangaboard import (
RECOMMENDED_VERSION,
REQUIRED_VERSION,
@ -14,7 +16,7 @@ from openflexure_microscope_server.things.stage.sangaboard import (
@pytest.fixture
def mock_sanga_thing(mocker):
"""Return a Sangaboard thing with a MagicMock for self._sangaboard."""
sanga_thing = SangaboardThing()
sanga_thing = create_thing_without_server(SangaboardThing)
sanga_thing._sangaboard = mocker.MagicMock()
return sanga_thing

View file

@ -28,10 +28,10 @@ def test_successful_start(mocker, caplog):
# Create a mock for the camera so we can check the MJPEG streams are closed on
# shutdown.
mock_camera = mocker.Mock()
mock_server.things = {"/camera/": mock_camera}
mock_server.things = {"camera": mock_camera}
# Mock the LabThings function that returns the server so we have a mock server
mocker.patch(
"openflexure_microscope_server.server.lt.cli.server_from_config",
"openflexure_microscope_server.server.lt.ThingServer.from_config",
return_value=mock_server,
)
# Also mock customisation or it will try to access the hard drive and make files.
@ -78,7 +78,7 @@ def test_failed_customise(mocker):
mock_server = mocker.Mock()
# Mock the LabThings function that returns the server so we have a mock server
mocker.patch(
"openflexure_microscope_server.server.lt.cli.server_from_config",
"openflexure_microscope_server.server.lt.ThingServer.from_config",
return_value=mock_server,
)
# Also mock customisation or it will try to access the hard drive and make files.