From a23e8a8e591ea935b2cc6f41e4280cac246d4226 Mon Sep 17 00:00:00 2001 From: missytake Date: Tue, 26 Aug 2025 15:21:05 +0200 Subject: [PATCH] tests: run tests in docker if SSH is not available --- .../src/cmdeploy/tests/online/test_1_basic.py | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py index 822b71f9..d709c684 100644 --- a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py +++ b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py @@ -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"))