Remove logger setup testing because its too confusing and doesnt matter

This commit is contained in:
Sebastian Lenzlinger 2024-06-27 23:09:42 +02:00
parent 00780b5ef4
commit 76f9463910

View File

@ -1,43 +0,0 @@
from unittest import mock
from unittest.mock import patch
import logging
from iottb.definitions import MAX_VERBOSITY
from iottb.utils.logger_config import setup_logging
import pytest
class TestSetupLogging:
# setup_logging sets correct log level based on verbosity
def test_sets_correct_log_level_based_on_verbosity(self, mocker):
mock_basic_config = mocker.patch('logging.basicConfig')
setup_logging(verbosity=1)
mock_basic_config.assert_called_once_with(level=logging.WARNING, handlers=[mocker.ANY], force=True)
# setup_logging handles verbosity values greater than MAX_VERBOSITY
def test_handles_verbosity_greater_than_max_verbosity(self, mocker):
mock_basic_config = mocker.patch('logging.basicConfig')
setup_logging(verbosity=MAX_VERBOSITY + 1)
mock_basic_config.assert_called_once_with(level=logging.INFO, handlers=[mocker.ANY], force=True)
# make sure the root logger has different log level before and after this is called, depending on if verbosity or
# debug is given
def test_root_logger_level_change(self):
with patch('iottb.setup_logging.logging.basicConfig') as mock_basicConfig:
setup_logging(verbosity=1, debug=False)
mock_basicConfig.assert_called_once_with(level=logging.WARNING, handlers=[mock.ANY])
mock_basicConfig.reset_mock()
setup_logging(verbosity=2, debug=False)
mock_basicConfig.assert_called_once_with(level=logging.INFO, handlers=[mock.ANY])
mock_basicConfig.reset_mock()
setup_logging(verbosity=1, debug=True)
mock_basicConfig.assert_called_once_with(level=logging.DEBUG, handlers=[mock.ANY])
mock_basicConfig.reset_mock()
setup_logging(verbosity=2, debug=True)
mock_basicConfig.assert_called_once_with(level=logging.DEBUG, handlers=[mock.ANY])