19 lines
558 B
Python
19 lines
558 B
Python
from __future__ import annotations
|
|
|
|
from bakrest.server_check import ServerStatus
|
|
from bakrest.server_notifier import should_alert
|
|
|
|
|
|
def test_notifier_alerts_once_while_server_is_down() -> None:
|
|
status = ServerStatus(False, "now", "down")
|
|
|
|
assert should_alert(status, None)
|
|
assert not should_alert(status, "unreachable")
|
|
assert should_alert(status, "unreachable", always_alert=True)
|
|
|
|
|
|
def test_notifier_does_not_alert_when_server_is_reachable() -> None:
|
|
status = ServerStatus(True, "now", "ok")
|
|
|
|
assert not should_alert(status, None)
|