Skip to content

Commit 0550457

Browse files
committed
Fix tests to use new CIF interface
1 parent ff2186e commit 0550457

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

tests/dream/geant4_reduction_test.py

+21-16
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import sciline
88
import scipp as sc
99
import scipp.testing
10+
from scippneutron.io.cif import Author
1011

1112
import ess.dream.data # noqa: F401
1213
from ess import dream, powder
13-
from ess.dream.io.cif import CIFAuthor, CIFAuthors
1414
from ess.powder.types import (
1515
AccumulatedProtonCharge,
1616
BackgroundRun,
1717
CalibrationFilename,
18+
CIFAuthors,
1819
DspacingBins,
1920
Filename,
2021
IofDspacing,
@@ -24,7 +25,7 @@
2425
NeXusSample,
2526
NeXusSource,
2627
NormalizedByProtonCharge,
27-
OutFilename,
28+
ReducedDspacingCIF,
2829
SampleRun,
2930
TofMask,
3031
TwoThetaBins,
@@ -57,8 +58,8 @@
5758
WavelengthMask: None,
5859
CIFAuthors: CIFAuthors(
5960
[
60-
CIFAuthor(
61-
name="Jane Doe", email="[email protected]", id_orcid="0000-0000-0000-0001"
61+
Author(
62+
name="Jane Doe", email="[email protected]", orcid="0000-0000-0000-0001"
6263
),
6364
]
6465
),
@@ -159,26 +160,19 @@ def test_use_workflow_helper(workflow):
159160

160161

161162
def test_pipeline_can_save_data(workflow):
162-
def get_result(da: IofDspacing) -> IofDspacing:
163-
return da
164-
165-
buffer = io.StringIO()
166-
workflow[OutFilename] = buffer
167163
workflow = powder.with_pixel_mask_filenames(workflow, [])
164+
result = workflow.compute(ReducedDspacingCIF)
168165

169-
result, expected = workflow.bind_and_call(
170-
[dream.io.save_reduced_dspacing, get_result]
171-
)
172-
sc.testing.assert_identical(result, expected)
173-
166+
buffer = io.StringIO()
167+
result.save(buffer)
174168
buffer.seek(0)
175169
content = buffer.read()
176-
# print(content)
177-
# assert False
178170

179171
assert content.startswith(r'#\#CIF_1.1')
180172
_assert_contains_source_info(content)
181173
_assert_contains_author_info(content)
174+
_assert_contains_beamline_info(content)
175+
_assert_contains_dspacing_data(content)
182176

183177

184178
def _assert_contains_source_info(cif_content: str) -> None:
@@ -188,3 +182,14 @@ def _assert_contains_source_info(cif_content: str) -> None:
188182
def _assert_contains_author_info(cif_content: str) -> None:
189183
assert "audit_contact_author.name 'Jane Doe'" in cif_content
190184
assert 'audit_contact_author.email [email protected]' in cif_content
185+
186+
187+
def _assert_contains_beamline_info(cif_content: str) -> None:
188+
assert 'diffrn_source.beamline DREAM' in cif_content
189+
assert 'diffrn_source.facility ESS' in cif_content
190+
191+
192+
def _assert_contains_dspacing_data(cif_content: str) -> None:
193+
assert 'pd_proc.d_spacing' in cif_content
194+
assert 'pd_proc.intensity_net' in cif_content
195+
assert 'pd_proc.intensity_net_su' in cif_content

0 commit comments

Comments
 (0)