diff --git a/tests/unit_tests/test_simulated_camera.py b/tests/unit_tests/test_simulated_camera.py index 2c7d4a81..8b93152d 100644 --- a/tests/unit_tests/test_simulated_camera.py +++ b/tests/unit_tests/test_simulated_camera.py @@ -2,11 +2,13 @@ import logging import time +from io import BytesIO import numpy as np import pytest from hypothesis import given from hypothesis import strategies as st +from PIL import Image from pydantic import ValidationError import labthings_fastapi as lt @@ -44,6 +46,19 @@ def stage(test_env) -> lt.Thing: return test_env.get_thing_by_type(DummyStage) +def test_snapshot(test_env) -> lt.Thing: + """Check the snapshot GET request returns an image.""" + http_client = test_env.get_thing_client("camera").client + response = http_client.get("camera/snapshot") + response.raise_for_status() + assert response.headers["content-type"] == "image/jpeg" + image = Image.open(BytesIO(response.content)) + + assert image.format == "JPEG" + assert image.width == 320 + assert image.height == 240 + + def test_downsample_shape_2d(): """Test downsampling for 2D array.""" shape_2d = (100, 80)