From 658bafe33de5c9a74f83eec6e0136621ddd668b6 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Tue, 29 Sep 2026 18:04:10 -0400 Subject: [PATCH] test: verify dependency-owned ImageJ environment in fresh children (#224) --- .../test_mcp_dev_client_persistent_session.py | 36 +++++++++++++++++++ tests/unit/test_process_environment.py | 7 ++++ 2 files changed, 43 insertions(+) diff --git a/tests/unit/test_mcp_dev_client_persistent_session.py b/tests/unit/test_mcp_dev_client_persistent_session.py index 26daeb201a..867be6f5cf 100644 --- a/tests/unit/test_mcp_dev_client_persistent_session.py +++ b/tests/unit/test_mcp_dev_client_persistent_session.py @@ -10,6 +10,10 @@ from dataclasses import replace import pytest +from polystore.imagej_distribution import ( + FijiArchiveDistribution, + ImageJArchiveDownloadPolicy, +) import openhcs.mcp.dev_client as dev_client from openhcs.pyqt_gui.config import ( @@ -57,6 +61,38 @@ def test_child_environment_does_not_invent_ui_config_override(monkeypatch) -> No assert UIConfigCacheEnvironment.cache_file_path_key not in environment +def test_fresh_child_consumes_declared_imagej_cache_and_download_policy( + tmp_path, monkeypatch +) -> None: + cache_root = tmp_path / "shared-imagej-bundles" + monkeypatch.setenv( + FijiArchiveDistribution.cache_root_environment_key, str(cache_root) + ) + monkeypatch.setenv( + ImageJArchiveDownloadPolicy.allow_download_environment_key, "false" + ) + result = subprocess.run( + [ + sys.executable, + "-c", + ( + "import json; " + "from polystore.imagej_distribution import " + "FijiArchiveDistribution, ImageJArchiveDownloadPolicy; " + "print(json.dumps([str(FijiArchiveDistribution.cache_root_from_environment()), " + "ImageJArchiveDownloadPolicy.from_environment().allow_download]))" + ), + ], + env=dev_client.McpDevServerSpec(sys.executable).environment(), + capture_output=True, + text=True, + check=True, + timeout=30, + ) + assert json.loads(result.stdout) == [str(cache_root), False] + assert not cache_root.exists() + + def test_multi_call_command_honors_its_declared_timeout_floor() -> None: parser = dev_client._build_parser() default_args = parser.parse_args( diff --git a/tests/unit/test_process_environment.py b/tests/unit/test_process_environment.py index 5c0b2cee47..f3ba064ec5 100644 --- a/tests/unit/test_process_environment.py +++ b/tests/unit/test_process_environment.py @@ -1,5 +1,10 @@ from pathlib import PureWindowsPath +from polystore.imagej_distribution import ( + FijiArchiveDistribution, + ImageJArchiveDownloadPolicy, +) + from openhcs.agent.runtime_platform import WindowsAgentRuntimePlatformAuthority from openhcs.resources.brand import BRAND_PRODUCT_NAME from openhcs.utils.environment import OpenHCSProcessEnvironment @@ -11,6 +16,8 @@ def test_process_environment_owns_inherited_mode_selectors() -> None: OpenHCSProcessEnvironment.headless_key, OpenHCSProcessEnvironment.numba_cache_key, OpenHCSProcessEnvironment.use_threading_key, + FijiArchiveDistribution.cache_root_environment_key, + ImageJArchiveDownloadPolicy.allow_download_environment_key, )