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.1.2.tar.gz (3.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.1.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rapidtest-0.1.2.tar.gz
  • Upload date:
  • Size: 3.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.1.2.tar.gz
Algorithm Hash digest
SHA256 99382d46e809d52a1cbfa59c6d4a3357fca713b72ec5bf0dc42cf1568477f087
MD5 59e2f23612ac6bf107f9c08b1813fc60
BLAKE2b-256 763f0c867aad12cb4bf497ed9982fe24eae50714d6a1a4089beba0db13f65fca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rapidtest-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.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.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 380e8e26b7efb60767d6a0f2ce01ea276190dc10d9da032251ad3561760426cf
MD5 950d9b34cddec4ad17fdad2abff694c9
BLAKE2b-256 17f7aa5f4f2f3a0a914be01a95c85841947441d9000b619734ce045dc7cfdbb2

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