feat: FastAPI app with REST API routes and WebSocket endpoint
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
29
tests/test_api_broker.py
Normal file
29
tests/test_api_broker.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient, ASGITransport
|
||||
|
||||
from mqtt_home.main import app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def client():
|
||||
transport = ASGITransport(app=app)
|
||||
async with AsyncClient(transport=transport, base_url="http://test") as ac:
|
||||
yield ac
|
||||
|
||||
|
||||
async def test_broker_status_no_client(client):
|
||||
resp = await client.get("/api/broker/status")
|
||||
assert resp.status_code == 503
|
||||
|
||||
|
||||
async def test_broker_clients_no_client(client):
|
||||
resp = await client.get("/api/broker/clients")
|
||||
assert resp.status_code == 503
|
||||
|
||||
|
||||
async def test_health_endpoint(client):
|
||||
resp = await client.get("/health")
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()
|
||||
assert "status" in data
|
||||
assert "mqtt_connected" in data
|
||||
Reference in New Issue
Block a user