mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00

Add a few tests for this along the way, and update the end-user messages about Docker/Podman to account for this change.
28 lines
939 B
Python
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"
|