This project uses Python for development, Pact for contract testing, and runs the Pact Broker using a Docker container.
This repository aims to demonstrate the implementation of contract tests using Pact in a Python project. The generated contracts are published to a Pact Broker, facilitating integration between consumer and provider API development teams.
### Cloning the repository
git clone https://github.com/AlexAlexandreAlves/pact-test-py.git
### Run through the venv (virtual environment), for this, you need to create and activate it first
python3 -m venv {$name}
source {$name}/bin/activate
### Copy the all folders and files in the main project and past into your recent created env-folder, and then install the dependencies:
cd {your-venv-folder}
pip install -r requirements.txt
### Then you must download the pact cli compatible version throught the command below:
curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-cli/main/install.sh | sh
### Runnign the contract tests
pytest ./testsThe contract files (pacts) will be generated in the pacts directory.
docker-compose up -d-
The pact broker will be available in your browser at http://localhost:9292
-
After running the tests, you publish PACT files to the broker:
pact-broker publish ./pacts \
--broker-base-url http://localhost:9292 \
--consumer-app-version {{version-here}}