def test_download_windows_binaries(mocker, tmp_path): mocker.patch.object(platform, "system", lambda: "Windows") mocker.patch.object(download_binaries, "CACHE_DIR", tmp_path) assert not download_binaries.get_docker_binary_path_in_cache().exists() assert download_binaries.get_user_os() == "windows" download_binaries.download_docker_cli() assert download_binaries.get_docker_binary_path_in_cache().exists()
def test_download_cli(mocker, tmp_path): mocker.patch.object(download_binaries, "CACHE_DIR", tmp_path) download_binaries.download_docker_cli() simple_command = [ download_binaries.get_docker_binary_path_in_cache(), "run", "--rm", "hello-world", ] output = run(simple_command, capture_stdout=True, capture_stderr=True) assert "Hello from Docker!" in output
def test_download_cli(): try: download_binaries.DOCKER_BINARY_PATH.unlink() except FileNotFoundError: pass download_binaries.download_docker_cli() simple_command = [ download_binaries.DOCKER_BINARY_PATH, "run", "--rm", "hello-world", ] output = run(simple_command, capture_stdout=True, capture_stderr=True) assert "Hello from Docker!" in output
def get_docker_path(self) -> ValidPath: if self.client_binary_path is None: self.client_binary_path = get_docker_client_binary_path() if self.client_binary_path is None: warnings.warn( "The docker client binary file was not found on your system. \n" "Docker on whales will try to download it for you. \n" "Don't worry, it " "won't be in the PATH and won't have anything to do with " "the package manager of your system. \n" "Note: We are not installing the docker daemon, which is a lot " "heavier and harder to install. We're just downloading a single " "standalone binary file.\n" "If you want to trigger the download of the client binary file " "manually (for example if you want to do it in a Dockerfile), " "you can run the following command:\n " "$ python-on-whales download-cli \n" ) download_docker_cli() self.client_binary_path = get_docker_binary_path_in_cache() return self.client_binary_path
def download_cli(): download_docker_cli()