def test_version_cmp(data): repo = Repository() pkg_mgr = PackageManager(repo=repo, installer=None, console=Console(exit_on_error=False)) for syntax in ["toolkit>=1.0.3"]: pkg = pkg_mgr.search(syntax) assert utils.pkg_comp_version("1.05.0", "1.5.0") < 0 assert utils.pkg_comp_version("1.0.15", "1.0.2") > 0 assert utils.pkg_comp_version("10.0.0", "9.999.999") > 0
def handle_(config, data): with Console(verbose=config.get("verbose", False), exit_on_error=True) as c: repo = init_repository(c, config["repository"]) pkg_mgr = PackageManager(repo, console=c) for syntax in data["syntax"]: pkg = pkg_mgr.search(syntax) if pkg: c.output(pkg)
def handle_(config, data): with Console(verbose=config.get("verbose", False), exit_on_error=True) as c: repo = init_repository(c, config["repository"]) pkg_mgr = PackageManager(repo, console=c) for syntax in data["packages"]: pkg = pkg_mgr.search(syntax) ok = pkg is not None if ok: ok = pkg_mgr.remove(pkg, interactive=not data["non_interactive"]) if ok: c.badge("removed", "success")
def test_search(): pm = PackageManager(repo=Repository(), installer=Installer(), overwrite=False, console=Console(exit_on_error=False)) pkg = Package(name="test_package", version="1.0.0", type="SOURCE") filename = resource_filename(__name__, "data/test_package-1.0.0.zip") pm.upload(pkg, filename) assert pm.search("test_package") == pkg assert pm.search("test_package==1.0.0") == pkg assert pm.search("test_package>0.9.9") == pkg assert pm.search("test_package<1.9.9") == pkg assert pm.search("fake") == None with pytest.raises(InvalidParameter): #no name pm.search("") with pytest.raises(InvalidParameter): #no ops pm.search("1.0.0")