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