httplaceholder

httplaceholder


Keywords
Swagger, httplaceholder
Install
pip install httplaceholder==0.5.0

Documentation

HttPlaceholder Python client

Build AppVeyor build status
License MIT License

This is a Python library for communicating with the HttPlaceholder REST API.

HttPlaceholder?

Quickly mock away any webservice using HttPlaceholder. HttPlaceholder lets you specify what the request should look like and what response needs to be returned.

Installation

The HttPlaceholder client is distributed as pip package.

pip install httplaceholder

Examples

from httplaceholder import *
from httplaceholder.models import *

api = HttPlaceholderAPI(base_url="http://localhost:5000")

# Add basic auth if API is protected by username and password
headers = {'Authorization': 'Basic ZHVjbzp3aW50ZXJ3ZXJw'}

# Add a new stub
api.ph_api_stubs_post(stub_model=StubModel(
    id="stub123",
    conditions = StubConditionsModel(
        method="GET",
        url=StubUrlConditionModel(
            path="/sjaak"
        )
    ),
    response = StubResponseModel(
        text = "OK YO"
    )
), custom_headers = headers)

# Get the latest request made to HttPlaceholder
requests = api.ph_api_requests_get(custom_headers = headers)
print(requests[0])