Skip to content

Commit

Permalink
feat: added support for message provider using pact broker
Browse files Browse the repository at this point in the history
  • Loading branch information
arturoriter committed Sep 3, 2021
2 parents 7c348a8 + a4803fa commit b0ec933
Show file tree
Hide file tree
Showing 23 changed files with 694 additions and 291 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pact-python specific ignores
e2e/pacts
userserviceclient-userservice.json
detectcontentlambda-contentprovider.json
pact/bin

# Byte-compiled / optimized / DLL files
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
### 1.4.2
* f2230b6 - chore: Bundle Ruby standalones into dist artifact. (#256) (Taj Pereira, Sun Aug 22 19:53:53 2021 +0930)
* e370786 - chore: Releasing version 1.4.1 (Elliott Murray, Tue Aug 17 18:55:53 2021 +0100)
* 7dc8864 - fix: make uvicorn versions over 0.14 (#255) (Elliott Murray, Tue Aug 17 18:51:52 2021 +0100)
* da49cd7 - chore: Releasing version 1.4.0 (Elliott Murray, Sat Aug 7 10:17:26 2021 +0100)
* 0089937 - fix: issue originating from snyk with requests and urllib (#252) (Elliott Murray, Sat Jul 31 12:46:15 2021 +0100)
* 903371b - feat: added support for message provider (#251) (Fabio Pulvirenti, Sat Jul 31 13:24:19 2021 +0200)
* 2c81029 - chore(snyk): update fastapi (#239) (Elliott Murray, Fri Jun 11 09:12:38 2021 +0100)
### 1.4.1
* 7dc8864 - fix: make uvicorn versions over 0.14 (#255) (Elliott Murray, Tue Aug 17 18:51:52 2021 +0100)
### 1.4.0
* 0089937 - fix: issue originating from snyk with requests and urllib (#252) (Elliott Murray, Sat Jul 31 12:46:15 2021 +0100)
* 903371b - feat: added support for message provider (#251) (Fabio Pulvirenti, Sat Jul 31 13:24:19 2021 +0200)
* 2c81029 - chore(snyk): update fastapi (#239) (Elliott Murray, Fri Jun 11 09:12:38 2021 +0100)
### 1.3.9
* 98d9a4b - chore(ruby): update ruby standalen (#233) (Elliott Murray, Thu May 13 20:21:10 2021 +0100)
* 657e770 - fix: change default from empty string to empty list (#235) (Vasile Tofan, Thu May 13 22:20:47 2021 +0300)
* 99fd965 - chore: Releasing version 1.3.8 (Elliott Murray, Sat May 1 12:26:47 2021 +0100)
* 3c909f1 - docs: example uses date matcher (#231) (Elliott Murray, Sat May 1 11:51:28 2021 +0100)
* 6390144 - fix: fix datetime serialization issues in Format (#230) (Syed Muhammad Dawoud Sheraz Ali, Thu Apr 29 01:49:53 2021 +0500)
### 1.3.8
* 3c909f1 - docs: example uses date matcher (#231) (Elliott Murray, Sat May 1 11:51:28 2021 +0100)
* 6390144 - fix: fix datetime serialization issues in Format (#230) (Syed Muhammad Dawoud Sheraz Ali, Thu Apr 29 01:49:53 2021 +0500)
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include LICENSE
include *.txt
include *.md
include pact/bin/*
prune pact/test
prune pact/bin
prune e2e
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ To setup a development environment:
1. If you want to run tests for all Python versions, install 2.7, 3.3, 3.4, 3.5, and 3.6 from source or using a tool like [pyenv]
2. Its recommended to create a Python [virtualenv] for the project

The setup the environment, run tests, and package the application, run:
To setup the environment, run tests, and package the application, run:
`make release`

If you are just interested in packaging pact-python so you can install it using pip:
Expand All @@ -449,6 +449,15 @@ From there you can use pip to install it:

`pip install ./dist/pact-python-N.N.N.tar.gz`

## Offline Installation of Standalone Packages

Although all Ruby standalone applications are predownloaded into the wheel artifact, it may be useful, for development, purposes to install custom Ruby binaries. In which case, use the `bin-path` flag.
```
pip install pact-python --bin-path=/absolute/path/to/folder/containing/pact/binaries/for/your/os
```

Pact binaries can be found at [Pact Ruby Releases](https://github.com/pact-foundation/pact-ruby-standalone/releases).

## Testing

This project has unit and end to end tests, which can both be run from make:
Expand Down
15 changes: 0 additions & 15 deletions examples/fastapi_e2e/Pipfile

This file was deleted.

210 changes: 0 additions & 210 deletions examples/fastapi_e2e/Pipfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion examples/fastapi_e2e/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fastapi==0.61.2
fastapi==0.65.2
pytest==5.4.1
requests==2.23.0
uvicorn==0.12.3
6 changes: 2 additions & 4 deletions examples/message/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MessageHandler(object):
```

Below is a snippet from a test where the message handler has no error.
Since the expected event contains a key `documentType` with value `microsoft-word`, message handler does not throw an error and a pact file `f"pacts/{expected_json}"` is expected to be generated.
Since the expected event contains a key `documentType` with value `microsoft-word`, message handler does not throw an error and a pact file `f"{PACT_FILE}""` is expected to be generated.

```python
def test_generate_new_pact_file(pact):
Expand Down Expand Up @@ -69,7 +69,7 @@ def test_generate_new_pact_file(pact):
assert isfile(f"{PACT_FILE}") == 1
```

For a similar test where the event does not contain a key `documentType` with value `microsoft-word`, a `CustomError` is generated and there there is no generated json file `f"pacts/{expected_json}"`.
For a similar test where the event does not contain a key `documentType` with value `microsoft-word`, a `CustomError` is generated and there there is no generated json file `f"{PACT_FILE}"`.

```python
def test_throw_exception_handler(pact):
Expand Down Expand Up @@ -97,8 +97,6 @@ def test_throw_exception_handler(pact):
assert isfile(f"{PACT_FILE}") == 0
```

Otherwise, no pact file is generated.

## Provider

Note: The current example only tests the consumer side.
Expand Down
Loading

0 comments on commit b0ec933

Please sign in to comment.