From: John Mulligan Date: Thu, 9 Nov 2023 00:21:10 +0000 (-0500) Subject: cephadm: use funkypatch for setting up common patches in deploy tests X-Git-Tag: v19.0.0^2~23 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=700ea8d109c71f31079d239dd256a7562e9961f2;p=ceph.git cephadm: use funkypatch for setting up common patches in deploy tests 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 --- diff --git a/src/cephadm/tests/test_deploy.py b/src/cephadm/tests/test_deploy.py index c77b243dfa77..9d82b2055b91 100644 --- a/src/cephadm/tests/test_deploy.py +++ b/src/cephadm/tests/test_deploy.py @@ -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