Files
yunke/yunke-server/tests/test_analytics_api.py
T
2026-09-04 15:37:13 +08:00

40 lines
1.1 KiB
Python

"""/api/analytics/health:E0-lite 冒烟。"""
from __future__ import annotations
from app.db.models import MsgDailyStats
async def test_health_empty(make_client):
async def seed(session):
...
client = await make_client(seed)
r = await client.get("/api/analytics/health")
assert r.status_code == 200
body = r.json()
assert body["data_as_of"] is None
assert any(e["table"] == "message" for e in body["entities"])
async def test_health_with_stats(make_client):
async def seed(session):
session.add(
MsgDailyStats(
channel="wechat",
owner_account_id="wx1",
peer_kind="friend",
peer_id="t1",
day=20260904,
send_cnt=1,
recv_cnt=2,
last_ts=1756900000000,
last_is_send=False,
)
)
await session.commit()
client = await make_client(seed)
r = await client.get("/api/analytics/health")
assert r.status_code == 200
assert r.json()["data_as_of"] == 1756900000000