discord_bot/tests/test_main_entry.py
Oleksandr Kozachuk 1a5da0ae7c Add comprehensive test suite to improve coverage and fix igdblib bugs
- Add extensive tests for igdblib.py (0% -> 100% coverage expected)
- Add tests for leonardo_draw.py AI image generation
- Add tests for openai_responder.py with GPT integration
- Add tests for discord_bot.py bot functionality
- Add extended tests for ai_responder.py edge cases
- Fix critical bugs in igdblib.py:
  * Fix platforms() method treating name as string instead of list
  * Fix game_info() method missing endpoint parameter
  * Add safe dictionary access with .get() methods

Coverage improvements target areas with lowest coverage to maximize impact.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 19:34:41 +02:00

61 lines
2.0 KiB
Python

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()