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.1.tar.gz (6.2 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.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rapidtest-0.2.1.tar.gz
  • Upload date:
  • Size: 6.2 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.1.tar.gz
Algorithm Hash digest
SHA256 1733451096c5293c358a47d2487fa38c0fd68dc99bcc270a4402acc888b1562e
MD5 6739764b190067e8852f5ef90efe3fea
BLAKE2b-256 b48086b9b2860b6ddbd18c91cd2c42bf3c2aa6603d5b421b6cba63aa55d1ed2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rapidtest-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d88e28bff430e165644dc9ead7b31cca43bb5de0fb7921f6fb213fd5d5b3d98b
MD5 6408cc3118bf8dde62e5bab81adfb6ac
BLAKE2b-256 dd9599273caeda40fb79723f97cfc8e31594f07a9c153956e588ee7d52338dde

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