v1.1.0: Alembic, pytest, домен и документация
- Миграции PostgreSQL через Alembic; DDL убран из lifespan приложения. - Тесты: health, status, ingress Grafana; моки Vault/Grafana/Forgejo. - Пакет onguard24/domain/ (сущности, шина событий), docs/DOMAIN.md. - Обновлены README, CHANGELOG, ARCHITECTURE. Made-with: Cursor
This commit is contained in:
22
tests/test_domain.py
Normal file
22
tests/test_domain.py
Normal file
@ -0,0 +1,22 @@
|
||||
import pytest
|
||||
|
||||
from onguard24.domain import Alert, AlertReceived, InMemoryEventBus, Severity
|
||||
|
||||
|
||||
def test_alert_model() -> None:
|
||||
a = Alert(source="grafana", severity=Severity.CRITICAL, title="x")
|
||||
assert a.source == "grafana"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_event_bus_alert_received() -> None:
|
||||
seen: list[str] = []
|
||||
|
||||
async def h(ev: AlertReceived) -> None:
|
||||
seen.append(ev.name)
|
||||
|
||||
bus = InMemoryEventBus()
|
||||
bus.subscribe("alert.received", h) # type: ignore[arg-type]
|
||||
a = Alert(source="grafana")
|
||||
await bus.publish_alert_received(a)
|
||||
assert seen == ["alert.received"]
|
||||
Reference in New Issue
Block a user