Source code for ewoksxrdct.tests.test_create_nxxrdct
from pathlib import Path
import h5py
import pytest
from ewoksxrdct.tasks.create_nxxrdct import CreateNxxrdct
[docs]
@pytest.mark.parametrize("Task", [CreateNxxrdct])
def test_create_nxxrdct_task_outputs(Task, tmp_path):
test_file = str(tmp_path / "test_file.hdf5")
title = "test create_nxxrdct"
start_time = "2026-05-07T16:16:16.161616+02:00"
beam_incident_energy = 60.0
sample_name = "sample-test"
detector_count_time = 0.1
inputs = {
"nx_path": test_file,
"title": title,
"start_time": start_time,
"beam_incident_energy": beam_incident_energy,
"sample_name": sample_name,
"detector_count_time": detector_count_time,
}
task = Task(inputs=inputs)
task.execute()
assert task.outputs.nx_path == test_file
assert Path(test_file).is_file()
# Test that the outputted file content is as expected
with h5py.File(test_file, "r") as h5:
data = h5["entry"]
assert data["title"][()].decode() == title
assert data["start_time"][()].decode() == start_time
assert data["beam/incident_energy"][()] == beam_incident_energy
assert data["sample/name"][()].decode() == sample_name
assert data["instrument/detector/count_time"][()] == detector_count_time