def test_verify_dataset_exit_codes(dataset, exit_status_expected, monkeypatch): # get the exit status from the script def sys_exit(status): return status monkeypatch.setattr(sys, "exit", sys_exit) h5path = retrieve_data(dataset) exit_status = cli.verify_dataset(h5path) assert exit_status == exit_status_expected
def test_verify_dataset_exit_code_alert(monkeypatch): # get the exit status from the script def sys_exit(status): return status monkeypatch.setattr(sys, "exit", sys_exit) h5path = retrieve_data("fmt-hdf5_fl_2018.zip") # provoke a warning with h5py.File(h5path, "r+") as h5: h5.attrs["experiment:unknown"] = "" with mock.patch("sys.argv", ["", str(h5path)]): exit_status = cli.verify_dataset(h5path) assert exit_status == 1 # unknown key leads to alert
def test_verify_dataset_exit_code_violation_1(monkeypatch): # get the exit status from the script def sys_exit(status): return status monkeypatch.setattr(sys, "exit", sys_exit) h5path = retrieve_data("fmt-hdf5_fl_2018.zip") # Since 0.35.0 we really check the configuration key types. # Just make sure that they are properly set: with h5py.File(h5path, "a") as h5: for key in ["fluorescence:sample rate", "imaging:roi position x", "imaging:roi position y"]: h5.attrs[key] = int(h5.attrs[key]) # provoke a warning with h5py.File(h5path, "r+") as h5: h5.attrs["setup:flow rate"] = 0 exit_status = cli.verify_dataset(h5path) assert exit_status == 3 # zero flow rate and warnings about mismatch