Test snapshot image is generated

This commit is contained in:
Julian Stirling 2026-06-21 14:07:00 +01:00
parent 4d5fd0b698
commit 267a02d0e8

View file

@ -2,11 +2,13 @@
import logging import logging
import time import time
from io import BytesIO
import numpy as np import numpy as np
import pytest import pytest
from hypothesis import given from hypothesis import given
from hypothesis import strategies as st from hypothesis import strategies as st
from PIL import Image
from pydantic import ValidationError from pydantic import ValidationError
import labthings_fastapi as lt import labthings_fastapi as lt
@ -44,6 +46,19 @@ def stage(test_env) -> lt.Thing:
return test_env.get_thing_by_type(DummyStage) 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(): def test_downsample_shape_2d():
"""Test downsampling for 2D array.""" """Test downsampling for 2D array."""
shape_2d = (100, 80) shape_2d = (100, 80)