add tests for machines api

This commit is contained in:
Jörg Thalheim
2023-08-24 19:16:44 +02:00
parent 58adf91af8
commit 33b43ae146
5 changed files with 71 additions and 13 deletions

View File

@@ -0,0 +1,21 @@
from pathlib import Path
from api import TestClient
def test_machines(api: TestClient, clan_flake: Path) -> None:
response = api.get("/api/machines")
assert response.status_code == 200
assert response.json() == {"machines": []}
response = api.post("/api/machines", json={"name": "test"})
assert response.status_code == 201
assert response.json() == {"machine": {"name": "test", "status": "unknown"}}
response = api.get("/api/machines/test")
assert response.status_code == 200
assert response.json() == {"machine": {"name": "test", "status": "unknown"}}
response = api.get("/api/machines")
assert response.status_code == 200
assert response.json() == {"machines": [{"name": "test", "status": "unknown"}]}