summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'ironic_python_agent/tests/unit')
-rw-r--r--ironic_python_agent/tests/unit/test_utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py
index 02f2f95d..640d50ca 100644
--- a/ironic_python_agent/tests/unit/test_utils.py
+++ b/ironic_python_agent/tests/unit/test_utils.py
@@ -1195,3 +1195,26 @@ class TestCheckVirtualMedia(ironic_agent_base.IronicAgentTest):
mock_execute.assert_called_with('lsblk', '-n', '-s', '-P', '-b',
'-oKNAME,TRAN,TYPE,SIZE',
'/dev/sdh')
+
+
+class TestCheckEarlyLogging(ironic_agent_base.IronicAgentTest):
+
+ @mock.patch.object(utils, 'LOG', autospec=True)
+ def test_early_logging_goes_to_logger(self, mock_log):
+ info = mock.Mock()
+ mock_log.info.side_effect = info
+ # Reset the buffer to be empty.
+ utils._EARLY_LOG_BUFFER = []
+ # Store some data via _early_log
+ utils._early_log('line 1.')
+ utils._early_log('line 2 %s', 'message')
+ expected_messages = ['line 1.',
+ 'line 2 message']
+ self.assertEqual(expected_messages, utils._EARLY_LOG_BUFFER)
+ # Test we've got data in the buffer.
+ info.assert_not_called()
+ # Test the other half of this.
+ utils.log_early_log_to_logger()
+ expected_calls = [mock.call('Early logging: %s', 'line 1.'),
+ mock.call('Early logging: %s', 'line 2 message')]
+ info.assert_has_calls(expected_calls)