]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: mock os.path.listdir in daemon forms test
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 3 Oct 2023 20:51:49 +0000 (16:51 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Tue, 10 Oct 2023 14:33:48 +0000 (10:33 -0400)
Prevent classes that want to check the filesystem from breaking the
simple daemon forms instantiation test case. A better future fix would
be avoiding checking the file system during __init__ of the class but
that is left for future improvements.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/tests/test_daemon_form.py

index 428183aaa3e19bf9dfe6dab41a8baae2b6396e80..07896cc5855903f263b95b797950797545fcc308 100644 (file)
@@ -61,7 +61,7 @@ def test_is_sysctl_daemon_form(dt, is_sdf):
     assert isinstance(inst, daemon_form.SysctlDaemonForm) == is_sdf
 
 
-def test_can_create_all_daemon_forms():
+def test_can_create_all_daemon_forms(monkeypatch):
     uuid = 'daeb985e-58c7-11ee-a536-201e8814f771'
     ctx = mock.MagicMock()
     ctx.config_blobs = {
@@ -69,6 +69,8 @@ def test_can_create_all_daemon_forms():
         'pool': 'swimming',
         'destination': 'earth',
     }
+    _os_path_isdir = mock.MagicMock(return_value=True)
+    monkeypatch.setattr('os.path.isdir', _os_path_isdir)
     dtypes = _cephadm.get_supported_daemons()
     for daemon_type in dtypes:
         if daemon_type == 'agent':