mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-05-05 21:21:49 +02:00
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from pathlib import Path
|
|
|
|
from pytest_mock import MockerFixture
|
|
|
|
from dangerzone.container_utils import Runtime
|
|
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", "/opt/somewhere/new-kid-on-the-block", autosave=True
|
|
)
|
|
|
|
assert Runtime().name == "new-kid-on-the-block"
|
|
|
|
|
|
def test_get_runtime_name_linux(mocker: MockerFixture, tmp_path: Path) -> None:
|
|
mocker.patch("dangerzone.settings.get_config_dir", return_value=tmp_path)
|
|
mocker.patch("platform.system", return_value="Linux")
|
|
assert Runtime().name == "podman"
|
|
|
|
|
|
def test_get_runtime_name_non_linux(mocker: MockerFixture, tmp_path: Path) -> None:
|
|
mocker.patch("platform.system", return_value="Windows")
|
|
mocker.patch("dangerzone.settings.get_config_dir", return_value=tmp_path)
|
|
assert Runtime().name == "docker"
|
|
|
|
mocker.patch("platform.system", return_value="Something else")
|
|
assert Runtime().name == "docker"
|