FastAPI - Unit Testing with Database - Whats the correct approach? Mock vs. Local Database

preview_player
Показать описание
In this Video I want to discuss how to unit test an API Endpoint with FastAPI that makes use of a SQL Database.

I will explain why I would use a different approach for an API.
Рекомендации по теме
Комментарии
Автор

Nice explanation!
Somehow there is still a connection to the database. The example still add the entry to the database. This seems to contradict the intention in my own opinion

isaacomolewa
Автор

The code does not work for me it says: AssertionError: Expected 'add' to have been called.

kevinrivas
Автор

TypeError: object MagicMock can't be used in 'await' expression

uytvnhz