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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for mini_mock_server-0.0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 12acf811561bade0bf1de31d3c863c1b7c8633cd3fc1d78f6c3ac38534a24afb
MD5 69202e0d7776a91df48ed2807c4f78c5
BLAKE2b-256 7cf4118ce38fe454a346bb197118df11480d320e14fdac905a4a50401443e096

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