def test_nexus_runtime_error(db_all, RE): RE.subscribe(db_all.insert) RE(count([det], 5, delay=0.1), owner="Tom") hdr = db_all[-1] fname = tempfile.NamedTemporaryFile() if hasattr(hdr, 'db'): nexus.export(hdr, fname.name, db=None) else: with pytest.raises(RuntimeError): nexus.export(hdr, fname.name, db=None)
def test_nexus_export_single(db_all, RE): """ Test the NeXus HDF5 export with a single header and verify the output is correct """ RE.subscribe(db_all.insert) RE(count([det], 5, delay=0.1), owner="Tom") hdr = db_all[-1] fname = tempfile.NamedTemporaryFile() nexus.export(hdr, fname.name, db=db_all) shallow_header_verify(fname.name, hdr, db_all) validate_basic_NeXus_structure(fname.name)
def test_nexus_export_single_no_uid(mds_all): """ Test the NeXus HDF5 export with a single header and verify the output is correct. No uid is used. """ mds = mds_all temperature_ramp.run(mds) db = Broker(mds, fs=None) hdr = db[-1] fname = tempfile.NamedTemporaryFile() nexus.export(hdr, fname.name, mds, use_uid=False) shallow_header_verify(fname.name, hdr, mds, use_uid=False) validate_basic_NeXus_structure(fname.name)
def test_nexus_export_with_fields_single(mds_all): """ Test the NeXus HDF5 export with a single header and verify the output is correct; fields kwd is used. """ mds = mds_all temperature_ramp.run(mds) db = Broker(mds, fs=None) hdr = db[-1] fname = tempfile.NamedTemporaryFile() nexus.export(hdr, fname.name, mds, fields=['point_dev']) shallow_header_verify(fname.name, hdr, mds, fields=['point_dev']) validate_basic_NeXus_structure(fname.name)
def test_nexus_export_list(db_all, RE): """ Test the NeXus HDF5 export with a list of headers and verify the output is correct """ RE.subscribe(db_all.insert) RE(count([det], 5, delay=0.1), owner="Tom") RE(count([det], 10, delay=0.1), sample="Cu") hdrs = db_all[-2:] fname = tempfile.NamedTemporaryFile() # test exporting a list of headers nexus.export(hdrs, fname.name, db=db_all) for hdr in hdrs: shallow_header_verify(fname.name, hdr, db_all) validate_basic_NeXus_structure(fname.name)
def test_nexus_export_list(mds_all): """ Test the NeXus HDF5 export with a list of headers and verify the output is correct """ mds = mds_all temperature_ramp.run(mds) temperature_ramp.run(mds) db = Broker(mds, fs=None) hdrs = db[-2:] fname = tempfile.NamedTemporaryFile() # test exporting a list of headers nexus.export(hdrs, fname.name, mds) for hdr in hdrs: shallow_header_verify(fname.name, hdr, mds) validate_basic_NeXus_structure(fname.name)