Pytest Easy Api
A pytest plugin for super simple API testing.
Installing
Install the package directly from pypi:
>>> pip install pytest-easy-api
Using the api fixture
The api fixture, acts as a pass through to a requests.Session object, meaning you can make your API calls from it like so:
def test_my_get_function(api):
response = api.get('/my-get-endpoint')
assert response.status_code == 200
Anything you can usually do through requests.Session you can do through this fixture, but you only need to pass the url extension, meaning you can run these same tests on any running instance of your application.
TODO
- Add option to read base url from config.
- Tests.
- Add documentation.
- Add decorator to read mock from json file.