async def test_async_enable_logging(hass): """Test to ensure logging is migrated to the queue handlers.""" with patch("logging.getLogger"), patch( "homeassistant.bootstrap.async_activate_log_queue_handler" ) as mock_async_activate_log_queue_handler: bootstrap.async_enable_logging(hass) mock_async_activate_log_queue_handler.assert_called_once()
async def test_async_enable_logging(hass): """Test to ensure logging is migrated to the queue handlers.""" with patch("logging.getLogger"), patch( "homeassistant.bootstrap.async_activate_log_queue_handler" ) as mock_async_activate_log_queue_handler: bootstrap.async_enable_logging(hass) mock_async_activate_log_queue_handler.assert_called_once() mock_async_activate_log_queue_handler.reset_mock() bootstrap.async_enable_logging( hass, log_rotate_days=5, log_file="test.log", ) mock_async_activate_log_queue_handler.assert_called_once() for f in glob.glob("test.log*"): os.remove(f) for f in glob.glob("testing_config/home-assistant.log*"): os.remove(f)
async def test_async_enable_logging(hass, caplog): """Test to ensure logging is migrated to the queue handlers.""" with patch("logging.getLogger"), patch( "homeassistant.bootstrap.async_activate_log_queue_handler" ) as mock_async_activate_log_queue_handler, patch( "homeassistant.bootstrap.logging.handlers.RotatingFileHandler.doRollover", side_effect=OSError, ): bootstrap.async_enable_logging(hass) mock_async_activate_log_queue_handler.assert_called_once() mock_async_activate_log_queue_handler.reset_mock() bootstrap.async_enable_logging( hass, log_rotate_days=5, log_file="test.log", ) mock_async_activate_log_queue_handler.assert_called_once() for f in glob.glob("test.log*"): os.remove(f) for f in glob.glob("testing_config/home-assistant.log*"): os.remove(f) assert "Error rolling over log file" in caplog.text