Update testenvs with minimal app config

Worked out by Beth Probert
This commit is contained in:
jaknapper 2026-05-12 19:13:35 +01:00
parent ab25705edc
commit 5962c80fdc
4 changed files with 15 additions and 4 deletions

View file

@ -5,6 +5,8 @@ test_simulated_camera.py and for testing the consistency of camera APIs see
test_cameras.py. test_cameras.py.
""" """
import tempfile
import numpy as np import numpy as np
import pytest import pytest
from PIL import Image from PIL import Image
@ -19,7 +21,8 @@ from ..shared_utils.lt_test_utils import LabThingsTestEnv
def test_env() -> LabThingsTestEnv: def test_env() -> LabThingsTestEnv:
"""Yield a test environment with the Simulated Camera and Dummy Stage.""" """Yield a test environment with the Simulated Camera and Dummy Stage."""
thing_conf = {"camera": SimulatedCamera, "stage": DummyStage} thing_conf = {"camera": SimulatedCamera, "stage": DummyStage}
with LabThingsTestEnv(things=thing_conf) as env: app_config = {"data_folder": tempfile.gettempdir()}
with LabThingsTestEnv(things=thing_conf, application_config=app_config) as env:
yield env yield env

View file

@ -1,6 +1,7 @@
"""Tests that captures have the expected metadata.""" """Tests that captures have the expected metadata."""
import json import json
import tempfile
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
@ -99,7 +100,8 @@ def test_env() -> LabThingsTestEnv:
"stage": DummyStage, "stage": DummyStage,
"bg_channel_deviations_luv": ChannelDeviationLUV, "bg_channel_deviations_luv": ChannelDeviationLUV,
} }
with LabThingsTestEnv(things=thing_conf) as env: app_config = {"data_folder": tempfile.gettempdir()}
with LabThingsTestEnv(things=thing_conf, application_config=app_config) as env:
yield env yield env

View file

@ -1,6 +1,7 @@
"""Test the functionality specific to the simulated camera.""" """Test the functionality specific to the simulated camera."""
import logging import logging
import tempfile
import time import time
import numpy as np import numpy as np
@ -27,7 +28,10 @@ def test_env() -> LabThingsTestEnv:
"stage": DummyStage, "stage": DummyStage,
"bg_channel_deviations_luv": ChannelDeviationLUV, "bg_channel_deviations_luv": ChannelDeviationLUV,
} }
with LabThingsTestEnv(things=thing_conf) as env:
app_config = {"data_folder": tempfile.gettempdir()}
with LabThingsTestEnv(things=thing_conf, application_config=app_config) as env:
yield env yield env

View file

@ -2,6 +2,7 @@
import itertools import itertools
import logging import logging
import tempfile
import threading import threading
import time import time
from dataclasses import dataclass from dataclasses import dataclass
@ -176,7 +177,8 @@ def test_direction_inversion(dummy_stage):
def test_direction_errors_local_and_http(): def test_direction_errors_local_and_http():
"""Check for expected errors both locally and over http.""" """Check for expected errors both locally and over http."""
thing_conf = {"camera": SimulatedCamera, "stage": DummyStage} thing_conf = {"camera": SimulatedCamera, "stage": DummyStage}
with LabThingsTestEnv(things=thing_conf) as test_env: app_config = {"data_folder": tempfile.gettempdir()}
with LabThingsTestEnv(things=thing_conf, application_config=app_config) as test_env:
dummy_stage = test_env.get_thing_by_type(DummyStage) dummy_stage = test_env.get_thing_by_type(DummyStage)
stage_client = test_env.get_thing_client("stage") stage_client = test_env.get_thing_client("stage")