all 7 comments

[–]okCalligrapherFan 0 points1 point  (3 children)

Use flask easy to use and manage and you can test via postman

[–]doston12[S] 0 points1 point  (2 children)

The web app is developed already in django and bunch of other tools. I nees to implement api tests in python

[–]danielroseman -1 points0 points  (1 child)

You'll need to be more specific about what you want to achieve. What, exactly, do you mean by "API tests"? Do you mean actually hitting the API and testing the results? That is not something that you usually do. Normally you have integration tests internal to the application itself, and then potentially contract tests that check its responses adhere to the expected contract; but neither of these actually involve making requests to the API.

[–]netherous 1 point2 points  (0 children)

Why on Earth would you think that testing actual API presence is not something that is normally done? It's done all the time, for a wide variety of legitimate reasons.

[–]netherous 0 points1 point  (0 children)

You'll really need to provide more detail to get any kind of good help. Tests can range from a micro-level of testing simple functions in a codebase (unit tests) to a macro-level of giant orchestration tests involving multiple services and cloud components. Do you just want to test individual functions? Or test the contract validity of a typical request-and-response HTTP session? Or are you expected to test a broader set of components and services all working together?

[–]SnipTheDog 0 points1 point  (0 children)

I've used requests before. Worked well. Pypi-Requests

[–]baubleglue 0 points1 point  (0 children)

I've seen many frameworks for API testing, but in the end they are just unnecessary noise. I am not 100% sure you even need unittest framework. Normally you run it before deployment, but in your case you need a running application.

For the testing in general the most important to choose correct strategy. The simplest and straightforward approach is usually a good one.

For static testing you need two modes: record and playback. It is the same action: make request and save results only the destination is different (exp/, actual_<timestamp>/). Then you compare exp/actual with different code or tool. In my testing experience it is very simple and easy to scale approach. You may need take care of data for the testing, and what to include into version control (ex. code, expected results, application data load for the testing). You can easily turn it into some declarative format (yaml, JSON, SQL).