Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
testpaths = tests
python_files = test_*.py
36 changes: 36 additions & 0 deletions src/tests/tests_factcheck_endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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"]
# tests/test_factcheck_endpoint.py

import pytest

Check warning on line 21 in src/tests/tests_factcheck_endpoint.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/tests/tests_factcheck_endpoint.py#L21

Reimport 'pytest' (imported line 3)
from httpx import AsyncClient

Check warning on line 22 in src/tests/tests_factcheck_endpoint.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/tests/tests_factcheck_endpoint.py#L22

Reimport 'AsyncClient' (imported line 4)
from app import app # Adjust the import based on your project structure

Check warning on line 23 in src/tests/tests_factcheck_endpoint.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/tests/tests_factcheck_endpoint.py#L23

Reimport 'app' (imported line 5)

@pytest.mark.asyncio
async def test_factcheck_endpoint():

Check failure on line 26 in src/tests/tests_factcheck_endpoint.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/tests/tests_factcheck_endpoint.py#L26

function already defined line 8
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"]
12 changes: 12 additions & 0 deletions src/tests/tests_health_endpoint.py
Original file line number Diff line number Diff line change
@@ -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"}
17 changes: 17 additions & 0 deletions src/tests/tests_status.py
Original file line number Diff line number Diff line change
@@ -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