diff --git a/tests/tests_bec_ipython_client/test_lamni_tomo_alignment_scan.py b/tests/tests_bec_ipython_client/test_lamni_tomo_alignment_scan.py index 2fff068..258dc92 100644 --- a/tests/tests_bec_ipython_client/test_lamni_tomo_alignment_scan.py +++ b/tests/tests_bec_ipython_client/test_lamni_tomo_alignment_scan.py @@ -13,7 +13,11 @@ import numpy as np import pytest import csaxs_bec.bec_ipython_client.plugins.LamNI.lamni as lamni_module -from csaxs_bec.bec_ipython_client.plugins.LamNI.lamni import LamNI, _ProgressProxy +from csaxs_bec.bec_ipython_client.plugins.LamNI.lamni import ( + LamNI, + _AlignmentScanProgressProxy, + _ProgressProxy, +) class FakeClient: @@ -54,12 +58,16 @@ def make_lamni(monkeypatch, xray_eye_fit=None): obj = object.__new__(LamNI) obj.client = FakeClient() obj._progress_proxy = _ProgressProxy(obj.client) + obj._alignment_scan_progress_proxy = _AlignmentScanProgressProxy(obj.client) obj.tomo_id = -1 obj.sample_name = "test" obj.OMNYTools = types.SimpleNamespace(printgreenbold=lambda msg: None) obj._scilog_calls = [] obj.write_to_scilog = lambda content, tags: obj._scilog_calls.append((content, tags)) obj.leye_out = lambda: None + obj.lamnigui_show_alignment_progress = lambda: None + obj._lamnigui_update_alignment_progress = lambda: None + obj._confirm_sequence_override = lambda *a, **k: True if xray_eye_fit is not None: obj.client.set_global_var("tomo_fit_xray_eye", xray_eye_fit) @@ -75,6 +83,7 @@ def make_lamni(monkeypatch, xray_eye_fit=None): def test_tomo_alignment_scan_aborts_without_xray_eye_fit(monkeypatch): lamni = make_lamni(monkeypatch, xray_eye_fit=None) + lamni._confirm_sequence_override = lambda *a, **k: False calls = [] lamni.tomo_scan_projection = lambda angle: calls.append(angle) diff --git a/tests/tests_bec_ipython_client/test_lamni_tomo_angles.py b/tests/tests_bec_ipython_client/test_lamni_tomo_angles.py index 0246079..0b42093 100644 --- a/tests/tests_bec_ipython_client/test_lamni_tomo_angles.py +++ b/tests/tests_bec_ipython_client/test_lamni_tomo_angles.py @@ -169,6 +169,10 @@ def make_lamni_for_tomo_scan( obj.lamnigui_show_progress = lambda: None obj.at_each_angle_hook = None obj.OMNYTools = types.SimpleNamespace(printgreenbold=lambda msg: None) + # These tests exercise tomo_scan()'s account-handling/heartbeat/progress-GUI + # logic, not the fine-alignment confirmation gate -- bypass it so it never + # blocks on input(). + obj._confirm_sequence_override = lambda *a, **k: True monkeypatch.setitem( builtins.__dict__, "bec", @@ -184,18 +188,24 @@ def make_lamni_for_tomo_scan( return obj -def test_tomo_scan_skips_sample_database_when_no_active_account(monkeypatch): - """Empty active_account (e.g. a dev/sim session) must not crash and must - not try to register a sample -- tomo_id falls back to 0, mirroring - Flomni.tomo_scan()'s identical guard.""" +def test_tomo_scan_registers_sample_even_without_active_account(monkeypatch): + """Empty active_account (e.g. a dev/sim session) must not crash -- it is + still passed through to add_sample_database() (as ""), letting + TomoIDManager.register() decide the outcome (test-server registration) + instead of pre-empting it with a hardcoded tomo_id=0.""" lamni = make_lamni_for_tomo_scan(monkeypatch, 45.0, active_account="") - lamni.add_sample_database = lambda *a, **k: (_ for _ in ()).throw( - AssertionError("add_sample_database must not be called with no active account") - ) + recorded = {} + + def _fake_add_sample_database(samplename, date, eaccount, scan_number, setup, info, user): + recorded["eaccount"] = eaccount + return 7 + + lamni.add_sample_database = _fake_add_sample_database lamni.tomo_scan() - assert lamni.tomo_id == 0 + assert recorded["eaccount"] == "" + assert lamni.tomo_id == 7 def test_tomo_scan_registers_sample_with_plain_string_account(monkeypatch): diff --git a/tests/tests_bec_ipython_client/test_lamni_tomo_queue.py b/tests/tests_bec_ipython_client/test_lamni_tomo_queue.py index 3e5a233..67c9692 100644 --- a/tests/tests_bec_ipython_client/test_lamni_tomo_queue.py +++ b/tests/tests_bec_ipython_client/test_lamni_tomo_queue.py @@ -122,7 +122,7 @@ def test_tomo_queue_execute_runs_fresh_job_then_marks_done(): lamni.tomo_queue_add(label="job1") lamni.tomo_queue_execute() - assert calls == [("scan", (), {})] + assert calls == [("scan", (), {"interactive": False})] job = lamni._tomo_queue_proxy.as_list()[0] assert job["status"] == "done" diff --git a/tests/tests_bec_ipython_client/test_x_ray_eye_align.py b/tests/tests_bec_ipython_client/test_x_ray_eye_align.py index 3bbc25a..4404582 100644 --- a/tests/tests_bec_ipython_client/test_x_ray_eye_align.py +++ b/tests/tests_bec_ipython_client/test_x_ray_eye_align.py @@ -158,6 +158,10 @@ def _make_calibration_align(client): align.lamni.loptics_out = mock.MagicMock() align.lamni.losa_out = mock.MagicMock() align.lamni.lamnigui_show_xeyealign = mock.MagicMock() + # _sync_sample_name(prompt=True) calls lamni._get_val(), which reads from + # input() -- keep the current default (as if Enter was pressed) instead of + # blocking on stdin. + align.lamni._get_val = lambda msg, default_value, data_type: default_value # Replace the real Scans proxy (which would try to talk to a live scan # server) with a plain mock -- these tests only care that # lamni_move_to_scan_center is *called* with the right kwargs.