Update legacy_api.py test_sangaboard and test_server_cli so tests pass for labthings-fastapi 0.0.12
This commit is contained in:
parent
70fc3516e6
commit
dec90f5b6b
3 changed files with 7 additions and 5 deletions
|
|
@ -38,7 +38,7 @@ def add_v2_endpoints(thing_server: lt.ThingServer) -> None:
|
||||||
@app.head("/api/v2/streams/snapshot")
|
@app.head("/api/v2/streams/snapshot")
|
||||||
async def thumbnail() -> JPEGResponse:
|
async def thumbnail() -> JPEGResponse:
|
||||||
"""Return a low-resolution snapshot, for compatibility with OF connect."""
|
"""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)
|
return JPEGResponse(blob)
|
||||||
|
|
||||||
@app.get("/api/v2/instrument/settings/name")
|
@app.get("/api/v2/instrument/settings/name")
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import logging
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from labthings_fastapi.testing import create_thing_without_server
|
||||||
|
|
||||||
from openflexure_microscope_server.things.stage.sangaboard import (
|
from openflexure_microscope_server.things.stage.sangaboard import (
|
||||||
RECOMMENDED_VERSION,
|
RECOMMENDED_VERSION,
|
||||||
REQUIRED_VERSION,
|
REQUIRED_VERSION,
|
||||||
|
|
@ -14,7 +16,7 @@ from openflexure_microscope_server.things.stage.sangaboard import (
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_sanga_thing(mocker):
|
def mock_sanga_thing(mocker):
|
||||||
"""Return a Sangaboard thing with a MagicMock for self._sangaboard."""
|
"""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()
|
sanga_thing._sangaboard = mocker.MagicMock()
|
||||||
return sanga_thing
|
return sanga_thing
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
# Create a mock for the camera so we can check the MJPEG streams are closed on
|
||||||
# shutdown.
|
# shutdown.
|
||||||
mock_camera = mocker.Mock()
|
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
|
# Mock the LabThings function that returns the server so we have a mock server
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
"openflexure_microscope_server.server.lt.cli.server_from_config",
|
"openflexure_microscope_server.server.lt.ThingServer.from_config",
|
||||||
return_value=mock_server,
|
return_value=mock_server,
|
||||||
)
|
)
|
||||||
# Also mock customisation or it will try to access the hard drive and make files.
|
# 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_server = mocker.Mock()
|
||||||
# Mock the LabThings function that returns the server so we have a mock server
|
# Mock the LabThings function that returns the server so we have a mock server
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
"openflexure_microscope_server.server.lt.cli.server_from_config",
|
"openflexure_microscope_server.server.lt.ThingServer.from_config",
|
||||||
return_value=mock_server,
|
return_value=mock_server,
|
||||||
)
|
)
|
||||||
# Also mock customisation or it will try to access the hard drive and make files.
|
# Also mock customisation or it will try to access the hard drive and make files.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue