Generate Python test cases from Pact files, for easier provider verification.
Project description
Pact Test Generator
Generate Python test cases from Pact files, for easier provider verification.
Free software: MIT license
Documentation: https://pact-testgen.readthedocs.io.
Features
Test Pact contracts against your Python providers via unit tests. Get test isolation for free.
pact-testgen creates test cases from your Pact files, with placeholders for defining provider states.
Getting Started
Install with pip
python -m pip install pact-testgen
Generate test files
Generate a provider_states.py and test_pact.py files in your tests directory:
pact-testgen /path/to/pactfile.json /tests/dir
For more details, see the Usage section of the documentation.
Fill in the generated provider states file
In your tests directory (passed as the second argument to pact-testgen), you’ll see a file named provider_states.py. It will contain set up functions matching the provider states defined in your pact file.
Before continuing, complete these functions so that they create the required states.
Run your tests
Run your test suite as normal, being sure to check the the test runner has picked up your new test_pact.py file.
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Logo Admiranda Urbis Venetæ from the British Library’s King’s Topographical Collection.
Verification of test responses in generated test code is powered by pactman.
History
0.5.0 (2022-02-04)
Adds Pact Broker support.
0.4.3 (2021-09-20)
Fix file handling for merge provider state file option.
0.4.2 (2021-09-18)
Improve handling of request data.
0.4.1 (2021-09-17)
Fix test method name missing test_.
0.4.0 (2021-09-16)
Adds option to merge changes to provider state file (Python 3.9 only).
Include structured provider state parameters from Pact v3 in provider state function names.
Support null provider state, i.e. pact.given(None).
0.3.0 (2021-09-03)
Provider state setup functions now raise NotImplementedError by default.
Format output files with target line length option.
Improve output to console, add quiet option.
0.2.1 (2021-09-01)
Fix test client not setting content type.
0.2.0 (2021-09-01)
Improve output for failed test cases.
0.1.2 (2021-08-25)
Fix bump2version config
0.1.1 (2021-08-24)
Fix templates missing from distributed package.
0.1.0 (2021-08-23)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pact_testgen-0.5.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d533c51ff61d69dbd1d3f30242be1f71ad04e5f184d4ac7f9d143dcc1758e19f |
|
MD5 | d0f29a5e2968a1c3a89d78235028c6a7 |
|
BLAKE2b-256 | 690ce9b1f05b29c30ab37819060acdf62ed387963cd81973d09f070da50218d9 |