mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-05-06 13:31:50 +02:00
Move container-specific method from base class
Move the `is_runtime_available()` method from the base `IsolationProvider` class, and into the `Dummy` provider class. This method was originally defined in the base class, in order to be mocked in our tests for the `Dummy` provider. There's no reason for the `Qubes` class to have it though, so we can just move it to the `Dummy` provider.
This commit is contained in:
parent
60df4f7e35
commit
96e64deae7
4 changed files with 9 additions and 7 deletions
|
@ -500,6 +500,7 @@ class WaitingWidgetContainer(WaitingWidget):
|
||||||
error: Optional[str] = None
|
error: Optional[str] = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
assert isinstance(self.dangerzone.isolation_provider, (Dummy, Container))
|
||||||
self.dangerzone.isolation_provider.is_runtime_available()
|
self.dangerzone.isolation_provider.is_runtime_available()
|
||||||
except NoContainerTechException as e:
|
except NoContainerTechException as e:
|
||||||
log.error(str(e))
|
log.error(str(e))
|
||||||
|
|
|
@ -93,10 +93,6 @@ class IsolationProvider(ABC):
|
||||||
else:
|
else:
|
||||||
self.proc_stderr = subprocess.DEVNULL
|
self.proc_stderr = subprocess.DEVNULL
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def is_runtime_available() -> bool:
|
|
||||||
return True
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def install(self) -> bool:
|
def install(self) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -39,6 +39,10 @@ class Dummy(IsolationProvider):
|
||||||
def install(self) -> bool:
|
def install(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_runtime_available() -> bool:
|
||||||
|
return True
|
||||||
|
|
||||||
def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen:
|
def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen:
|
||||||
cmd = [
|
cmd = [
|
||||||
sys.executable,
|
sys.executable,
|
||||||
|
|
|
@ -30,6 +30,7 @@ from dangerzone.isolation_provider.container import (
|
||||||
NoContainerTechException,
|
NoContainerTechException,
|
||||||
NotAvailableContainerTechException,
|
NotAvailableContainerTechException,
|
||||||
)
|
)
|
||||||
|
from dangerzone.isolation_provider.dummy import Dummy
|
||||||
|
|
||||||
from .test_updater import assert_report_equal, default_updater_settings
|
from .test_updater import assert_report_equal, default_updater_settings
|
||||||
|
|
||||||
|
@ -510,9 +511,9 @@ def test_not_available_container_tech_exception(
|
||||||
) -> None:
|
) -> None:
|
||||||
# Setup
|
# Setup
|
||||||
mock_app = mocker.MagicMock()
|
mock_app = mocker.MagicMock()
|
||||||
dummy = mocker.MagicMock()
|
dummy = Dummy()
|
||||||
|
fn = mocker.patch.object(dummy, "is_runtime_available")
|
||||||
dummy.is_runtime_available.side_effect = NotAvailableContainerTechException(
|
fn.side_effect = NotAvailableContainerTechException(
|
||||||
"podman", "podman image ls logs"
|
"podman", "podman image ls logs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue