From: John Mulligan Date: Tue, 3 Oct 2023 20:51:49 +0000 (-0400) Subject: cephadm: mock os.path.listdir in daemon forms test X-Git-Tag: v19.0.0~277^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d9314780a59e991afce036236d425a5ed8368d09;p=ceph-ci.git cephadm: mock os.path.listdir in daemon forms test 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 --- diff --git a/src/cephadm/tests/test_daemon_form.py b/src/cephadm/tests/test_daemon_form.py index 428183aaa3e..07896cc5855 100644 --- a/src/cephadm/tests/test_daemon_form.py +++ b/src/cephadm/tests/test_daemon_form.py @@ -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':