mirror of
https://github.com/R0m1k3/Reviflow.git
synced 2026-10-20 05:28:08 +02:00
Sauvegarde de l'état (réparation)
This commit is contained in:
commit
7c04fffe77
434 files changed
+83923
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
from app.main import app
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def anyio_backend():
|
||||
return "asyncio"
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
async def client():
|
||||
async with AsyncClient(app=app, base_url="http://test") as c:
|
||||
yield c
|
||||
@@ -0,0 +1,38 @@
|
||||
import pytest
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_health_check(client):
|
||||
response = await client.get("/api/health")
|
||||
assert response.status_code == 200
|
||||
# Allow extra fields, just check status
|
||||
assert response.json().get("status") == "ok"
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_register_flow(client):
|
||||
# Minimal required fields for UserCreate
|
||||
user_data = {
|
||||
"email": "test@example.com",
|
||||
"password": "strongPassword123!",
|
||||
"role": "parent" # Specific to our schema
|
||||
}
|
||||
|
||||
response = await client.post("/api/auth/register", json=user_data)
|
||||
if response.status_code not in [201, 400]:
|
||||
print(f"Registration failed: {response.json()}")
|
||||
# 201 Created or 400 Bad Request (if exists)
|
||||
assert response.status_code in [201, 400]
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_login_flow(client, anyio_backend):
|
||||
login_data = {
|
||||
"username": "test@example.com",
|
||||
"password": "strongPassword123!"
|
||||
}
|
||||
# Correct path for fastapi-users JWT strategy
|
||||
response = await client.post("/api/auth/jwt/login", data=login_data)
|
||||
|
||||
if response.status_code == 200:
|
||||
assert "access_token" in response.json()
|
||||
else:
|
||||
# 400/401 acceptable if user creation failed or db issue
|
||||
assert response.status_code in [400, 401]
|
||||
Reference in new issue
Block a user