ems-core v1.0.0: Standard EMS platform core
Shared backend + frontend for multi-customer EMS deployments. - 12 enterprise modules: quota, cost, charging, maintenance, analysis, etc. - 120+ API endpoints, 37 database tables - Customer config mechanism (CUSTOMER env var + YAML config) - Collectors: Modbus TCP, MQTT, HTTP API, Sungrow iSolarCloud - Frontend: React 19 + Ant Design + ECharts + Three.js - Infrastructure: Redis cache, rate limiting, aggregation engine Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
44
backend/tests/test_monitoring.py
Normal file
44
backend/tests/test_monitoring.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import pytest
|
||||
from conftest import auth_header
|
||||
|
||||
|
||||
class TestDeviceRealtime:
|
||||
async def test_get_device_realtime(self, client, admin_user, admin_token, seed_devices, seed_energy_data):
|
||||
device = seed_devices[0]
|
||||
resp = await client.get(
|
||||
f"/api/v1/monitoring/devices/{device.id}/realtime",
|
||||
headers=auth_header(admin_token),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert "device" in body
|
||||
assert "data" in body
|
||||
assert body["device"]["id"] == device.id
|
||||
|
||||
async def test_get_device_realtime_no_device(self, client, admin_user, admin_token):
|
||||
resp = await client.get(
|
||||
"/api/v1/monitoring/devices/99999/realtime",
|
||||
headers=auth_header(admin_token),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["device"] is None
|
||||
|
||||
async def test_get_device_realtime_unauthenticated(self, client):
|
||||
resp = await client.get("/api/v1/monitoring/devices/1/realtime")
|
||||
assert resp.status_code == 401
|
||||
|
||||
|
||||
class TestEnergyFlow:
|
||||
async def test_get_energy_flow(self, client, admin_user, admin_token, seed_devices, seed_energy_data):
|
||||
resp = await client.get("/api/v1/monitoring/energy-flow", headers=auth_header(admin_token))
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert "nodes" in body
|
||||
assert "links" in body
|
||||
assert len(body["nodes"]) == 4
|
||||
assert len(body["links"]) == 4
|
||||
|
||||
async def test_get_energy_flow_unauthenticated(self, client):
|
||||
resp = await client.get("/api/v1/monitoring/energy-flow")
|
||||
assert resp.status_code == 401
|
||||
Reference in New Issue
Block a user