Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Contractual provides a method for verifying the function of mocks across modules and projects

Project description

Contractual

Code style: black pipeline status coverage report

Installation

pip install contractual

Use

how to use-

Contract Files

Contract files comply with the Pact file format seen at https://github.com/pact-foundation/pact-specification/tree/version-2 There is a key difference though-

Contractual supports mocking out arbitrary interfaces, while Pact limits itself to http requests. As such, a Contractual file can only be used with a Pact verifier if you limit the unchecked mocks to HttpContractMock. In the files themselves, you will see a list of interactions having the form

{
    "description": "get all users for max",
    "request": {},
    "response": {},
    "providerState": "a user with an id named 'u:ser' exists"
}

That is a valid HTTP contract. A more general ContractMock contract would have the form

{
    "description": "get all users for max",
    "contractMock": {
        "contractName": "Name",
        "args": []
    },
    "response": {},
    "providerState": "a user with an id named 'user' exists"
}

Development

Development Environment

Poetry is used to manage the project and dependencies. Once you have poetry installed pip install --user poetry, you can run poetry install to setup a virtaulenv for your project. Dependencies can be updated using poetry add or poetry remove and committing the updated pyproject.toml and poetry.lock files.

Release

CI is handled on Gitlab at https://gitlab.com/pjbecotte/contractual. There is a make target to create a new release by tagging a new version and then incrementing to the next beta version. (This requires permissions to push to master)

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 contractual, version 0.4.6
Filename, size File type Python version Upload date Hashes
Filename, size contractual-0.4.6-py3-none-any.whl (3.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size contractual-0.4.6.tar.gz (6.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page