HackerNoon Mobile

Better reading experience on the app
Python: Checking API Application Requests to Third-Party Servicesby@shv

Python: Checking API Application Requests to Third-Party Services

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

I will show you some examples of how you can verify requests to third-party services in tests using of async FastAPI + httpx (not only) + mocks. I'll show you 2 methods. The main task is to compare the request that our application sent to the mock. If it is different, then we need to return an error in the test. At the same time, a correct request may often have a different visual representation, so just comparing the request body with the template will not work. I compare dict or list as it's more flexible.
featured image - Python: Checking API Application Requests to Third-Party Services
Aleksei Sharypov HackerNoon profile picture

@shv

Aleksei Sharypov


Receive Stories from @shv


Credibility

react to story with heart
Aleksei Sharypov HackerNoon profile picture
by Aleksei Sharypov @shv.I’m a Lead Software Developer (Python, Golang, Perl). 15 years of experience in IT.
Read my stories

RELATED STORIES

L O A D I N G
. . . comments & more!