import pytest
from rec_sdk_common.log.log import LoggingProxy
from rec_sdk_common.constants.constants import LogLevel
class TestLoggingProxy:
"""Test for 'mxrec.python.util.log.LoggingProxy'."""
@staticmethod
def teardown_method():
LoggingProxy._instance = None
@staticmethod
def test_info_log_ok():
LoggingProxy.set_instance(LogLevel.INFO.value)
try:
LoggingProxy.info("Test log, we have a %s, log level is %s.", "interesting problem", "info")
except Exception as e:
pytest.fail(f"unexpected exception raised: {e}")
@staticmethod
def test_debug_log_ok():
LoggingProxy.set_instance(LogLevel.DEBUG.value)
try:
LoggingProxy.debug("Test log, we have a %s, log level is %s.", "thorny problem", "debug")
except Exception as e:
pytest.fail(f"unexpected exception raised: {e}")
@staticmethod
def test_warning_log_ok():
LoggingProxy.set_instance(LogLevel.WARNING.value)
try:
LoggingProxy.warning("Test log, we have a %s, log level is %s.", "bit of a problem", "warning")
except Exception as e:
pytest.fail(f"unexpected exception raised: {e}")
@staticmethod
def test_error_log_ok():
LoggingProxy.set_instance(LogLevel.ERROR.value)
try:
LoggingProxy.error("Test log, we have a %s, log level is %s.", "major problem", "error")
except Exception as e:
pytest.fail(f"unexpected exception raised: {e}")
@staticmethod
def test_exception_log_ok():
LoggingProxy.set_instance(LogLevel.ERROR.value)
try:
LoggingProxy.exception("Test log, we have a %s, log level is %s.", "exception problem", "exception")
except Exception as e:
pytest.fail(f"unexpected exception raised: {e}")
@staticmethod
def test_critical_log_ok():
LoggingProxy.set_instance(LogLevel.CRITICAL.value)
try:
LoggingProxy.critical("Test log, we have a %s, log level is %s.", "major disaster", "critical")
except Exception as e:
pytest.fail(f"unexpected exception raised: {e}")