"""Tests for logging module.""" from unittest.mock import patch import pytest from notebooklm_agent.core.config import Settings from notebooklm_agent.core.logging import setup_logging @pytest.mark.unit class TestSetupLogging: """Test suite for setup_logging function.""" @patch("notebooklm_agent.core.logging.structlog.configure") @patch("notebooklm_agent.core.logging.logging.basicConfig") def test_configures_structlog(self, mock_basic_config, mock_structlog_configure): """Should configure structlog with correct processors.""" # Arrange settings = Settings(log_level="INFO", log_format="json") # Act setup_logging(settings) # Assert mock_structlog_configure.assert_called_once() call_args = mock_structlog_configure.call_args assert "processors" in call_args.kwargs @patch("notebooklm_agent.core.logging.structlog.configure") @patch("notebooklm_agent.core.logging.logging.basicConfig") def test_uses_json_renderer_for_json_format(self, mock_basic_config, mock_structlog_configure): """Should use JSONRenderer for json log format.""" # Arrange settings = Settings(log_level="INFO", log_format="json") # Act setup_logging(settings) # Assert processors = mock_structlog_configure.call_args.kwargs["processors"] assert any("JSONRenderer" in str(p) for p in processors) @patch("notebooklm_agent.core.logging.structlog.configure") @patch("notebooklm_agent.core.logging.logging.basicConfig") def test_uses_console_renderer_for_console_format(self, mock_basic_config, mock_structlog_configure): """Should use ConsoleRenderer for console log format.""" # Arrange settings = Settings(log_level="INFO", log_format="console") # Act setup_logging(settings) # Assert processors = mock_structlog_configure.call_args.kwargs["processors"] assert any("ConsoleRenderer" in str(p) for p in processors) @patch("notebooklm_agent.core.logging.structlog.configure") @patch("notebooklm_agent.core.logging.logging.basicConfig") def test_sets_uvicorn_log_level(self, mock_basic_config, mock_structlog_configure): """Should set uvicorn loggers to WARNING.""" # Arrange settings = Settings(log_level="INFO", log_format="json") # Act setup_logging(settings) # Assert # basicConfig should be called mock_basic_config.assert_called_once()