A
A
alekssamos2020-08-19 06:18:07
Python
alekssamos, 2020-08-19 06:18:07

How to write tests for the library API?

Let's say I write a class as a wrapper for a certain service. To work with it, you need a complex (long) registration and replenishment of the account (balance).
Instead of requests, I made a mock fake function. I checked everything else, it works,
and suddenly it turned out that there was an error in that real function that was replaced through mock, GET parameters were not correctly transmitted to the server.
So, what is the right way to test such things? During the test, raise your service, which will check the sent parameters and respond to the same JSON original service? For example, I raise flask to port 8080, connect a class, write self.url = "http://localhost:8080/"and already test based on it?
Or are there other ways?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alekssamos, 2020-08-19
@alekssamos

Yes, I asked and answered. This thing will do: https://github.com/getsentry/responses .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question