fix: host_silence proactive notify when event is None

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-11 09:26:03 +10:00
parent 37bffe0e3f
commit 3f7095ed03
3 changed files with 40 additions and 4 deletions
+29
View File
@@ -326,3 +326,32 @@ def test_agent_inventory_hardware_change_template():
assert "железо" in text.lower() or "Изменилось" in text
assert "memory_gb" in text
assert "32" in text
def test_format_problem_host_silence_scan_without_event():
from app.models import Host, Problem
from app.services.problem_rules import RULE_HOST_SILENCE
from app.services.telegram_templates import format_problem_telegram_html
host = Host(
hostname="YURKOV-PC",
os_family="windows",
product="rdp-login-monitor",
last_seen_at=datetime(2026, 6, 11, 9, 0, tzinfo=timezone.utc),
)
problem = Problem(
host_id=1,
host=host,
title="Host silence: YURKOV-PC",
summary="Нет свежего agent.heartbeat более 300 мин",
severity="high",
status="open",
rule_id=RULE_HOST_SILENCE,
fingerprint="fp-silence",
event_count=0,
last_seen_at=datetime(2026, 6, 11, 9, 0, tzinfo=timezone.utc),
)
text = format_problem_telegram_html(problem, event=None)
assert "периодическая проверка SAC" in text
assert "host_silence scan" in text
assert "YURKOV-PC" in text or "UNMS" not in text # host label uses hostname