Skip to content

Commit

Permalink
test: make test use fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
grieve54706 committed Dec 19, 2024
1 parent 959cc1d commit 6505d51
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions ibis-server/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
from fastapi.testclient import TestClient

from app.main import app

client = TestClient(app)


def test_root():
response = client.get("/")
async def test_root(client):
response = await client.get("/")
assert response.status_code == 200
assert response.url == client.base_url.join("/docs")


def test_health():
response = client.get("/health")
async def test_health(client):
response = await client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}


def test_config():
response = client.get("/config")
async def test_config(client):
response = await client.get("/config")
assert response.status_code == 200
assert response.json() == {
"wren_engine_endpoint": "http://localhost:8080",
Expand All @@ -27,16 +20,16 @@ def test_config():
}


def test_update_diagnose():
response = client.patch("/config", json={"diagnose": True})
async def test_update_diagnose(client):
response = await client.patch("/config", json={"diagnose": True})
assert response.status_code == 200
assert response.json()["diagnose"] is True
response = client.get("/config")
response = await client.get("/config")
assert response.status_code == 200
assert response.json()["diagnose"] is True
response = client.patch("/config", json={"diagnose": False})
response = await client.patch("/config", json={"diagnose": False})
assert response.status_code == 200
assert response.json()["diagnose"] is False
response = client.get("/config")
response = await client.get("/config")
assert response.status_code == 200
assert response.json()["diagnose"] is False

0 comments on commit 6505d51

Please sign in to comment.