-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pact verification issue #38
Comments
@pawelszk I think what's happening is when the contract runs its hitting your locally running animal service instead of the mock service. At the top when you create the mock service: pact = Consumer('Consumer').has_pact_with(
Provider('Provider'), host_name='localhost', port=1234)
# Don't forget to start the service and register the method to stop it when Python exits
pact.start_service()
import atexit
atexit.register(pact.stop_service) It will start on port 1234. Later on in your test you create the URL: url = 'http://localhost:8081/animals/1' Which is used for the request before you enter the pact context and inside it. You would need to adjust the URL in the second request to point it to the running mock service instead: url = 'http://localhost:1234/animals/1'
with pact:
result = requests.get(url) That should connect to the mock service instead of the animal service and it will then register the missing request. |
Thanks 👍 The main issue was in my understanding of how contract tests are working. That is why in the second request I was hitting the animal service instead of pact mock service. Regarding starting and stopping mock service: |
Yup, I'm trying to fix this. Really hoping a windows expert can give me a hand with working out how to shut down a process gracefully (sigterm) rather than using sigint. |
@matthewbalvanz-wf @bethesque
I was trying to run the same code on ubuntu and I was not observing this issue. |
I'm pretty close to getting some very ugly code working on windows. |
This will be closed by #41 |
Hi,
I am new to contract testing and I am trying to find out how it works.
I have copied animal example and started animal service:
I have started also pact mock service locally
My code looks like that:
When I am running my test I am getting Missing Request warning and tests fails
Here is mock service console output:
Is this a verification issue or is my code wrong? (if my code is wrong then how can I fix it?)
The text was updated successfully, but these errors were encountered: