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 44045820..9987ebe4 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 @@ -16,6 +16,10 @@ from csaxs_bec.bec_ipython_client.plugins.LamNI.x_ray_eye_align import XrayEyeAl # pylint: disable=protected-access XRAY_EYE_ALIGN = "csaxs_bec.bec_ipython_client.plugins.LamNI.x_ray_eye_align" +# find_rotation_center()'s y/n prompts go through OMNYTools.yesno(), which +# calls the real input() from this module -- not from XRAY_EYE_ALIGN -- so +# that's what needs patching to keep these tests from blocking on stdin. +OMNY_GENERAL_TOOLS = "csaxs_bec.bec_ipython_client.plugins.OMNY_shared.omny_general_tools" class RTControllerMock: @@ -234,7 +238,7 @@ def test_extended_calibration_accumulates_shift_across_iterations(bec_client_moc with mock.patch(f"{XRAY_EYE_ALIGN}.dev", dev_mock): with mock.patch(f"{XRAY_EYE_ALIGN}.umv"): with mock.patch(f"{XRAY_EYE_ALIGN}.time.sleep"): - with mock.patch(f"{XRAY_EYE_ALIGN}.input", side_effect=["n", "y"]): + with mock.patch(f"{OMNY_GENERAL_TOOLS}.input", side_effect=["n", "y"]): align.find_rotation_center(sample_type="extended", apply=False) calls = align.scans.lamni_move_to_scan_center.call_args_list @@ -309,7 +313,7 @@ def test_find_rotation_center_isolated_computes_midpoint(bec_client_mock): with mock.patch(f"{XRAY_EYE_ALIGN}.dev", dev_mock): with mock.patch(f"{XRAY_EYE_ALIGN}.umv"): with mock.patch(f"{XRAY_EYE_ALIGN}.time.sleep"): - with mock.patch(f"{XRAY_EYE_ALIGN}.input", return_value="y"): + with mock.patch(f"{OMNY_GENERAL_TOOLS}.input", return_value="y"): result = align.find_rotation_center(sample_type="isolated") # midpoint of (0.3,0.3) and (0.5,0.7) is (0.4, 0.5) -> @@ -337,7 +341,7 @@ def test_find_rotation_center_isolated_declines_apply(bec_client_mock): with mock.patch(f"{XRAY_EYE_ALIGN}.dev", dev_mock): with mock.patch(f"{XRAY_EYE_ALIGN}.umv"): with mock.patch(f"{XRAY_EYE_ALIGN}.time.sleep"): - with mock.patch(f"{XRAY_EYE_ALIGN}.input", return_value="n"): + with mock.patch(f"{OMNY_GENERAL_TOOLS}.input", return_value="n"): align.find_rotation_center(sample_type="isolated") dev_mock.lsamx.update_user_parameter.assert_not_called() @@ -364,7 +368,7 @@ def test_find_rotation_center_extended_iterates_until_happy(bec_client_mock): with mock.patch(f"{XRAY_EYE_ALIGN}.time.sleep"): # first iteration: "not happy" -> second iteration: "happy", # then accept the final apply prompt - with mock.patch(f"{XRAY_EYE_ALIGN}.input", side_effect=["n", "y", "y"]): + with mock.patch(f"{OMNY_GENERAL_TOOLS}.input", side_effect=["n", "y", "y"]): align.find_rotation_center(sample_type="extended") # one lamni_move_to_scan_center pair per iteration -> 2 iterations = 4 calls @@ -546,7 +550,7 @@ def test_find_rotation_center_smear_experimental_switches_live_view_signal(bec_c with mock.patch(f"{XRAY_EYE_ALIGN}.umv"): with mock.patch(f"{XRAY_EYE_ALIGN}.mv", return_value=report): with mock.patch(f"{XRAY_EYE_ALIGN}.time.sleep"): - with mock.patch(f"{XRAY_EYE_ALIGN}.input", side_effect=["y", "y"]): + with mock.patch(f"{OMNY_GENERAL_TOOLS}.input", side_effect=["y", "y"]): with mock.patch.object(align, "_save_smear_calibration_data"): align.find_rotation_center_smear_experimental() @@ -572,7 +576,7 @@ def test_find_rotation_center_smear_experimental_saves_composites_and_clicks(bec with mock.patch(f"{XRAY_EYE_ALIGN}.umv"): with mock.patch(f"{XRAY_EYE_ALIGN}.mv", return_value=report): with mock.patch(f"{XRAY_EYE_ALIGN}.time.sleep"): - with mock.patch(f"{XRAY_EYE_ALIGN}.input", side_effect=["y", "y"]): + with mock.patch(f"{OMNY_GENERAL_TOOLS}.input", side_effect=["y", "y"]): with mock.patch.object(align, "_save_smear_calibration_data") as save_mock: align.find_rotation_center_smear_experimental(sweep_deg=45.0)