def package_remove(args): if len(args) != 1: raise PackageException("Usage: check_mk -P remove NAME") pacname = args[0] package = read_package_info(pacname) if not package: raise PackageException("No such package %s." % pacname) logger.log(VERBOSE, "Removing package %s...", pacname) remove_package(package) logger.log(VERBOSE, "Successfully removed package %s.", pacname)
def test_install_package_by_path(tmp_path): # Create _create_simple_test_package("aaa") package_info = packaging.read_package_info("aaa") # Write MKP file mkp_path = tmp_path.joinpath("aaa.mkp") with mkp_path.open("wb") as mkp: packaging.create_mkp_file(package_info, mkp) # Remove files from local hierarchy packaging.remove_package(package_info) assert packaging._package_exists("aaa") is False # And now install the package from memory packaging.install_package_by_path(mkp_path) # Check result assert packaging._package_exists("aaa") is True package_info = packaging.read_package_info("aaa") assert package_info["version"] == "1.0" assert package_info["files"]["checks"] == ["aaa"] assert cmk.utils.paths.local_checks_dir.joinpath("aaa").exists()
def test_install_package(): # Create _create_simple_test_package("aaa") package_info = packaging.read_package_info("aaa") # Build MKP in memory mkp = BytesIO() packaging.create_mkp_file(package_info, mkp) mkp.seek(0) # Remove files from local hierarchy packaging.remove_package(package_info) assert packaging._package_exists("aaa") is False # And now install the package from memory packaging.install_package(mkp) # Check result assert packaging._package_exists("aaa") is True package_info = packaging.read_package_info("aaa") assert package_info["version"] == "1.0" assert package_info["files"]["checks"] == ["aaa"] assert cmk.utils.paths.local_checks_dir.joinpath("aaa").exists()
def test_remove_package(): package_info = _create_simple_test_package("aaa") packaging.remove_package(package_info) assert packaging._package_exists("aaa") is False