import unittest from unittest.mock import Mock, patch from fjerkroa_bot import bot_logging class TestMainEntry(unittest.TestCase): """Test the main entry points.""" def test_main_module_exists(self): """Test that the main module exists and is executable.""" import os main_file = "fjerkroa_bot/__main__.py" self.assertTrue(os.path.exists(main_file)) # Read the content to verify it calls main with open(main_file) as f: content = f.read() self.assertIn("main()", content) self.assertIn("sys.exit", content) class TestBotLogging(unittest.TestCase): """Test bot logging functionality.""" @patch("fjerkroa_bot.bot_logging.logging.basicConfig") def test_setup_logging_default(self, mock_basic_config): """Test setup_logging with default level.""" bot_logging.setup_logging() mock_basic_config.assert_called_once() call_args = mock_basic_config.call_args self.assertIn("level", call_args.kwargs) self.assertIn("format", call_args.kwargs) @patch("fjerkroa_bot.bot_logging.logging.basicConfig") def test_setup_logging_custom_level(self, mock_basic_config): """Test setup_logging with custom level.""" import logging bot_logging.setup_logging(logging.DEBUG) mock_basic_config.assert_called_once() call_args = mock_basic_config.call_args self.assertEqual(call_args.kwargs["level"], logging.DEBUG) @patch("fjerkroa_bot.bot_logging.logging.getLogger") def test_setup_logging_discord_logger(self, mock_get_logger): """Test that discord logger is configured.""" mock_logger = Mock() mock_get_logger.return_value = mock_logger bot_logging.setup_logging() # Should get the discord logger mock_get_logger.assert_called_with("discord") # Should set its level mock_logger.setLevel.assert_called_once() if __name__ == "__main__": unittest.main()