🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
30 lines
739 B
Python
30 lines
739 B
Python
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
|