Skip to main content

Python HTTP client for wiremock

Project description

sky-wiremock

https://img.shields.io/pypi/v/sky_wiremock.svg https://img.shields.io/travis/grubert65/sky_wiremock.svg Documentation Status

Python HTTP client for wiremock

Features

Usage:

from sky_wiremock.sky_wiremock import Wiremock

# get a client object
w = Wiremock("localhost", 8080)


# add a mapping and get back its id
id = w.add_mapping({
    "request": {
        "method": "GET",
        "url": "/some/thing"
    },
    "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
})

# populate wiremock with a list of mappings and
# get their ids
ids = w.populate([{
    "request": {
        "method": "GET",
        "url": "/some/thing"
    },
    "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
},{
    "request": {
        "method": "GET",
        "url": "/some/thing/else"
    },
        "response": {
        "status": 200,
        "body": "Hello world again!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
}])

# delete a mapping by its id
ret = w.delete_mapping(id)

# get the list of all mappings defined
mappings = w.mappings()

# get a mapping by its id
mapping = w.mapping_by_id(id)

# get a mapping by its url and method
mapping = w.mapping_by_url_and_method("/some/thing", "GET")

# add a fixed delay to a mapping dictionary
delayed_id = w.fixed_delay(mapping, 10000)

# add a global fixed delay
ret = w.global_fixed_delay(300)

# add a random delay to a mapping dictionary
delayed_id = w.random_delay(mapping, {
    "type": "lognormal",
    "median": 80,
    "sigma": 0.4
})

# add a global random delay
ret = w.global_random_delay({
    "type": "lognormal",
    "median": 90,
    "sigma": 0.1
})


# add a chunked dribble delay to a mapping
delayed_id = w.chunked_dribble_delay(mapping, {
    "numberOfChunks": 5,
    "totalDuration": 1000
})

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2019-02-12)

  • First release on PyPI.

Project details


Download files

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

Files for sky-wiremock, version 0.1.8
Filename, size File type Python version Upload date Hashes
Filename, size sky_wiremock-0.1.8-py2.py3-none-any.whl (6.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size sky_wiremock-0.1.8.tar.gz (18.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page