tests: run tests in docker if SSH is not available

This commit is contained in:
missytake
2025-08-26 15:21:05 +02:00
parent 2f4cfcc03d
commit a23e8a8e59

View File

@@ -10,10 +10,37 @@ from cmdeploy import remote
from cmdeploy.sshexec import SSHExec
class FuncError(Exception):
pass
class DockerExec:
FuncError = FuncError
def __init__(self, pre_command):
self.pre_command = pre_command
def __call__(self, call, kwargs=None):
if kwargs is None:
kwargs = {}
return call(**kwargs)
def logged(self, call, kwargs):
title = call.__doc__
if not title:
title = call.__name__
print("[ssh] " + title)
return self(call, kwargs)
class TestSSHExecutor:
@pytest.fixture(scope="class")
def sshexec(self, sshdomain):
return SSHExec(sshdomain)
try:
sshexec = SSHExec(sshdomain)
except FileNotFoundError:
sshexec = DockerExec("docker exec chatmail ")
return sshexec
def test_ls(self, sshexec):
out = sshexec(call=remote.rdns.shell, kwargs=dict(command="ls"))