"""Fixtures for end-to-end tomo-queue tests against a running flOMNI sim. Deliberately does NOT use the shipped ``bec_client_lib_with_demo_config`` / ``bec_ipython_client_with_demo_config`` fixtures from pytest_bec_e2e: both call ``bec.config.load_demo_config(force=True)``, which against a running sim session overwrites the loaded simulated-flOMNI device config with BEC's demo devices. See TOMO_QUEUE_TESTING.md section 3. """ import pytest from _bootstrap import build_flomni, shutdown _QUEUE_VAR = "tomo_queue" _PROGRESS_VAR = "tomo_progress" @pytest.fixture def flomni_sim(bec_redis_fixture, bec_services_config_file_path, bec_servers): """A live ``Flomni`` instance attached to the already-running sim session. See ``_bootstrap.build_flomni()`` for what connecting/constructing this involves and why. The ``tomo_queue`` / ``tomo_progress`` global vars are snapshotted before the test and restored after, so tests don't leak queue/progress state into each other or into a real operator's session on the same sim. The queue is also reset to empty at setup: it lives in the shared sim Redis, so a prior crashed run or manual debugging session can leave stale entries behind that would otherwise contaminate every test that assumes it starts from an empty queue. """ bec, flomni = build_flomni(bec_services_config_file_path) queue_snapshot = bec.get_global_var(_QUEUE_VAR) progress_snapshot = bec.get_global_var(_PROGRESS_VAR) bec.set_global_var(_QUEUE_VAR, []) bec.set_global_var(_PROGRESS_VAR, None) try: yield flomni finally: bec.set_global_var(_QUEUE_VAR, queue_snapshot) bec.set_global_var(_PROGRESS_VAR, progress_snapshot) shutdown(bec)