dangerzone/tests/test_container_utils.py
Alexis Métaireau c0215062bc
Allow to read the container runtime from the settings
Add a few tests for this along the way, and update the end-user messages
about Docker/Podman to account for this change.
2025-03-31 16:20:28 +02:00

28 lines
939 B
Python

from pathlib import Path
from pytest_mock import MockerFixture
from dangerzone.container_utils import get_runtime_name
from dangerzone.settings import Settings
def test_get_runtime_name_from_settings(mocker: MockerFixture, tmp_path: Path) -> None:
mocker.patch("dangerzone.settings.get_config_dir", return_value=tmp_path)
settings = Settings()
settings.set("container_runtime", "new-kid-on-the-block", autosave=True)
assert get_runtime_name() == "new-kid-on-the-block"
def test_get_runtime_name_linux(mocker: MockerFixture) -> None:
mocker.patch("platform.system", return_value="Linux")
assert get_runtime_name() == "podman"
def test_get_runtime_name_non_linux(mocker: MockerFixture) -> None:
mocker.patch("platform.system", return_value="Windows")
assert get_runtime_name() == "docker"
mocker.patch("platform.system", return_value="Something else")
assert get_runtime_name() == "docker"