def test_convert_with_profile(): cfgpath = setup_config(pxsize=1.34e-6, medium_index=1.346, wavelength=554.2e-9) _, path_in, path_out = setup_test_data() argsadd = argparse.Namespace(subparser_name="add", name="test_8440_prof_convert", path=cfgpath) profile.cli_profile(args=argsadd) try: # perform conversion h5data = cli_convert(path=path_in, ret_data=True, profile="test_8440_prof_convert") cfg = config.ConfigFile(path_out) assert np.allclose(cfg["meta"]["medium index"], 1.346) assert np.allclose(cfg["meta"]["pixel size um"], 1.34) assert np.allclose(cfg["meta"]["wavelength nm"], 554.2) with qpimage.QPSeries(h5file=h5data, h5mode="r") as qps: assert np.allclose(qps[0]["medium index"], 1.346) assert np.allclose(qps[0]["pixel size"], 1.34e-6) assert np.allclose(qps[0]["wavelength"], 554.2e-9) except BaseException: raise finally: # cleanup argsrem = argparse.Namespace(subparser_name="remove", name="test_8440_prof_convert") profile.cli_profile(args=argsrem)
def test_list_none(capsys): if profile.get_profiles(): warnings.warn("Test cannot succeed, b/c there are user profiles.") else: argslist = argparse.Namespace(subparser_name="list") profile.cli_profile(args=argslist) captured = capsys.readouterr() assert "No profiles in local library." in captured.out.strip()
def test_remove_fail(): argsrem = argparse.Namespace(subparser_name="remove", name="test_8474_prof") try: profile.cli_profile(args=argsrem) except OSError: pass else: assert False
def test_add_remove(): path = setup_config() argsadd = argparse.Namespace(subparser_name="add", name="test_8472_prof", path=path) profile.cli_profile(args=argsadd) # verify that the profile was imported pps = profile.get_profile_path(name="test_8472_prof") assert pps.exists() # remove the profile again argsrem = argparse.Namespace(subparser_name="remove", name="test_8472_prof") profile.cli_profile(args=argsrem) assert not pps.exists()
def test_list_profile(capsys): path = setup_config() argsadd = argparse.Namespace(subparser_name="add", name="test_8490_prof", path=path) profile.cli_profile(args=argsadd) argslist = argparse.Namespace(subparser_name="list") profile.cli_profile(args=argslist) captured = capsys.readouterr() assert "- test_8490_prof:" in captured.out.strip() argsrem = argparse.Namespace(subparser_name="remove", name="test_8490_prof") profile.cli_profile(args=argsrem)
def test_export(): path = setup_config() argsadd = argparse.Namespace(subparser_name="add", name="test_8491_prof", path=path) profile.cli_profile(args=argsadd) # export tdir = tempfile.mkdtemp(prefix="test_drymass_profile_export_") argsexp = argparse.Namespace(subparser_name="export", path=tdir) profile.cli_profile(args=argsexp) assert (pathlib.Path(tdir) / "profile_test_8491_prof.cfg").exists() # cleanup argsrem = argparse.Namespace(subparser_name="remove", name="test_8491_prof") profile.cli_profile(args=argsrem)
def test_add_fail(): path = setup_config() argsadd = argparse.Namespace(subparser_name="add", name="test_8473_prof", path=path) profile.cli_profile(args=argsadd) try: profile.cli_profile(args=argsadd) except OSError: pass else: assert False # remove the profile again argsrem = argparse.Namespace(subparser_name="remove", name="test_8473_prof") profile.cli_profile(args=argsrem)