Python client for mockserver
Project description
py-mockserver
mockserver client for james bloom's mockserver https://github.com/jamesdbloom/mockserver
installation
pip install py-mockserver
Usage
For detail instruction how to use mockserver see this documentation
Creating Expectations
from pymockserver import Client, Request, Response
from pymockserver import RequestTimes
# without times
def create_expectation(self):
client = Client('localhost', 1080)
request = Request('/somepath', 'POST')
response = Response('')
client.expectation(request, response)
# with times
def create_expectation(self):
client = Client('localhost', 1080)
request = Request('/somepath', 'POST')
response = Response('')
times = Times()
client.expectation(request, response, times)
RequestTimes
is optional to specify if you don't want that fake endpoint to live forever
Getting recorded requests
from pymockserver import Client, Request
# get all recorded requests
client = Client('localhost', 1080)
def get_all_recorded():
requests = client.retrieve_requests()
# do something with array requests
def get_recorded_request_match():
request = Request('/hello', 'POST')
requests = client.retrieve_requests(request)
Examples
all other examples can be seen in integration_test.py
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
py-mockserver-0.1.4.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for py_mockserver-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d899c5c649f84220e60c0a6a14737e05f8f2d84042bf0e751a4892856638829 |
|
MD5 | 1e2032cf2308cc8e76aa6ff1e9c9a1e3 |
|
BLAKE2b-256 | 758da87b34d2a518a5c917366ce34e9d17bf8e2132b82f4d2159ea15b6ed98d2 |