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.1.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.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rapidtest-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 0c2647d33083ede16806bc5366fbd70df7cf398476eac1e0968f8523c58bfb8d
MD5 5862508b31c33d6ab888bb1259398da4
BLAKE2b-256 eecd04e3761c122ceb9f1c1c0d36ac67ff7387dc632c261782099d440fabf043

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rapidtest-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f003b29437885e93acb2be66609bd49b2b790f0917b3a0a1fd12778c4ebb151e
MD5 1031a53eedf899b1b0165de611fb3989
BLAKE2b-256 b0b98e5cf54a4f1fd3893e482acd7b5a5bb1e146a838bee50f3a7d9663aff403

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