Skip to content

ericsalesdeandrade/pytest-rest-api-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTest REST API Example

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.

Requirements

  • 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.

Repo Structure

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

How To Run the Unit Tests

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.

Releases

No releases published

Packages

No packages published

Languages