Skip to content

Commit

Permalink
Handle type checking updates in Request library
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Sep 5, 2024
1 parent 258644a commit 6156312
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/dodal/devices/areadetector/plugins/MJPG.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_snapshot():
try:
response = requests.get(url_str, stream=True)
response.raise_for_status()
with Image.open(response.raw) as image:
with Image.open(response.content) as image:
self.post_processing(image)
st.set_finished()
except requests.HTTPError as e:
Expand Down
41 changes: 22 additions & 19 deletions tests/devices/unit_tests/detector/test_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,28 @@ def test_detector_params_is_serialisable(tmp_path):


# Until https://github.com/DiamondLightSource/dodal/issues/775
def test_detector_params_deserialisation_unchanged(tmp_path):
json = """
{"expected_energy_ev":100.0,
"exposure_time":1.0,
"directory":"/tmp/pytest-of-qwe67581/pytest-23/test_detector_params_serialisa0",
"prefix":"test",
"detector_distance":1.0,
"omega_start":0.0,
"omega_increment":0.0,
"num_images_per_trigger":1,
"num_triggers":1,
"use_roi_mode":false,
"det_dist_to_beam_converter_path":"a fake directory",
"run_number":17,
"trigger_mode":1,
"detector_size_constants":"EIGER2_X_16M",
"enable_dev_shm":false}
"""
assert '"run_number":17' in json
def test_detector_params_deserialisation_unchanged(tmp_path: Path):
# The `directory` parameter in the `create_det_params_with_dir_and_prefix` function is used to
# specify the directory path where the detector data will be saved. This function creates an
# instance of `DetectorParams` with the provided directory path and other default parameters. The
# `directory` parameter can accept either a string or a `Path` object, and it is used to set the
# `directory` attribute of the `DetectorParams` instance.
json = f'{{"expected_energy_ev": 100.0, \
"exposure_time": 1.0, \
"directory": "{tmp_path}", \
"prefix": "test", \
"detector_distance": 1.0, \
"omega_start": 0.0, \
"omega_increment": 0.0, \
"num_images_per_trigger": 1, \
"num_triggers": 1, \
"use_roi_mode": false, \
"det_dist_to_beam_converter_path": "a fake directory", \
"run_number": 17, \
"trigger_mode": 1, \
"detector_size_constants": "EIGER2_X_16M", \
"enable_dev_shm": false}}'
assert '"run_number": 17' in json
new_params = DetectorParams.model_validate_json(json)
assert new_params.run_number == 17

Expand Down

0 comments on commit 6156312

Please sign in to comment.