Skip to main content

A mini mock server for http requests

Project description

Mini Mock Server

A mini mock server for http requests.

Features

  • Start a http mock server using the lib http.server.
  • Delay requests to simulate slow endpoints.
  • Return random responses on the same route to simulates success and error cases.

Installation

pip install mini-mock-server

Usage

  1. Create mock-api.json file to routes especifications.
{
    "/": [
        {
            "url": "/users",
            "method": "GET",
            "response": [
                {
                    "status_code": 200,
                    "body": [
                        {"id": 1, "name": "Mario"},
                        {"id": 2, "name": "Luigi"}
                    ]
                },
                {
                    "status_code": 400,
                    "body": {"error": "Bad request custom message"}
                }
            ]
        }
    ],
    "/api": [
        {
            "url": "/products/:id",
            "method": "GET",
            "response": {
                "status_code": 200,
                "body": {
                    "id": 1,
                    "name": "Product 001",
                    "price": 115.51
                }
            }
        }
    ]
}
  1. Start the mock server
mini-mock-server mock-api.json

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

mini_mock_server-0.0.24-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file mini_mock_server-0.0.24-py3-none-any.whl.

File metadata

File hashes

Hashes for mini_mock_server-0.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 2802fadd31822679cc101ef02662ff528d587f939964b7591b55380c547039bd
MD5 8a7a35cddf6ce80549560ef8f5d21e5c
BLAKE2b-256 3f3c9104273c415ac69d420cdcbdc292ed3d937fd8c0aac0a5546ae516cb4a67

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