Skip to main content

Serve WireMock stubs as a mock with respx.

Project description

Build Status PyPI

wiremock-mock

Serve WireMock stubs as a mock with respx.

Requires Python 3.12+.

Installation

uv pip install wiremock-mock

Or with pip:

pip install wiremock-mock

Usage

"""Example usage of wiremock-mock."""

from http import HTTPStatus
from typing import Any

import httpx
import respx

from wiremock_mock import add_wiremock_to_respx

stubs: dict[str, Any] = {
    "mappings": [
        {
            "request": {"method": "GET", "urlPath": "/v1/pages"},
            "response": {
                "status": 200,
                "jsonBody": {"object": "list", "results": []},
            },
        },
    ],
}
with respx.mock(
    base_url="http://notion-mock.test", assert_all_called=False
) as m:
    add_wiremock_to_respx(
        mock_obj=m, stubs=stubs, base_url="http://notion-mock.test"
    )
    response = httpx.get(url="http://notion-mock.test/v1/pages")
    assert response.status_code == HTTPStatus.OK  # noqa: S101

This lets you use existing WireMock stub files (e.g. from the WireMock Admin API import format) without running WireMock in Docker. All HTTP traffic is mocked at the httpx level via respx. To load stubs from a JSON file, use json.loads(path.read_text()).

Use cases

  • Use existing WireMock stub files without running WireMock in Docker

  • Test against external APIs (e.g. Notion) without network access

  • Reuse stubs exported from WireMock Admin API or recorded mappings

  • Run tests in CI without Docker/socket dependencies

Supported stub features

  • Request matching: method, urlPath (exact), urlPathPattern (regex)

  • Query parameters: queryParameters with equalTo

  • Request body: bodyPatterns with equalToJson (honouring ignoreArrayOrder and ignoreExtraElements), contains and equalTo. This lets two requests to the same method and URL return different responses based on their bodies.

  • Response: status, headers, jsonBody, body

Full documentation

See the full documentation for more information including how to contribute.

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

wiremock_mock-2026.6.22.tar.gz (125.0 kB view details)

Uploaded Source

Built Distribution

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

wiremock_mock-2026.6.22-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file wiremock_mock-2026.6.22.tar.gz.

File metadata

  • Download URL: wiremock_mock-2026.6.22.tar.gz
  • Upload date:
  • Size: 125.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wiremock_mock-2026.6.22.tar.gz
Algorithm Hash digest
SHA256 620c98a261ab0e2dbaa24224ee475c42c2273cf9d3c936be6d1200d5d629951e
MD5 02999d198bd83f6a29f3f176dd9e3b22
BLAKE2b-256 36af7436e9c08ce9fda93950464e4e8b19d6dd4310029fc04d6ae5e18b4a4bc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for wiremock_mock-2026.6.22.tar.gz:

Publisher: release.yml on adamtheturtle/wiremock-mock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wiremock_mock-2026.6.22-py3-none-any.whl.

File metadata

File hashes

Hashes for wiremock_mock-2026.6.22-py3-none-any.whl
Algorithm Hash digest
SHA256 123db5fffe14aa60604da5514f7065ab1bf1bad3899d32d966a279313f466cef
MD5 e6ac4db8521da90a9847b4b3c64893bb
BLAKE2b-256 b7ff07bf4e69e12020404cb681a14fc8d698a22f8937d7d22d55cafd7787be84

See more details on using hashes here.

Provenance

The following attestation bundles were made for wiremock_mock-2026.6.22-py3-none-any.whl:

Publisher: release.yml on adamtheturtle/wiremock-mock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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