Skip to content

jeffrey2233/test_api

Repository files navigation

DummyJSON API Testing Project

This is an API testing project using pytest. The project tests the DummyJSON API and demonstrates automated API testing including login, data retrieval, and payload manipulation.

Features

  • Login with username and password
  • Retrieve user information (/auth/me)
  • Fetch lists of users, products, or other DummyJSON endpoints
  • Send custom POST/GET requests and handle payloads

Getting Started

1. Clone the Repository

git clone https://github.com/jeffrey2233/test_api.git
cd test_api

2. Create a Virtual Environment

python -m venv .venv

3. Activate the Virtual Environment

Windows:

.venv\Scripts\activate

Linux/macOS:

source .venv/bin/activate

4. Install Dependencies

pip install -r requirements.txt

5. Run Tests with Pytest

pytest

This will automatically discover and run all tests in the tests/ directory.

Allure Reports

Generate Allure reports to visualize test results:

pytest --alluredir=allure-results
allure serve allure-results

Project Structure

test_api/
├─ .venv/               # Python virtual environment
├─ src/                 # Source code (API client, helpers)
├─ tests/               # Pytest test cases
├─ requirements.txt     # Project dependencies
├─ settings.ini         # API credentials and base URL
└─ README.md            # Project documentation

Notes

  • API credentials (username, password, base URL) are stored in settings.ini or .env.
  • Use the APIClient class in src/api_client.py to handle login and API requests.
  • Tests are designed to be flexible and reusable with different DummyJSON accounts.

Tips

  • Run a single test function:
pytest tests/test_auth.py::test_login
  • For debugging in VSCode, configure launch.json with showReturnValue: true.

About

API testing project with pytest. Includes tests for creating, retrieving, and updating tasks on the Pixegami Todo API.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages