Implement Monlet MVP stack and UI updates

This commit is contained in:
Stanislav Rossovskii
2026-05-27 10:01:59 +04:00
parent dcea096327
commit edc51e9c59
145 changed files with 15618 additions and 248 deletions

View File

@@ -0,0 +1,33 @@
import json
import os
import pytest
from sqlalchemy import select
from monlet_server.models import Agent, Check, Incident
EXAMPLES = os.path.join(os.path.dirname(__file__), "..", "..", "examples")
@pytest.mark.asyncio
async def test_examples_payload(app_client, auth_headers, session):
with open(os.path.join(EXAMPLES, "heartbeat.json")) as f:
hb = json.load(f)
with open(os.path.join(EXAMPLES, "event-batch.json")) as f:
batch = json.load(f)
r = await app_client.post("/api/v1/heartbeat", json=hb, headers=auth_headers)
assert r.status_code == 202
r = await app_client.post("/api/v1/events", json=batch, headers=auth_headers)
assert r.status_code == 202
agents = (await session.execute(select(Agent))).scalars().all()
assert len(agents) == 1
checks = (await session.execute(select(Check))).scalars().all()
assert {c.check_id for c in checks} == {"disk_root", "postgres_up"}
open_inc = (
(await session.execute(select(Incident).where(Incident.state == "open"))).scalars().all()
)
assert len(open_inc) == 1
assert open_inc[0].check_id == "postgres_up"