Skip to main content

A simple testing framework for FastAPI

Project description

FastTest 🚀

A lightweight and simple library to simplify REST API testing. Designed to be intuitive, fast to implement, and with clear visual reports.

✨ Features

  • Simplicity: Perform HTTP requests (GET, POST, PUT, PATCH, DELETE) in a single line.
  • Automatic Validation: Automatically compare status codes and response bodies.
  • Visual Reports: Formatted console output with colors to identify failures quickly.
  • FastData: Integrated random data generator (using Faker) for dynamic testing.

🛠️ Installation

Make sure you have the necessary dependencies installed:

pip install requests faker

🚀 Quick Start

1. Initialize FastTest

from FastTest import FastTest

# Configure your API's base URL
tester = FastTest("http://localhost:8000")

2. Run Tests

GET

tester.get("/users", expected_status=200)

POST with Body Validation

user_data = {"username": "hector", "password": "123"}
tester.post("/user", data=user_data, expected_status=201, expected_body=user_data)

PUT / PATCH / DELETE

# Update data
tester.put("/user/hector", data={"password": "new_password"}, expected_status=200)

# Delete resource
tester.delete("/user/hector", expected_status=200)

3. Generate Random Data (FastData)

Use FastData to create test data on the fly:

from FastData import FastData

user = FastData.generate_auth_user()
email = FastData.generate_email()

print(user) # {'username': '...', 'password': '...'}

📊 Reports

Each test generates a visual report in the console like this:

============================================================
 TEST PASSED 
============================================================
URL:    http://localhost:8000/user
Status: 201
Body:
{
    "username": "hector",
    "password": "123"
}
============================================================

📁 Project Structure

  • FastTest.py: Core library logic.
  • FastData.py: Random data generator.
  • utils.py: Formatting and reporting utilities.

Built to simplify a developer's life. Happy testing! 🛠️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rapidtest-0.2.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rapidtest-0.2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file rapidtest-0.2.0.tar.gz.

File metadata

  • Download URL: rapidtest-0.2.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rapidtest-0.2.0.tar.gz
Algorithm Hash digest
SHA256 291ef66dd90f07810954744fb16e7ebb2b541c8715c2aef9249c10125f9b7875
MD5 91d899f2e72cfd5e140ae553be959299
BLAKE2b-256 163a8885db0d8dbe91c050c7830add5ff4f32bb6acf5e1b3e4a2c745ef7a6470

See more details on using hashes here.

File details

Details for the file rapidtest-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rapidtest-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for rapidtest-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 122f05d649ab8f32467d5cf21eabf85e26f10394b83fd241fe61a46123ddce6d
MD5 665521d592c207d6807c8fac2e6ea91c
BLAKE2b-256 34dc8f71718a3ae8429b578e02a27d969ca6bbb6157fee94819d1ed32abfcb73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page