def test_ex_plugin_description(): path_name = "ext_feat_anc_plugin_ca.py" tmpd = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) path_used = tmpd / path_name shutil.copy2(data_path / path_name, path_used) ex = extensions.Extension(path_used) ex.load() assert "longer description" in ex.description
def test_ex_ml_description(): path_name = "ext_feat_anc_ml_tf_rbc.modc" tmpd = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) path_used = tmpd / path_name shutil.copy2(data_path / path_name, path_used) ex = extensions.Extension(path_used) ex.load() assert "I don't know what I am doing" in ex.description
def test_ex_all_enabled(path_name): tmpd = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) path_used = tmpd / path_name shutil.copy2(data_path / path_name, path_used) ex = extensions.Extension(path_used) assert ex.enabled ex.set_enabled(False) assert not ex.enabled
def test_ex_plugin_title(): path_name = "ext_feat_anc_plugin_ca.py" tmpd = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) path_used = tmpd / path_name shutil.copy2(data_path / path_name, path_used) ex = extensions.Extension(path_used) ex.load() assert "0.1.0" in ex.title assert "some circularity" in ex.title
def test_ex_ml_title(): path_name = "ext_feat_anc_ml_tf_rbc.modc" tmpd = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) path_used = tmpd / path_name shutil.copy2(data_path / path_name, path_used) ex = extensions.Extension(path_used) ex.load() assert "2021-11-26 02:07" in ex.title assert "Naive red blood cell score" in ex.title
def test_em_getitem_type(): tmpd = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) em = extensions.ExtensionManager(store_path=tmpd) em.import_extension_from_path(data_path / "ext_feat_anc_plugin_ca.py") with pytest.raises(ValueError, match="Extension not in"): em["peter"] with pytest.raises(IndexError, match="list index out of range"): em[1] tmpd2 = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) script = (data_path / "ext_feat_anc_plugin_ca.py").read_text() (tmpd2 / "test.py").write_text(script.replace("_area", "_area2")) ext_not_in_manager = extensions.Extension(tmpd2 / "test.py") with pytest.raises(ValueError, match="Extension not in"): em[ext_not_in_manager]
def test_ex_all_loaded(path_name): tmpd = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) path_used = tmpd / path_name shutil.copy2(data_path / path_name, path_used) ex = extensions.Extension(path_used) assert not ex.loaded ex.load() assert ex.loaded ex.unload() assert not ex.loaded ex.set_enabled(False) ex.load() assert ex.path_lock_disabled.exists() assert not ex.loaded ex.destroy() assert not ex.path.exists() assert not ex.path_lock_disabled.exists()
def test_ex_all_repr(path_name): tmpd = pathlib.Path(tempfile.mkdtemp(prefix="extension_")) path_used = tmpd / path_name shutil.copy2(data_path / path_name, path_used) ex = extensions.Extension(path_used) assert path_name in repr(ex)