From: John Mulligan Date: Thu, 14 Mar 2024 18:02:17 +0000 (-0400) Subject: mgr/cephadm: add a simple unit test for RemoteCommand class X-Git-Tag: v20.0.0~2361^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e357d2f99a14969b6f1a089680a9f16dc3bb0e54;p=ceph.git 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 --- diff --git a/src/pybind/mgr/cephadm/tests/test_ssh.py b/src/pybind/mgr/cephadm/tests/test_ssh.py index 29f01b6c79724..44ef3d429b75c 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', + ]