From 6b54fbdb119c6340093521b11aa1f8dfb05025eb Mon Sep 17 00:00:00 2001 From: appel_c Date: Fri, 29 May 2026 14:04:16 +0200 Subject: [PATCH] tests(timepix): adapt tests after refactoring to redis --- superxas_bec/devices/timepix/timepix.py | 2 +- tests/tests_devices/test_timepix.py | 11 ++++++-- .../tests_devices/test_timepix_fly_backend.py | 26 ++++++++++++++----- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/superxas_bec/devices/timepix/timepix.py b/superxas_bec/devices/timepix/timepix.py index dcda59d..f3f2e06 100644 --- a/superxas_bec/devices/timepix/timepix.py +++ b/superxas_bec/devices/timepix/timepix.py @@ -190,7 +190,7 @@ class TimePixControl(ADBase): DETECTOR_SHAPE = (512, 1024) # Shape of the TimePix detector -TIMEPIX_FLY_BACKEND_DEFAULT_REDIS_TOPIC = "user/timepix_fly_backend/raw_data" +TIMEPIX_FLY_BACKEND_DEFAULT_REDIS_TOPIC = "public/timepix_fly_backend/raw_data" class Timepix(PSIDeviceBase, TimePixControl): diff --git a/tests/tests_devices/test_timepix.py b/tests/tests_devices/test_timepix.py index 2d426e8..c316937 100644 --- a/tests/tests_devices/test_timepix.py +++ b/tests/tests_devices/test_timepix.py @@ -133,6 +133,7 @@ def timepix(): scan_name="step_scan", scan_parameters={"exp_time": 0.1, "frames_per_trigger": 2}, num_points=3, + scan_id="test", ) ) with ( @@ -213,7 +214,10 @@ def test_timepix_on_stage_configures_camera_writer_and_mocked_backend(timepix, p assert timepix.cam.raw_file_path.get() == "tcp://connect@127.0.0.1:8451" assert timepix.backend.on_stage.call_count == 1 other_config = timepix.backend.on_stage.call_args.kwargs["other_config"] - assert other_config.output_uri == "tcp:localhost:9876" + assert ( + other_config.output_uri + == "redis://localhost:0000/public/timepix_fly_backend/raw_data?scan-id=test" + ) assert other_config.TRoiStep == timepix.troistep assert other_config.TRoiN == timepix.troin assert timepix.backend.on_stage.call_args.kwargs["pixel_map"] == pixel_map @@ -249,7 +253,10 @@ def test_timepix_on_stage_configures_mocked_backend(timepix, pixel_map): assert timepix.cam.raw_file_path.get() == "tcp://connect@127.0.0.1:8451" assert timepix.backend.on_stage.call_count == 1 other_config = timepix.backend.on_stage.call_args.kwargs["other_config"] - assert other_config.output_uri == "tcp:localhost:9876" + assert ( + other_config.output_uri + == "redis://localhost:0000/public/timepix_fly_backend/raw_data?scan-id=test" + ) assert other_config.TRoiStep == timepix.troistep assert other_config.TRoiN == timepix.troin assert timepix.backend.on_stage.call_args.kwargs["pixel_map"] == pixel_map diff --git a/tests/tests_devices/test_timepix_fly_backend.py b/tests/tests_devices/test_timepix_fly_backend.py index a9857c3..74ed285 100644 --- a/tests/tests_devices/test_timepix_fly_backend.py +++ b/tests/tests_devices/test_timepix_fly_backend.py @@ -195,14 +195,28 @@ def test_timepix_fly_backend_decode_end_frame_runs_callbacks(backend_with_states received["scan_id"] = scan_id backend.add_callback(callback, kwd={"scan_id": 7}) - backend._decode_received_data( - '{"type":"StartFrame","Mode":"TOA","TRoiStart":0,"TRoiStep":1,"TRoiN":2,"NumEnergyPoints":2,"save_interval":10}' + backend._process_timepix_fly_msg( + { + "type": "StartFrame", + "Mode": "TOA", + "TRoiStart": 0, + "TRoiStep": 1, + "TRoiN": 2, + "NumEnergyPoints": 2, + "save_interval": 10, + } ) - backend._decode_received_data( - '{"type":"XesData","period":1,"TDSpectra":[1,2,3,4],"totalEvents":4,"beforeROI":0,"afterROI":0}' + backend._process_timepix_fly_msg( + { + "type": "XesData", + "period": 1, + "TDSpectra": [1, 2, 3, 4], + "totalEvents": 4, + "beforeROI": 0, + "afterROI": 0, + } ) - backend._decode_received_data('{"type":"EndFrame","error":"","periods":5}') - + backend._process_timepix_fly_msg({"type": "EndFrame", "error": "", "periods": 5}) assert received["start_frame"]["type"] == "StartFrame" assert received["data_frames"][0]["type"] == "XesData" assert received["end_frame"]["type"] == "EndFrame"