Fix recovery Telegram dedup and unify Beijing time display.
Store alert metrics without per-value Redis members to stop duplicate recovery pushes; format all operator-facing timestamps in Asia/Shanghai across Web UI and Telegram.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
"""Telegram timestamps should display Beijing local time."""
|
||||
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from server.infrastructure.telegram import _now_cn
|
||||
from server.utils.display_time import format_beijing_now
|
||||
|
||||
|
||||
def test_now_cn_uses_beijing_timezone_label():
|
||||
text = _now_cn()
|
||||
assert text == format_beijing_now()
|
||||
assert text.endswith("北京时间")
|
||||
assert "UTC" not in text
|
||||
wall = text.replace(" 北京时间", "")
|
||||
parsed = datetime.strptime(wall, "%Y-%m-%d %H:%M:%S").replace(tzinfo=ZoneInfo("Asia/Shanghai"))
|
||||
utc_now = datetime.now(ZoneInfo("UTC"))
|
||||
delta_seconds = abs((parsed - utc_now).total_seconds())
|
||||
assert delta_seconds < 120
|
||||
Reference in New Issue
Block a user