How do you test request validation in FastAPI?

The default approach involves using TestClient. However, I found that mocking the database, background tasks, etc., is overkill. Do you have any suggestions?

6 points · 2 comments · view on lemmy.world

2 Comments

bradbeattie@lemmy.ca · 1 pts · 295d (1 reply)

If you don't want to test the round trip, have your fastapi routes call some other function and test just that function.

vi21@lemmy.ml · 1 pts · 261d

Do you mean moving Pydantic models as arguments of other function?