diff --git a/src/openflexure_microscope_server/server/legacy_api.py b/src/openflexure_microscope_server/server/legacy_api.py index ff41c2bc..7d0e7265 100644 --- a/src/openflexure_microscope_server/server/legacy_api.py +++ b/src/openflexure_microscope_server/server/legacy_api.py @@ -38,7 +38,7 @@ def add_v2_endpoints(thing_server: lt.ThingServer) -> None: @app.head("/api/v2/streams/snapshot") async def thumbnail() -> JPEGResponse: """Return a low-resolution snapshot, for compatibility with OF connect.""" - blob = await thing_server.things["/camera/"].lores_mjpeg_stream.grab_frame() + blob = await thing_server.things["camera"].lores_mjpeg_stream.grab_frame() return JPEGResponse(blob) @app.get("/api/v2/instrument/settings/name") diff --git a/tests/test_sangaboard.py b/tests/test_sangaboard.py index bd9ec103..b22ef1af 100644 --- a/tests/test_sangaboard.py +++ b/tests/test_sangaboard.py @@ -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 diff --git a/tests/test_server_cli.py b/tests/test_server_cli.py index 94bf057d..dde9879f 100644 --- a/tests/test_server_cli.py +++ b/tests/test_server_cli.py @@ -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.