You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1016 B
Python
33 lines
1016 B
Python
"""Unit tests for common.logging module."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def test_configure_logging_no_error():
|
|
"""configure_logging("DEBUG") 호출 시 예외가 발생하지 않아야 한다."""
|
|
from libs.common.logging import configure_logging
|
|
|
|
configure_logging("DEBUG")
|
|
configure_logging("INFO") # reset to INFO after
|
|
|
|
|
|
def test_bind_job_run_id_in_context():
|
|
"""bind_job_run_id 후 ContextVar에 run_id가 설정된다."""
|
|
from libs.common.logging import _job_run_id, bind_job_run_id
|
|
|
|
bind_job_run_id("RUN::test-001")
|
|
assert _job_run_id.get() == "RUN::test-001"
|
|
# cleanup
|
|
bind_job_run_id("")
|
|
|
|
|
|
def test_get_logger_returns_bound_logger():
|
|
"""get_logger("name") 결과가 logging 메서드를 가진 객체를 반환한다."""
|
|
from libs.common.logging import get_logger
|
|
|
|
logger = get_logger("test.module")
|
|
assert hasattr(logger, "info")
|
|
assert hasattr(logger, "debug")
|
|
assert hasattr(logger, "warning")
|
|
assert hasattr(logger, "error")
|