https://github.com/sergeyklay/provider-pact-example
Provider-side demo using consumer-driven contract testing
https://github.com/sergeyklay/provider-pact-example
api api-project api-server api-service-for-crud api-specification api-testing consumer-driven-contracts contract-driven-development contract-testing contract-tests contracts flask-api flask-application flask-example openapi openapi3 pact pact-provider
Last synced: 11 days ago
JSON representation
Provider-side demo using consumer-driven contract testing
- Host: GitHub
- URL: https://github.com/sergeyklay/provider-pact-example
- Owner: sergeyklay
- License: mit
- Created: 2023-01-23T08:22:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-20T06:16:43.000Z (14 days ago)
- Last Synced: 2025-04-20T07:23:13.952Z (14 days ago)
- Topics: api, api-project, api-server, api-service-for-crud, api-specification, api-testing, consumer-driven-contracts, contract-driven-development, contract-testing, contract-tests, contracts, flask-api, flask-application, flask-example, openapi, openapi3, pact, pact-provider
- Language: Python
- Homepage:
- Size: 1.39 MB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 11
-
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
Provider 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
* `OpenAPI `_, to describe the Products API
* `Flask `_, a micro web framework for
building API.. teaser-end
.. image:: https://raw.githubusercontent.com/sergeyklay/provider-pact-example/main/cdc-example.png
:alt: Interaction diagramProvider
========Provider API Example is a sample Flask application that expose endpoints with
REST standard. As an example, this project uses the simple Products API. Here
is the
`OpenAPI spec `_
describes the interaction of clients with the provider.Consumer
========For the purity of the experiment, the consumer is implemented as a separate
project and can be found at
`the following repo `_.Pact
====Sample contracts (pacts) are located here:
https://github.com/sergeyklay/consumer-pact-example/tree/main/tests/pactsGetting Started
===============Prerequisites
-------------What kind of things you need to install on your workstation to start:
* Python >= 3.11
* SQLite3
* Node.js >= 16Installing
----------First, install Python dependencies for provider (Products API):
.. code-block:: console
$ make init
$ make installCreate provider configuration:
.. code-block:: console
$ cp .env.example .env
Run database migrations for provider:
.. code-block:: console
$ make migrate
Add provider seed data to the database:
.. code-block:: console
$ make seed
Next, install Node.js linters and tools:
.. code-block:: console
$ npm install
Run API server
--------------To run API server use the command as follows:
.. code-block:: console
$ make serve
Run tests
---------To run unit tests use the command as follows:
.. code-block:: console
$ make test
To verify contracts (pacts) use the command as follows:
.. code-block:: console
$ ./tests/run-pytest.sh
Note that before the contracts verification, you must have deployed the broker,
as well as the contracts must be published.Run lint check
--------------To run OpenAPI spec checking use the command as follows:
.. code-block:: console
$ npm run lint
.. -project-information-
Project Information
===================Provider 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 Provider 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 Provider API Example, please
`open an issue `_.