From e357d2f99a14969b6f1a089680a9f16dc3bb0e54 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 14 Mar 2024 14:02:17 -0400 Subject: [PATCH] mgr/cephadm: add a simple unit test for RemoteCommand class Converting a remote command to something that other libs uses requires converting the enum to a string. Python behavior in the area varies across versions so add a unit test that verifies the conversion behaves as intended. Signed-off-by: John Mulligan --- src/pybind/mgr/cephadm/tests/test_ssh.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pybind/mgr/cephadm/tests/test_ssh.py b/src/pybind/mgr/cephadm/tests/test_ssh.py index 29f01b6c797..44ef3d429b7 100644 --- a/src/pybind/mgr/cephadm/tests/test_ssh.py +++ b/src/pybind/mgr/cephadm/tests/test_ssh.py @@ -103,3 +103,14 @@ class TestWithSSH: class TestWithoutSSH: def test_can_run(self, cephadm_module: CephadmOrchestrator): assert cephadm_module.can_run() == (False, "loading asyncssh library:No module named 'asyncssh'") + + +def test_remote_command(): + from cephadm.ssh import RemoteCommand, Executables + + assert list(RemoteCommand(Executables.TRUE)) == ['true'] + assert list(RemoteCommand(Executables.RM, ['-rf', '/tmp/blat'])) == [ + 'rm', + '-rf', + '/tmp/blat', + ] -- 2.39.5