Files
hunjing/backend/tests/modules/time_sense/test_context_text.py
T
2026-08-21 16:00:13 +08:00

40 lines
1.5 KiB
Python

"""temporal_context 文本组装测试(辰正 §8.1)。"""
from app.modules.time_sense.context_text import render_temporal_context
def test_context_contains_shichen_and_period():
from app.modules.time_sense.modulation import ModulationInput, compute_modulation
from tests.modules.time_sense.test_modulation import _snapshot
snap = _snapshot(day_period="深夜", local_hour=23)
factors = compute_modulation(snap, ModulationInput())
text = render_temporal_context(snap, factors)
assert "深夜" in text
assert "周" in text
def test_context_reunion_line():
from app.modules.time_sense.duration import OfflineDuration
from app.modules.time_sense.modulation import ModulationInput, compute_modulation
from tests.modules.time_sense.test_modulation import _snapshot
snap = _snapshot(
offline=OfflineDuration(minutes=4320 * 2, band="reunion_impact", reunion_intensity=0.7)
)
factors = compute_modulation(snap, ModulationInput())
text = render_temporal_context(snap, factors)
assert "久别重逢" in text
def test_context_no_lunar_does_not_crash():
"""lunar=None 时第二行跳过,不抛异常。"""
from app.modules.time_sense.modulation import ModulationInput, compute_modulation
from tests.modules.time_sense.test_modulation import _snapshot
snap = _snapshot(lunar=None)
factors = compute_modulation(snap, ModulationInput())
text = render_temporal_context(snap, factors)
assert isinstance(text, str)
assert len(text) > 0