A comprehensive API test automation framework for the AirportGap using Pytest and the Requests library with Python.
- Overview
- Features
- Project Structure
- Prerequisites
- Installation
- Running Tests
- Test Coverage
- API Endpoints Tested
- Author
This project demonstrates API testing practices using the AirportGap public API. The framework follows the Page Object Model pattern adapted for API testing, ensuring maintainable and scalable test code. It includes comprehensive test coverage for positive scenarios, negative scenarios, and end-to-end workflows.
Pytest-API/ ├── tests/ │ ├── pages/ │ │ ├── airport_page.py # Airport API endpoints wrapper │ │ └── auth.py # Authentication client │ ├── test_api/ │ │ ├── test_airportgap_positive.py # Positive test scenarios │ │ ├── test_airportgap_negative.py # Negative test scenarios │ │ └── test_airportgap_e2e.py # End-to-end workflows │ ├── __init__.py │ └── conftest.py # Pytest fixtures and configuration ├── .gitignore └── README.md
bash
git clone https://github.com/saisyah101/Pytest-API.git cd Pytest-API
bash
# Windows python -m venv venv venv\Scripts\activate
# macOS/Linux python3 -m venv venv source venv/bin/activate
bash
pip install pytest pip install requests pip install pytest-html
bash
pytest
bash
# Positive tests only pytest tests/test_api/test_airportgap_positive.py
# # Negative tests only pytest tests/test_api/test_airportgap_negative.py
# End-to-end tests only pytest tests/test_api/test_airportgap_e2e.py
bash
pytest -v
bash
pip install pytest-xdist pytest -n auto
bash
pytest --html=report.html --self-contained-html
bash
pytest -k "test_get_airports_success"
https://airportgap.com/api
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /airports | Get all airports with pagination | NO |
| GET | /airports/{id} | Get specific airport by ID | NO |
| POST | /airports/distance | Calculate distance between airports | NO |
| GET | /favorites | Get user's favorite airports | YES |
| GET | /favorites/{id} | Get specific favorite by ID | YES |
| POST | /favorites | Add airport to favorites | YES |
| PATCH | /favorites/{id} | Update favorite note | YES |
| DELETE | /favorites/{id} | Remove favorite airport | YES |
| POST | /tokens | Authenticate and get token | NO |
Siti Aisyah
LinkedIn