import pytest
from httpx import AsyncClient
from project import app as fastapi_app
from fastapi import Request
from fastapi_azure_auth.user import User
from project import azure_scheme
@pytest.fixture
async def normal_user_client():
async def mock_normal_user(request: Request):
user = User(
claims={},
preferred_username="NormalUser",
roles=[],
aud="aud",
tid="tid",
access_token="123",
is_guest=False,
iat=1537231048,
nbf=1537231048,
exp=1537234948,
iss="iss",
aio="aio",
sub="sub",
oid="oid",
uti="uti",
rh="rh",
ver="2.0",
)
request.state.user = user
return user
fastapi_app.dependency_overrides[azure_scheme] = mock_normal_user
async with AsyncClient(app=fastapi_app, base_url='http://test') as ac:
yield ac
@pytest.mark.asyncio
async def test_get_workout_plans(normal_user_client):
response = await normal_user_client.get("/workout-plans")
assert response.status_coode == 200
assert type(response.json()) == list
Help i wanan do some cllient testing. BTW, I'm using FastAPI-Azure-Auth. That's why this is the state of my client. I just copied this from the documentation, and I'm quite not sure of its usage.I already googled and chatgpt this error.ugm no solution thereof