]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: fix invalid use of mock called_with method
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 1 Nov 2024 15:41:33 +0000 (11:41 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Mon, 4 Nov 2024 20:38:41 +0000 (15:38 -0500)
Fixes `AttributeError: 'called_with' is not a valid assertion` errors
that appear when running the unit tests with python3.12.

Part of an effort to get ceph tox environments passing on Python 3.12.

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

index 6d0c00d408c170aceb95869e32cfe39d3c12ad63..41364a8acb127e145ec094babd31526c6a3b88a7 100644 (file)
@@ -499,7 +499,7 @@ class TestCephadm(object):
 
                 CephadmServe(cephadm_module)._check_daemons()
 
-                assert _save_host.called_with('test')
+                _save_host.assert_called_with('test')
                 assert cephadm_module.cache.get_scheduled_daemon_action('test', daemon_name) is None
 
     @mock.patch("cephadm.serve.CephadmServe._run_cephadm")
@@ -2849,15 +2849,15 @@ Traceback (most recent call last):
         # pass force=true in these tests to bypass _admin label check
         with with_host(cephadm_module, 'test', refresh_hosts=False, rm_with_force=True):
             cephadm_module.drain_host('test', force=True, zap_osd_devices=False)
-            assert _rm_osds.called_with([], zap=False)
+            _rm_osds.assert_called_with([], zap=False)
 
         with with_host(cephadm_module, 'test', refresh_hosts=False, rm_with_force=True):
             cephadm_module.drain_host('test', force=True, zap_osd_devices=True)
-            assert _rm_osds.called_with([], zap=True)
+            _rm_osds.assert_called_with([], zap=True)
 
         with pytest.raises(OrchestratorError, match=r"Cannot find host 'host1' in the inventory."):
             cephadm_module.drain_host('host1', force=True, zap_osd_devices=True)
-            assert _rm_osds.called_with([], zap=True)
+            _rm_osds.assert_called_with([], zap=True)
 
     def test_process_ls_output(self, cephadm_module):
         sample_ls_output = """[