call_timeout,
concurrent_tasks,
)
+from cephadmlib.container_engine_base import ContainerEngine
FuncT = TypeVar('FuncT', bound=Callable)
RECONFIG = 'Reconfig'
-class ContainerEngine:
- def __init__(self) -> None:
- self.path = find_program(self.EXE)
-
- @property
- def EXE(self) -> str:
- raise NotImplementedError()
-
- def __str__(self) -> str:
- return f'{self.EXE} ({self.path})'
-
-
class Podman(ContainerEngine):
EXE = 'podman'
--- /dev/null
+# container_engine_base.py - container engine base class
+
+from .exe_utils import find_program
+
+
+class ContainerEngine:
+ def __init__(self) -> None:
+ self.path = find_program(self.EXE)
+
+ @property
+ def EXE(self) -> str:
+ raise NotImplementedError()
+
+ def __str__(self) -> str:
+ return f'{self.EXE} ({self.path})'
_cephadm = import_cephadm()
+_find_program_loc = 'cephadmlib.container_engine_base.find_program'
+
+
def test_container_engine():
with pytest.raises(NotImplementedError):
_cephadm.ContainerEngine()
class PhonyContainerEngine(_cephadm.ContainerEngine):
EXE = "true"
- with mock.patch("cephadm.find_program") as find_program:
+ with mock.patch(_find_program_loc) as find_program:
find_program.return_value = "/usr/bin/true"
pce = PhonyContainerEngine()
assert str(pce) == "true (/usr/bin/true)"
def test_podman():
- with mock.patch("cephadm.find_program") as find_program:
+ with mock.patch(_find_program_loc) as find_program:
find_program.return_value = "/usr/bin/podman"
pm = _cephadm.Podman()
find_program.assert_called()
def test_podman_badversion():
- with mock.patch("cephadm.find_program") as find_program:
+ with mock.patch(_find_program_loc) as find_program:
find_program.return_value = "/usr/bin/podman"
pm = _cephadm.Podman()
find_program.assert_called()
def test_docker():
- with mock.patch("cephadm.find_program") as find_program:
+ with mock.patch(_find_program_loc) as find_program:
find_program.return_value = "/usr/bin/docker"
docker = _cephadm.Docker()
assert str(docker) == "docker (/usr/bin/docker)"