-
-
Save nickshoust-wf/5850df10ec556632e8eee467f6819199 to your computer and use it in GitHub Desktop.
mock-pact-service issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given that you have pactpy installed in your environment | |
# And that madkom/pact-mock-service is stood up at localhost:1234 | |
# And that a request with a trailing slash is requested | |
# The contract that is written does not contain the slash in the path | |
# This results in the wrong URL being requested with the generated | |
# contract is verified against the server | |
import requests | |
from unittest import TestCase | |
from pact import Consumer, Provider | |
SERVER_HOSTNAME = "localhost" | |
class BaseContract(TestCase): | |
def setUp(self): | |
pass | |
class SomeContract(BaseContract): | |
def setUp(self): | |
super(SomeContract, self).setUp() | |
self.pact = Consumer('Consumer').has_pact_with( | |
Provider('Provider'), host_name=SERVER_HOSTNAME, port=1234) | |
def test_case(self): | |
expected = "stuff" | |
(self.pact | |
.given('a request for stuff') | |
.upon_receiving('a request for stuff with a trailing slash') | |
.with_request('get', '/stuff/', query='sorted') | |
.will_respond_with(200, body=expected)) | |
with self.pact: | |
result = requests.get('http://' + SERVER_HOSTNAME + ':1234' + '/stuff/?sorted') | |
print result | |
self.assertEqual(result.content, expected) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The contract looks like