This repo contains the sample code for the article - Python REST API Unit Testing for External APIs
This project explains how to call an External Rest API (DogAPI) and validate call GET
and POST
API methods using PytTest including the use of fixtures and mocking.
- Python (3.10.6)
Please install the dependencies via the requirements.txt
file using
pip install -r requirements.txt
If you don't have Pip installed please follow instructions online on how to do it.
The repo structure is very simple with just one source code folder dog_api
containing the source code in file core.py
.
The Unit Tests are located under /tests
including the file conftest.py
. The Unit tests are split across 2 files - test_dog_api_core_basic.py
and test_dog_api_core_mock.py
To run the Unit Tests, from the root of the repo run
pytest ./tests/unit/
If you have any questions about the project please raise an Issue on GitHub.