40 lines
1012 B
Python
40 lines
1012 B
Python
|
|
"""logger.py DTO 单元测试。
|
||
|
|
|
||
|
|
覆盖 ``LogLevel`` 枚举的取值、字符串继承与成员完整性。
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
from yuxi.channels.contract.dtos.logger import LogLevel
|
||
|
|
|
||
|
|
pytestmark = pytest.mark.unit
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.unit
|
||
|
|
class TestLogLevel:
|
||
|
|
"""日志级别枚举测试。"""
|
||
|
|
|
||
|
|
def test_enum_values_are_correct(self):
|
||
|
|
# Arrange
|
||
|
|
# Act
|
||
|
|
# Assert - 校验四个枚举成员的字符串值
|
||
|
|
assert LogLevel.DEBUG == "debug"
|
||
|
|
assert LogLevel.INFO == "info"
|
||
|
|
assert LogLevel.WARN == "warn"
|
||
|
|
assert LogLevel.ERROR == "error"
|
||
|
|
|
||
|
|
def test_enum_inherits_from_str(self):
|
||
|
|
# Arrange
|
||
|
|
# Act
|
||
|
|
# Assert - StrEnum 应继承 str 并支持字符串比较
|
||
|
|
assert issubclass(LogLevel, str)
|
||
|
|
assert isinstance(LogLevel.INFO, str)
|
||
|
|
|
||
|
|
def test_enum_has_four_members(self):
|
||
|
|
# Arrange
|
||
|
|
# Act
|
||
|
|
members = list(LogLevel)
|
||
|
|
# Assert
|
||
|
|
assert len(members) == 4
|