Skip to main content

codecov Language grade: Python

mounty

A wrapper for Mountebank REST API, can be used for existing instances or for testing in CI/CD ephemeral Mountebank instances.

Who/what is Mountebank? Mountebank is an amazing open-source stub/service virtualisation tool, see more here. It can be used as a stub service for any external dependency, it can run as proxy (recording and replaying requests), it can be used for load testing services in isolation (stub external requests, so no latency added)

Installation

$ pip install mounty

Usage examples:

Start local Mountebank instance in container:

docker pull bbyars/mountebank:2.6.0
# start the container exposing port 2525 for imposters administration and ports 4555/4556 for imposters
docker run --rm -p 2525:2525 -p 8080:8080 -p 4555:4555 -p 4556:4556 bbyars/mountebank:2.6.0 mb start
import requests
from mounty import Mountebank
from mounty.models import Imposter, Stub, RecordedRequest

# the url must contain the port on which Mountebank is listening
mountebank = Mountebank(url="http://localhost:2525")
# or, if MOUNTEBANK_URL variable is defined:
mountebank_from_env = Mountebank.from_env()

# add imposter as dict
imposter = mountebank.add_imposter(imposter={
 "port": 4555,
 "protocol": "http",
 "stubs": [{"responses": [{"is": {"statusCode": 201}}]}],
})

# add another imposter as Imposter object
other_imposter = mountebank.add_imposter(
 imposter=Imposter(
    port=4556,
    protocol="http",
    recordRequests=True,
    stubs=[Stub(responses=[{"is": {"statusCode": 201}}])],
 )
)

# perform 2 requests
requests.post(url="http://localhost:4556")
requests.post(url="http://localhost:4556")
# wait for maximum 2 seconds for the imposter to contain 2 recorded requests
reqs = mountebank.wait_for_requests(port=4556, count=2, timeout=2)
# validate recorded request
assert type(reqs[0]) == RecordedRequest

Local development

You will first need to clone the repository using git and place yourself in its directory:

$ poetry install -vv
$ poetry run pytest tests/

To make sure that you don't accidentally commit code that does not follow the coding style:

$ poetry run pre-commit autoupdate
$ poetry run pre-commit install
$ poetry run pre-commit run --all-files

Release files for mounty 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mounty 1.0.2
File Size Uploaded
mounty-1.0.2.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mounty 1.0.2
File Interpreter ABI Platform
mounty-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / mounty-1.0.2.tar.gz

Download URL mounty-1.0.2.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1895e002b5db74814e96e519b540eed4630ac8eeeeb92800511c7ce999a0a409
BLAKE2b-256 checksum
How to use checksums
dccff90e43fb51cdfda384d5b3a69c9a3e7cb44a7e09041fa1225fdc86072775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / mounty-1.0.2-py3-none-any.whl

Download URL mounty-1.0.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ade3d9a0c7ee9325c0f5b6c450760f593811757c825abb788667a474f39dcf8a
BLAKE2b-256 checksum
How to use checksums
87214b0ed479a2f277e541c2f1dacacc5dffae57997f9ef696262f81dc521964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page