修复高风险预警邮件通知并补充测试
This commit is contained in:
@@ -38,6 +38,8 @@ class _FakeNotificationService:
|
||||
def __init__(self, *, fail: bool = False) -> None:
|
||||
self.fail = fail
|
||||
self.in_app: list[str] = []
|
||||
self.mail_records: list[Any] = []
|
||||
self.mail_marks: list[tuple[str, str | None]] = []
|
||||
|
||||
def create_in_app(self, alert: Any, **kwargs: Any) -> None:
|
||||
if self.fail:
|
||||
@@ -47,6 +49,22 @@ class _FakeNotificationService:
|
||||
def create_mail_record(self, alert: Any, **kwargs: Any) -> None:
|
||||
if self.fail:
|
||||
raise RuntimeError("邮件记录写库失败")
|
||||
notification = SimpleNamespace(
|
||||
alert=alert,
|
||||
send_status="待发送",
|
||||
sent_at=None,
|
||||
fail_reason=None,
|
||||
)
|
||||
self.mail_records.append(notification)
|
||||
return notification
|
||||
|
||||
def mark_mail_sent(self, notification: Any) -> None:
|
||||
self.mail_marks.append(("sent", None))
|
||||
notification.send_status = "已发送"
|
||||
|
||||
def mark_mail_failed(self, notification: Any, reason: str) -> None:
|
||||
self.mail_marks.append(("failed", reason))
|
||||
notification.send_status = "发送失败"
|
||||
|
||||
|
||||
def _alert(level: str, alert_no: str = "ALTEST") -> Any:
|
||||
|
||||
Reference in New Issue
Block a user