]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: add a simple unit test for RemoteCommand class
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 14 Mar 2024 18:02:17 +0000 (14:02 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sun, 17 Mar 2024 15:23:04 +0000 (11:23 -0400)
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 <jmulligan@redhat.com>
src/pybind/mgr/cephadm/tests/test_ssh.py

index 29f01b6c79724001bb86ad6768827e57b96a7184..44ef3d429b75ce07b9033aa422f705445bf07d5a 100644 (file)
@@ -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',
+    ]