Source code for blissoda.tests.test_scxrd_eiger2crysalis
from types import SimpleNamespace
from unittest.mock import patch
from .. import resources
from ..scxrd.eiger2crysalis import Eiger2CrysalisLima2Processor
from ..scxrd.eiger2crysalis import Eiger2CrysalisProcessor
from ..scxrd.eiger2crysalis import Eiger2CrysalisWithCbfProcessor
def _scan(tmp_path):
filename = tmp_path / "RAW_DATA" / "sample" / "sample_0001" / "sample_0001.h5"
scan_info = {
"filename": str(filename),
"scan_nb": 10,
"npoints": 5,
"type": "fscan",
"channels": {"eiger:image": {}},
"dataset_metadata_snapshot": {"Sample_name": "sample"},
"instrument": {
"fscan_parameters": {
"start_pos": -5.0,
"step_size": 0.5,
"acq_time": 0.1,
}
},
}
scan_saving = SimpleNamespace(
filename=scan_info["filename"],
images_path=str(tmp_path / "images" / "{scan_number}_{img_acq_device}_"),
sample_name="sample",
)
return SimpleNamespace(
scan_number=scan_info["scan_nb"],
scan_info=scan_info,
scan_saving=scan_saving,
)
def _inputs_by_name(inputs):
return {item["name"]: item["value"] for item in inputs}
[docs]
def test_default_workflow_resources(mock_persistent):
processor = Eiger2CrysalisProcessor()
processor_with_cbf = Eiger2CrysalisWithCbfProcessor()
lima2_processor = Eiger2CrysalisLima2Processor()
assert processor.workflow == resources.resource_filename(
"scxrd", "eiger2crysalis.json"
)
assert processor_with_cbf._workflow == resources.resource_filename(
"scxrd", "eiger2crysalis.json"
)
assert processor_with_cbf._cbf_workflow == resources.resource_filename(
"scxrd", "eiger2cbf_xds.json"
)
assert lima2_processor.workflow == resources.resource_filename(
"scxrd", "eiger2crysalis_lima2.json"
)
[docs]
def test_run_conversion_dispatches_selected_workflows(mock_persistent, tmp_path):
processor = Eiger2CrysalisWithCbfProcessor(
defaults={
"_workflow": "esperanto_workflow.json",
"_cbf_workflow": "cbf_workflow.json",
"output_file_format": ["cbf", "esperanto"],
}
)
assert processor.get_output_file_formats() == ["cbf", "esperanto"]
with patch("blissoda.scxrd.eiger2crysalis.submit") as submit_mock:
processor.run_conversion(_scan(tmp_path))
assert [call.kwargs["args"][0] for call in submit_mock.call_args_list] == [
"cbf_workflow.json",
"esperanto_workflow.json",
]
cbf_call = submit_mock.call_args_list[0].kwargs
esperanto_call = submit_mock.call_args_list[1].kwargs
assert cbf_call["kwargs"]["convert_destination"].endswith("_cbf.json")
assert cbf_call["kwargs"]["inputs"][0]["task_identifier"] == "Eiger2CBF"
assert any(
item["task_identifier"] == "CreateXDSInp"
for item in cbf_call["kwargs"]["inputs"]
)
assert esperanto_call["kwargs"]["convert_destination"].endswith(".json")
assert any(
item["task_identifier"] == "Eiger2Crysalis"
for item in esperanto_call["kwargs"]["inputs"]
)