diff --git a/src/tests/pytest.ini b/src/tests/pytest.ini new file mode 100644 index 0000000..27eec68 --- /dev/null +++ b/src/tests/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +testpaths = tests +python_files = test_*.py diff --git a/src/tests/tests_factcheck_endpoint.py b/src/tests/tests_factcheck_endpoint.py new file mode 100644 index 0000000..fc3d3f9 --- /dev/null +++ b/src/tests/tests_factcheck_endpoint.py @@ -0,0 +1,19 @@ +# tests/test_factcheck_endpoint.py + +import pytest +from httpx import AsyncClient +from app import app # Adjust the import based on your project structure + +@pytest.mark.asyncio +async def test_factcheck_endpoint(): + async with AsyncClient(app=app, base_url="http://test") as ac: + payload = { + "claim": "The Eiffel Tower is located in Berlin." + } + response = await ac.post("/factcheck", json=payload) + assert response.status_code == 200 + data = response.json() + assert "verdict" in data + assert "evidence" in data + assert data["verdict"] in ["true", "false", "uncertain"] + diff --git a/src/tests/tests_health_endpoint.py b/src/tests/tests_health_endpoint.py new file mode 100644 index 0000000..4c8ca52 --- /dev/null +++ b/src/tests/tests_health_endpoint.py @@ -0,0 +1,12 @@ +# tests/test_health_endpoint.py + +import pytest +from httpx import AsyncClient +from app import app + +@pytest.mark.asyncio +async def test_health_endpoint(): + async with AsyncClient(app=app, base_url="http://test") as ac: + response = await ac.get("/health") + assert response.status_code == 200 + assert response.json() == {"status": "ok"} diff --git a/src/tests/tests_search_endpoint.py b/src/tests/tests_search_endpoint.py new file mode 100644 index 0000000..19f3b88 --- /dev/null +++ b/src/tests/tests_search_endpoint.py @@ -0,0 +1,17 @@ +# tests/test_search_endpoint.py + +import pytest +from httpx import AsyncClient +from app import app + +@pytest.mark.asyncio +async def test_search_endpoint(): + async with AsyncClient(app=app, base_url="http://test") as ac: + params = {"query": "climate change"} + response = await ac.get("/search", params=params) + assert response.status_code == 200 + data = response.json() + assert isinstance(data, list) + for item in data: + assert "title" in item + assert "url" in item