robotframework-fasthttpmock
HTTP mock server library for Robot Framework powered by FastAPI. This library enables easy mocking of HTTP endpoints in your Robot Framework tests with minimal setup and configuration.
Features
- 🚀 Lightweight and fast mock server using FastAPI
- 🤖 Simple Robot Framework keywords
- 🔄 Dynamic mock interaction management
- ✅ Request verification capabilities
- 🧹 Automatic server cleanup
- 🌐 Support for all HTTP methods (GET, POST, PUT, DELETE, PATCH)
Installation
pip install robotframework-fasthttpmock
The editable mode (-e) allows you to modify the source code and see the changes immediately without reinstalling.
Available Keywords
| Keyword | Description |
|---|---|
Start Mock Server |
Start the mock HTTP server with optional host and port |
Stop Mock Server |
Gracefully stop the mock server |
Add Mock Interaction |
Add a new mock interaction with request/response definitions |
Remove Mock Interaction |
Remove an existing mock interaction |
Verify Interaction Called |
Verify the number of times an interaction was called |
Quick Start
Here's a simple example of how to use the library in your Robot Framework tests:
*** Settings ***
Library FastHTTPMock
Library RequestsLibrary
*** Test Cases ***
Mock Simple API Response
Start Mock Server port=8000
# Define mock interaction
${request}= Create Dictionary method=GET path=/api/users
${response}= Create Dictionary status=200 body={"users": ["user1", "user2"]}
${id}= Add Mock Interaction ${request} ${response}
# Make request to mock server
${resp}= GET http://localhost:8000/api/users
Should Be Equal As Strings ${resp.status_code} 200
# Verify the interaction
Verify Interaction Called ${id} 1
[Teardown] Stop Mock Server
Advanced Usage
Multiple Endpoints Example
*** Test Cases ***
Mock Multiple API Endpoints
Start Mock Server port=8000
# Mock GET endpoint
${get_request}= Create Dictionary method=GET path=/api/users/1
${get_response}= Create Dictionary status=200 body={"id": 1, "name": "John Doe"}
${get_id}= Add Mock Interaction ${get_request} ${get_response}
# Mock POST endpoint
${post_request}= Create Dictionary method=POST path=/api/users
${post_response}= Create Dictionary status=201 body={"message": "User created"}
${post_id}= Add Mock Interaction ${post_request} ${post_response}
# Test both endpoints
${get_resp}= GET http://localhost:8000/api/users/1
Should Be Equal As Strings ${get_resp.status_code} 200
${post_resp}= POST http://localhost:8000/api/users
Should Be Equal As Strings ${post_resp.status_code} 201
[Teardown] Stop Mock Server
Contributing
Refer to Contributing Docs for more details
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests and ensure they pass
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue if your problem isn't already listed
Acknowledgments
- Inspired by PactumJS
- Built with FastAPI
- Made for Robot Framework
Metadata
Release files for robotframework-fasthttpmock 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| robotframework_fasthttpmock-0.2.0.tar.gz | 9.3 kB | Without provenance | Details for robotframework_fasthttpmock-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| robotframework_fasthttpmock-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for robotframework_fasthttpmock-0.2.0-py3-none-any.whl |
Total release size: 20.8 kB
Release files / robotframework_fasthttpmock-0.2.0.tar.gz
| Download URL | robotframework_fasthttpmock-0.2.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec064032c7bd14b8ab88a61857c3d5a1b218ea0b50f735384ad6e15a240c7a6a
|
|
BLAKE2b-256 checksum How to use checksums |
7f76d62b07efb9efe0d9b34be61c1cc9427f79b5a8d86ce53fdcc55e2514d4fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.1
|
Release files / robotframework_fasthttpmock-0.2.0-py3-none-any.whl
| Download URL | robotframework_fasthttpmock-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3670c9e91b93b257131102004cd543d7ad1c480c30c71854cf3bbb92f32e5e0
|
|
BLAKE2b-256 checksum How to use checksums |
c13d95a71895f70c5117d3f3c8602954b80352d5bd2338fbbc757bf5c2bb95c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.1
|
Security for robotframework-fasthttpmock 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.