diff --git a/tests/unit_tests/test_legacy_api.py b/tests/unit_tests/test_legacy_api.py index b040d064..78ca9915 100644 --- a/tests/unit_tests/test_legacy_api.py +++ b/tests/unit_tests/test_legacy_api.py @@ -6,13 +6,14 @@ from socket import gethostname # Import as ofm server to attempt to minimise confusion with server as a var in other # functions and also FastAPI `Server`. from openflexure_microscope_server.server import legacy_api +from openflexure_microscope_server.things.camera import BaseCamera def test_v2_endpoints(mocker): """Check that the expected v2 endpoints are added.""" mock_server = mocker.Mock() # Mock the camera thing to mocke the lores_mjpeg stream get_frame() - mock_server.things = {"camera": mocker.Mock()} + mock_server.things = {"camera": mocker.Mock(spec=BaseCamera)} mock_server.things["camera"].lores_mjpeg_stream.grab_frame = mocker.AsyncMock( return_value="Mock Frame" ) diff --git a/tests/unit_tests/test_server_cli.py b/tests/unit_tests/test_server_cli.py index 32a35b05..079cdf15 100644 --- a/tests/unit_tests/test_server_cli.py +++ b/tests/unit_tests/test_server_cli.py @@ -10,7 +10,7 @@ from fastapi import FastAPI from openflexure_microscope_server import server as ofm_server from openflexure_microscope_server.things.camera import BaseCamera -from .test_server_config import FULL_CONFIG +from .test_server_config import SIM_CONFIG def test_no_config(): @@ -41,7 +41,7 @@ def test_successful_start(mocker, caplog): mock_uvicorn_run = mocker.patch("openflexure_microscope_server.server.uvicorn.run") # Run the mock CLI - ofm_server.serve_from_cli(["-c", FULL_CONFIG]) + ofm_server.serve_from_cli(["-c", SIM_CONFIG]) # Check that the server was customised and the run assert mock_customise.call_count == 1 @@ -91,10 +91,10 @@ def test_failed_customise(mocker): # Running the mock CLI will error with pytest.raises(RuntimeError, match="Can't touch this"): - ofm_server.serve_from_cli(["-c", FULL_CONFIG]) + ofm_server.serve_from_cli(["-c", SIM_CONFIG]) # But with the fallback flag uvicorn run will be run - ofm_server.serve_from_cli(["-c", FULL_CONFIG, "--fallback"]) + ofm_server.serve_from_cli(["-c", SIM_CONFIG, "--fallback"]) assert mock_uvicorn_run.call_count == 1 # Get the fallback app passed to uvicorn tun