tests(timepix): adapt tests after refactoring to redis
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user