Rest assured equivalent in Python for Rest API automation testing - Stack Overflow
Best automation framework for API testing other than RestAssured? Something Python specific maybe.
Build a REST API from the ground up with Python
REST API testing with python projects
Videos
In order to simulate the same functionality as in Java's rest-assured, you can use:
Option 1
requests module along with pytest
Option 2
Use an available module pyhttptest Here you just need to define your test-cases and request in a json file and run all your test cases using command line
And Last
My favorite and recommended one is pyresttest
pyresttest is tool for testing RESTful HTTP requests. It’s written in Python (hence the py prefix) but unless you intend to write extensions this does not require any Python programming. It will work just fine in a Ruby, Go, Node, or PHP project.
As a command line tool it works by specifying a root URL (host) address and then the path to a YAML configuration file. The configuration file enumerates a list of URLs to request and tests against the expected status code.
Cheers!!
If you are using Django or Django Rest Framework For developing your REST APIs then you can use the django.test.Client. It helps you simulate requests with data defined in your application. You can write a shell script which executes these files on a production server and then use the results to make sure code changes don't break any existing code.
from django.test import Client
c = Client()
# Call a POST request endpoint with data
response = c.post("/login/", {"username": "john", "password": "smith"})
status_code = response.status_code
if status_code==200:
print("wow test case passed")
You can find the complete documentation from the django's official docs from this link official_docs_test_client
What automation framework have you used to automate api testing? How have you designed your tests(proj structure)? What factors you’ve focused on your api testing(status check, schema check, response value check)? Please share your experience.