Skip to content

This is a comprehensive API testing framework designed to systematically identify and report defects in web service interfaces using Python, Playwright, and advanced testing methodologies.

License

Notifications You must be signed in to change notification settings

ZhikharevAl/qa-hackathon-raptors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ruff Linter

API Defect Hunt πŸ•΅οΈβ€β™€οΈπŸ”

Project Overview

This is a comprehensive API testing framework designed to systematically identify and report defects in web service interfaces using Python, Playwright, and advanced testing methodologies.

Tech Stack πŸ› οΈ

  • Language: Python 3.10+
  • Virtual Environment: uv
  • Testing Framework:
    • Pytest
    • Playwright
  • Validation:
    • Pydantic
  • Linting: Ruff
  • Pre-commit Hooks: pre-commit
  • Reporting: Allure
  • Parallel Execution: pytest-xdist

Prerequisites πŸ“‹

  • Python 3.10+
  • uv
  • pip

Setup & Installation πŸš€

1. Clone the Repository

git clone https://github.com/ZhikharevAl/qa-hackathon-raptors.git
cd qa-hackathon-raptors

2. Create Virtual Environment with uv

uv venv  # Creates a new virtual environment
source .venv/bin/activate  # On Windows use `.venv\Scripts\activate`

3. Install Dependencies

uv pip install -r requirements.txt
uv pip install pre-commit
pre-commit install

4. Configure Environment Variables

Create a .env file with necessary credentials:

API_TOKEN=your_api_token_here

Development Tools πŸ› οΈ

Linting with Ruff

ruff check .  # Check for linting issues
ruff format .  # Format code

Pre-commit Hooks

Automatically run before each commit:

  • Linting
  • Formatting
  • Type checking
  • Other configured checks

Pydantic Validation πŸ”

Key Features

  • Strict type validation
  • Data parsing
  • Schema generation
  • Runtime type checking

Example Model

from pydantic import BaseModel, Field

class UserResponse(BaseModel):
    uuid: str = Field(..., description="UUID of the user")
    email: str = Field(..., description="Email address of the user")
    name: str = Field(..., description="Name of the user")
    nickname: str = Field(..., description="Nickname of the user")

Running Tests πŸ§ͺ

All Tests

pytest

Parallel Execution

pytest -n auto  # Automatically detect available CPU cores

Specific Test Suite

pytest tests/test_users.py

Generating Allure Reports πŸ“Š

1. Run Tests with Allure Tracking

pytest --alluredir=allure-results

2. Generate HTML Report

allure serve allure-results

Project Structure

project-root/
β”‚
β”œβ”€β”€ tests/               # Test suites
β”‚   β”œβ”€β”€ test_users.py
β”‚   └── ...
β”‚
β”œβ”€β”€ services/            # API service classes
β”‚   β”œβ”€β”€ users/
β”‚   β”‚   └── models/     # Pydantic models
β”‚   └── ...
β”‚
β”œβ”€β”€ config/              # Configuration files
β”œβ”€β”€ utils/               # Utility modules
β”œβ”€β”€ requirements.txt     # Dependency list
└── .pre-commit-config.yaml  # Pre-commit configuration

Coverage Report πŸ“Š

 pytest --cov=tests/
Name Stmts Miss Cover
tests_init_.py 0 0 100%
tests\test_games.py 45 6 87%
tests\test_users.py 80 26 68%
tests\test_wishlist.py 28 3 89%
------------------------- ------- ------ -------
TOTAL 153 35 77%

Best Practices πŸ“˜

  • Use uv for dependency management
  • Utilize Ruff for consistent code quality
  • Leverage pre-commit hooks
  • Use Pydantic for robust data validation
  • Create comprehensive Pydantic models
  • Use fixtures for test setup/teardown
  • Parameterize tests
  • Validate response schemas
  • coverage report

πŸ“ TODO

  • Refactor tests to use fixtures
  • 🎯 Target: 90%+ test coverage
  • Dynamic test data generation

License

MIT

About

This is a comprehensive API testing framework designed to systematically identify and report defects in web service interfaces using Python, Playwright, and advanced testing methodologies.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages