From 040924ee636e74f9c9f78a6755047ee5704b5636 Mon Sep 17 00:00:00 2001 From: Mahnoor Asghar Date: Fri, 16 Aug 2024 12:41:42 -0400 Subject: [PATCH] Add unit test to ensure full node object is not logged Change-Id: Ief6351f77a06966200c5cdaa443cc89e49198eec --- ironic/tests/unit/conductor/test_cleaning.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ironic/tests/unit/conductor/test_cleaning.py b/ironic/tests/unit/conductor/test_cleaning.py index 3a2d447b00..a963536ec1 100644 --- a/ironic/tests/unit/conductor/test_cleaning.py +++ b/ironic/tests/unit/conductor/test_cleaning.py @@ -165,9 +165,10 @@ class DoNodeCleanTestCase(db_base.DbTestCase): def test__do_node_clean_automated_cache_bios_unsupported(self): self._test__do_node_clean_cache_bios(enable_unsupported=True) + @mock.patch.object(cleaning, 'LOG', autospec=True) @mock.patch('ironic.drivers.modules.fake.FakePower.validate', autospec=True) - def test__do_node_clean_automated_disabled(self, mock_validate): + def test__do_node_clean_automated_disabled(self, mock_validate, mock_log): self.config(automated_clean=False, group='conductor') node = obj_utils.create_test_node( @@ -187,6 +188,12 @@ class DoNodeCleanTestCase(db_base.DbTestCase): self.assertEqual({}, node.clean_step) self.assertNotIn('clean_steps', node.driver_internal_info) self.assertNotIn('clean_step_index', node.driver_internal_info) + mock_log.info.assert_called_once_with("Automated cleaning is disabled " + "via %(how)s, node %(node)s has " + "been successfully moved to " + "AVAILABLE state", + {'how': 'configuration', + 'node': node.uuid}) @mock.patch('ironic.drivers.modules.fake.FakePower.validate', autospec=True)