55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
import unittest
|
|
from unittest.mock import 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)
|
|
|
|
def test_setup_logging_function_exists(self):
|
|
"""Test that setup_logging function exists and is callable."""
|
|
self.assertTrue(callable(bot_logging.setup_logging))
|
|
|
|
@patch("fjerkroa_bot.bot_logging.logging.basicConfig")
|
|
def test_setup_logging_calls_basicConfig(self, mock_basic_config):
|
|
"""Test that setup_logging calls basicConfig."""
|
|
bot_logging.setup_logging()
|
|
|
|
mock_basic_config.assert_called_once()
|
|
# Verify it sets up logging properly
|
|
call_args = mock_basic_config.call_args
|
|
self.assertIn("level", call_args.kwargs)
|
|
self.assertIn("format", call_args.kwargs)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|