def test_release_package(): _create_simple_test_package("aaa") assert packaging._package_exists("aaa") is True assert cmk.utils.paths.local_checks_dir.joinpath("aaa").exists() packaging.release_package("aaa") assert packaging._package_exists("aaa") is False assert cmk.utils.paths.local_checks_dir.joinpath("aaa").exists()
def _install_and_disable_package(mkp_file): packaging.install_by_path(mkp_file) assert packaging._package_exists("aaa") is True package_info = packaging.read_package_info("aaa") assert package_info is not None package_file_name = packaging.format_file_name(name="aaa", version=package_info["version"]) packaging.disable("aaa", package_info) assert packaging._package_exists("aaa") is False assert cmk.utils.paths.disabled_packages_dir.joinpath(package_file_name).exists() assert not cmk.utils.paths.local_checks_dir.joinpath("aaa").exists() return package_file_name
def test_enable_disabled_package(mkp_file): package_file_name = _install_and_disable_package(mkp_file) packaging.enable(package_file_name) assert packaging._package_exists("aaa") is True assert not cmk.utils.paths.disabled_packages_dir.joinpath(package_file_name).exists() assert cmk.utils.paths.local_checks_dir.joinpath("aaa").exists()
def test_remove_disabled_package(mkp_file): package_file_name = _install_and_disable_package(mkp_file) packaging.remove_disabled(package_file_name) assert packaging._package_exists("aaa") is False assert not cmk.utils.paths.disabled_packages_dir.joinpath( package_file_name).exists()
def test_remove_disabled_package(mkp_file, build_setup_search_index): package_file_name = _install_and_disable_package(mkp_file, build_setup_search_index) packaging.remove_disabled(package_file_name) build_setup_search_index.assert_not_called() assert packaging._package_exists("aaa") is False assert not cmk.utils.paths.disabled_packages_dir.joinpath(package_file_name).exists()
def test_install_by_path(mkp_file): packaging.install_by_path(mkp_file) assert packaging._package_exists("aaa") is True package_info = _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_enable_disabled_package(mkp_file, build_setup_search_index): package_file_name = _install_and_disable_package(mkp_file, build_setup_search_index) packaging.enable(package_file_name) build_setup_search_index.assert_called_once() assert packaging._package_exists("aaa") is True assert not cmk.utils.paths.disabled_packages_dir.joinpath(package_file_name).exists() assert cmk.utils.paths.local_checks_dir.joinpath("aaa").exists()
def test_install_by_path(mkp_file, build_setup_search_index): packaging.install_by_path(mkp_file) build_setup_search_index.assert_called_once() assert packaging._package_exists("aaa") is True package_info = _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_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 fixture_mkp_bytes(): # Create package information _create_simple_test_package("aaa") package_info = _read_package_info("aaa") # Build MKP in memory mkp = BytesIO() packaging.write_file(package_info, mkp) mkp.seek(0) # Remove files from local hierarchy packaging.remove(package_info) assert packaging._package_exists("aaa") is False return mkp
def fixture_mkp_bytes(build_setup_search_index): # Create package information _create_simple_test_package("aaa") package_info = _read_package_info("aaa") # Build MKP in memory mkp = BytesIO() packaging.write_file(package_info, mkp) mkp.seek(0) # Remove files from local hierarchy packaging.remove(package_info) build_setup_search_index.assert_called_once() build_setup_search_index.reset_mock() assert packaging._package_exists("aaa") is False return mkp
def test_remove_package(): package_info = _create_simple_test_package("aaa") packaging.remove_package(package_info) assert packaging._package_exists("aaa") is False
def test_remove(build_setup_search_index): package_info = _create_simple_test_package("aaa") packaging.remove(package_info) build_setup_search_index.assert_called_once() assert packaging._package_exists("aaa") is False