]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: use funkypatch for setting up common patches in deploy tests
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 9 Nov 2023 00:21:10 +0000 (19:21 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 30 Nov 2023 21:55:59 +0000 (16:55 -0500)
Add a shim function and convert to the use of the FunkyPatcher class in
the test_deploy.py test functions. Use a shim as to not have to change
all the tests (yet).

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

index c77b243dfa774cc59b8117c34cc617202f730b90..9d82b2055b918f66feb42d0330217b1223103784 100644 (file)
@@ -8,6 +8,7 @@ from .fixtures import (
     import_cephadm,
     mock_podman,
     with_cephadm_ctx,
+    FunkyPatcher,
 )
 
 
@@ -15,25 +16,24 @@ _cephadm = import_cephadm()
 
 
 def _common_mp(monkeypatch):
+    return _common_patches(FunkyPatcher(monkeypatch))
+
+
+def _common_patches(funkypatch):
     mocks = {}
-    _call = mock.MagicMock(return_value=('', '', 0))
-    monkeypatch.setattr('cephadmlib.container_types.call', _call)
+    _call = funkypatch.patch('cephadmlib.container_types.call')
+    _call.return_value = ('', '', 0)
     mocks['call'] = _call
-    _call_throws = mock.MagicMock(return_value=0)
-    monkeypatch.setattr(
-        'cephadmlib.container_types.call_throws', _call_throws
-    )
+    _call_throws = funkypatch.patch('cephadmlib.container_types.call_throws')
+    _call_throws.return_value = ('', '', 0)
     mocks['call_throws'] = _call_throws
-    _firewalld = mock.MagicMock()
+    _firewalld = funkypatch.patch('cephadm.Firewalld')
     _firewalld().external_ports.get.return_value = []
-    monkeypatch.setattr('cephadm.Firewalld', _firewalld)
     mocks['Firewalld'] = _firewalld
-    _extract_uid_gid = mock.MagicMock()
+    _extract_uid_gid = funkypatch.patch('cephadm.extract_uid_gid', force=True)
     _extract_uid_gid.return_value = (8765, 8765)
-    monkeypatch.setattr('cephadm.extract_uid_gid', _extract_uid_gid)
     mocks['extract_uid_gid'] = _extract_uid_gid
-    _install_sysctl = mock.MagicMock()
-    monkeypatch.setattr('cephadm.install_sysctl', _install_sysctl)
+    _install_sysctl = funkypatch.patch('cephadm.install_sysctl')
     mocks['install_sysctl'] = _install_sysctl
     return mocks