https://github.com/sergeyklay/consumer-pact-example
Consumer-side demo using contract driven development
https://github.com/sergeyklay/consumer-pact-example
api-testing consumer-driven-contracts contract-driven-development contract-testing contract-tests contracts pact pact-consumer pacts
Last synced: 11 days ago
JSON representation
Consumer-side demo using contract driven development
- Host: GitHub
- URL: https://github.com/sergeyklay/consumer-pact-example
- Owner: sergeyklay
- License: mit
- Created: 2023-02-24T22:50:07.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T22:04:44.000Z (6 months ago)
- Last Synced: 2025-03-29T22:41:20.656Z (about 1 month ago)
- Topics: api-testing, consumer-driven-contracts, contract-driven-development, contract-testing, contract-tests, contracts, pact, pact-consumer, pacts
- Language: Python
- Homepage:
- Size: 407 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
- Codeowners: CODEOWNERS
- Security: SECURITY.rst
- Authors: AUTHORS.rst
Awesome Lists containing this project
README
.. raw:: html
Consumer API Example
.. teaser-begin
This is a Python application for explanation of Contract Testing based on
`Pact `_.Here you can find out how to use Pact using the Python language. You can find
more of an overview on Pact in the `Pact Introduction `_.This project uses:
* `Pact `_, a code-first tool for testing HTTP and message
integrations using contract tests
* `pact-python `_, to create
and verify consumer driven contracts.. teaser-end
.. image:: https://raw.githubusercontent.com/sergeyklay/consumer-pact-example/main/cdc-example.png
:alt: Interaction diagramConsumer (this project)
=======================Consumer API Example is a simple HTTP client that makes requests to Provider,
gets response from API server and creates data model using the data from
responses. For demonstration purposes, the project has simplified
logic and should not be considered as a full-fledged Production-ready solution.Provider
========For the purity of the experiment, the provider is implemented as a separate
project and can be found at
`the following repo `_.Pact
====Sample contracts (pacts) are located in
`tests/pacts `_.Getting Started
===============Prerequisites
-------------What kind of things you need to install on your workstation to start:
* Python >= 3.11
* Docker / Rancher
* Docker Compose / Rancher ComposeInstalling
----------First, install Python dependencies for consumer:
.. code-block:: console
$ make init
$ make installRun tests
---------To run unit tests use the command as follows:
.. code-block:: console
$ make test
Run the dockerized broker using the ``docker-compose.yml`` file in the root of
the project:.. code-block:: console
$ docker compose -d
To publish contracts (pacts) to the broker use the following command:
.. code-block:: console
$ ./publish-contracts.sh
Run lint check
--------------To run code style checking use the command as follows:
.. code-block:: console
$ make lint
.. -project-information-
Project Information
===================Consumer API Example is released under the `MIT License `_,
and its code lives at `GitHub `_.
It’s rigorously tested on Python 3.11+.If you'd like to contribute to Consumer API Example you're most welcome!
.. -support-
Support
=======Should you have any question, any remark, or if you find a bug, or if there is
something you can't do with the Consumer API Example, please
`open an issue `_.