From bef4193d8f23cbfd2988fe7cd0b914ab48cca759 Mon Sep 17 00:00:00 2001 From: appleb_m Date: Mon, 27 Apr 2026 17:20:29 +0200 Subject: [PATCH] gitea workflows: updated pyproject toml dependencies, tellupdater updates and fix error in test_beamcenter_fit_no_contours --- pyproject.toml | 11 +++++++++++ src/aare/daq/tellupdater.py | 10 ++++++---- tests/unit/daq/test_beamcenterfit.py | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1b5bd2f5..0a0e759d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,15 @@ dependencies = [ "httpx>=0.28.1", ] +[project.optional-dependencies] +test = [ + "pytest==9.0.3", + "pytest-cov==7.1.0", + "pytest-mock==3.14.0", + "pytest-qt==4.4.0", + "pytest-asyncio==0.25.3", +] + [lint] ignore = ["F401", "F541", "W503", "W504"] @@ -45,6 +54,8 @@ url = "https://gitea.psi.ch/api/packages/mx/pypi/simple" testpaths = ["tests"] python_files = ["test_*.py"] norecursedirs = ["scripts", ".venv", "logs", "docs"] +asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "function" markers = [ "integration: tests that require external systems or secrets", ] diff --git a/src/aare/daq/tellupdater.py b/src/aare/daq/tellupdater.py index 8a18a77a..7e329ddf 100644 --- a/src/aare/daq/tellupdater.py +++ b/src/aare/daq/tellupdater.py @@ -15,6 +15,10 @@ from aare.common.beamline import MXBeamline, mx_beamline logger = setup_logger("aareDAQ") +# Initialize TELL client and DB wrapper to None so they can be patched in tests +tell_client = None +aare_db = None + # Track current state current_pucks = [] last_pucks_sent = [] @@ -196,6 +200,8 @@ def main(): if __name__ == "__main__": # Configuration + tell_client = TellClient(bl=mx_beamline()) + aare_db = AareWrapper(bl=mx_beamline()) beamline = mx_beamline() SLOT_IDENTIFIER = beamline.value.upper() @@ -205,8 +211,4 @@ if __name__ == "__main__": WS_HEADERS = [f"X-Shared-Password: {os.getenv('AAREDB_SHARED_PASSWORD')}"] print(WS_HEADERS) - # Initialize TELL client and DB wrapper - # Use your beamline enum/value - tell_client = TellClient(bl=beamline) - aare_db = AareWrapper(bl=beamline) main() diff --git a/tests/unit/daq/test_beamcenterfit.py b/tests/unit/daq/test_beamcenterfit.py index 74d39c0d..769a09e8 100644 --- a/tests/unit/daq/test_beamcenterfit.py +++ b/tests/unit/daq/test_beamcenterfit.py @@ -51,7 +51,7 @@ def test_beamcenter_fit_no_converge(): def test_beamcenter_fit_no_contours(): # Completely black image, max(contours) will fail image = np.zeros((100, 100), dtype=np.uint8) - with pytest.raises(ValueError, match="max\(\) (arg is an empty sequence|iterable argument is empty)"): + with pytest.raises(ValueError, match=r"max\(\) (arg is an empty sequence|iterable argument is empty)"): beamcenter_fit(image) def test_beamcenter_fit_small_blob():