bethskurrie
2018-03-24 03:39
has joined #pact-python

bethskurrie
2018-04-05 04:09
/github subscribe pact-foundation/pact-python

matthew.balvanz
2018-04-05 04:12
has joined #pact-python

bethskurrie
2018-04-24 10:35
@matthew.balvanz could you have a look at this issue? https://stackoverflow.com/questions/49983126/pact-simple-example-ad-setup-issues

bethskurrie
2018-04-24 10:35
Not sure if you're following the pact tags on stackoverflow. Sorry if you've already seen it.

bethskurrie
2018-04-24 10:41
I actually had a poke around the code myself, and added an answer - I think it's just super out of date.

matthew.balvanz
2018-04-24 13:45
Sure, I've got a full schedule today, but I hope to take a look at it tomorrow.

bethskurrie
2018-05-02 05:00
/github unsubscribe pact-foundation/pact-python deployments public commits

slack1
2018-05-09 20:01
has joined #pact-python

gnewitt
2018-05-29 22:49
has joined #pact-python

gonzalogarcia243
2018-06-08 15:00
has joined #pact-python

ashish.dubey91
2018-06-13 06:12
has joined #pact-python

ashish.dubey91
2018-06-13 06:15
hey guys, pact-verifier returns exit code 0 even when the verification fails, is that by design? I'd want some way to detect failures. exit code would have been the most elegant

bethskurrie
2018-06-13 07:52
That doesn't sound right :thinking_face:

bethskurrie
2018-06-13 07:52
As in, it sounds like a bug.

bethskurrie
2018-06-13 07:53
Under the hood, its calling the ruby pact-provider-verifier. Have a look and see if to can see that code, and how it handles error codes.

ashish.dubey91
2018-06-13 08:50
oh wait, the python pact-verifier also uses ruby? that'd be interesting

ashish.dubey91
2018-06-13 08:50
sorry I didn't mention that I installed the python version

bethskurrie
2018-06-13 09:25
It's packaged as a standalone executable.

bethskurrie
2018-06-13 09:25
You don't have to have ruby installed

bethskurrie
2018-06-13 09:36
And yes, I assumed you were using the python on, given the channel topic.

ashish.dubey91
2018-06-13 09:38
thanks. maybe I'll dive into the code

ashish.dubey91
2018-06-13 09:39
could be my first contribution

matthew.balvanz
2018-06-13 19:11
A quick glance at the code makes me think I attempted to make that happen:


matthew.balvanz
2018-06-13 19:12
We may need to dig a bit more to find out why that `sys.exit(p.returncode)` isn't the same as the Ruby exit code.


ashish.dubey91
2018-06-14 13:57
but not in the latest release?

ashish.dubey91
2018-06-14 13:58
oh wait that's not master, `p.communicate` is what fixes it

ashish.dubey91
2018-06-14 13:59
otherwise, `p.returncode` is always `None` as the process spawned by Popen is still executing

ashish.dubey91
2018-06-14 13:59
you have to either `poll`, `wait` or `communicate` to wait for the actual exit code


matthew.balvanz
2018-06-14 16:39
Yep, that is clearly not right. We likely need to add back a poll or wait after we finish reading the logs to get things back in order.

ashish.dubey91
2018-06-14 17:20
I can create a PR :slightly_smiling_face:

richard.jones
2018-06-15 00:12
has joined #pact-python

matthew.balvanz
2018-07-21 03:44
@ashish.dubey91 I just released 0.17.0 which should now be exiting with a non-zero code when verification fails.

bethskurrie
2018-07-21 04:27
Like a shop bought one!

thirumal.net
2018-07-23 05:55
has joined #pact-python

thirumal.net
2018-07-26 16:17
~://pact-foundation.slack.com~

thirumal.net
2018-07-26 16:20
Hi, i am doing POC for pact-python implementation in our project and i am facing below questions. It seems we have to use localhost:1234 from consumer side at the time of mock generation ? Can we use real service in place of mocking service ? If I use localhost:1234 , pact was generated but if i use real service ,then error is coming up So my question is do we need to always use Mock service ((localhost:1234) when we creating pacts from consumer side 2nd issue : i am from QA Team and thinking that pacts should be written by DEV team not QA team . is my assumption correct ? if yes, how these pacts will help QA Team ? Thank you in Advance,

thirumal.net
2018-07-26 16:22
@bethskurrie - Can you please help me on my question , Thank you in advance

matthew.balvanz
2018-07-26 17:49
Pact uses the mock service to generate the contract JSON files, which are later verified against the real service. Being able to use the real service I think would just convert the test into an integration test? I see you get an error when using the real service, when you verify the generated pact against that service do you see the same error?

bethskurrie
2018-07-26 22:06
You must use the mock to create a pact. This is one of the fundamental principles of using Pact.

bethskurrie
2018-07-26 22:07
@thirumal.net yes, it is typically the developers who write both the consumer and provider pact tests.

bethskurrie
2018-07-26 22:08
They run as part of the same test suite as the unit and functional tests.

bethskurrie
2018-07-26 22:08
They should be able to run locally, without any reliance on a deployed environment.

bethskurrie
2018-07-26 22:09
You may find these useful https://docs.pact.io/faq

bethskurrie
2018-07-26 22:10
I would recommend reading the entire Getting Started section if you have not already.

thirumal.net
2018-07-27 18:28
@matthew.balvanz -Thank you for your reply. i am not getting any error if i use real service with pact verifier.

thirumal.net
2018-07-27 18:28
@bethskurrie - Thank you very much for your help on clarifying my questions.

thirumal.net
2018-07-27 18:29
@bethskurrie - i will go through entire document you have mentioned and let you know if i have any questions. Thank you again !

thirumal.net
2018-07-30 18:35
Hi, i am doing poc with real service and need your help. i am able to create mock and verify for small service but not real service . just i am taking real service and trying to mock the response through mock service so that i can demo it to dev team for implementation . here is my issue *how should i generate the mock for below situation where Provider service is responding with below Jason format *

thirumal.net
2018-07-30 18:43
@bethskurrie or @matthew.balvanz - can you please guide me how to generate mock for provider which gives Jason response . unable to mock the jason response consumer side . here is the code i have tried so far ' def test_callAPI (self): url = 'http://localhost:1234' expected = { 'class': 'HealthCheck', } pact.given ( 'sending a request to url' ).upon_receiving ( 'class name should match with HealthCheck' ).with_request ( 'get', '/' ).will_respond_with ( 200,body=expected) with pact: result = callAPI ( url ) self.assertEqual ( result,expected )'

thirumal.net
2018-07-30 18:46
* Jason fomat * ' { "class": [ "HealthCheck" ], "properties": { "timestamp": "2018-07-30T02:48:04+0000", "systemName": "minimal-rx , "buildInfo": { "buildDate": "2018-07-27T07:38:19+0000", "appVersion": " ", "revision": " ", "branch": "develop" }, "health": "OK", "checks": [ { "check": "DB connection via Instance of ", "status": "OK", "assertion": "available", "target": "I" }, { "check": "Connection to /userinfo", "status": "OK", "config_id": " .com", "secure_key": " .com", "assertion": "access", "config_type": "OAUTH", "target": userinfo" } ] }, "links": [ { "rel": [ "self" ], "href": "/ " } ] }'

thirumal.net
2018-07-30 18:47
* Jason fomat * ' { "class": [ "HealthCheck" ], "properties": { "timestamp": "2018-07-30T02:48:04+0000", "systemName": "minimal-rx", "buildInfo": { "buildDate": "2018-07-27T07:38:19+0000", "appVersion": "CS-MRA_develop.25", "revision": "291a6553f509edc68074d31cd7d5a077a98c5add", "branch": "develop" }, "health": "OK", "checks": [ { "check": "DB connection via Instance of class com.zaxxer.hikari.HikariDataSource", "status": "OK", "assertion": "available", "target": "Instance of class com.zaxxer.hikari.HikariDataSource" }, { "check": "Connection to /userinfo", "status": "OK", "config_id": " .com", "secure_key": " .com", "assertion": "access", "config_type": "OAUTH", "target": userinfo" } ] }, "links": [ { "rel": [ "self" ], "href": "/minimal-rx/v1/admin/healthcheck" } ] }'

bethskurrie
2018-07-30 22:15
Hi @thirumal.net can you tell us exactly what problem you're having?

bethskurrie
2018-07-30 22:16
On a side, note, I'll make some suggestions for your other fields

bethskurrie
2018-07-30 22:17
"Given" should describe the state of the data on the provider. For example, if you need any domain objects, it should describe those. eg. "a widget with id 1 exists"

bethskurrie
2018-07-30 22:17
"upon_receiving" should describe the request. eg "a request for a widget with id 1"

bethskurrie
2018-07-30 22:18
in your case, I would say ``` pact.given ( 'the health of the system is OK' ).upon_receiving ( 'a request for the health check' ) ```

bethskurrie
2018-07-30 22:19
@matthew.balvanz will have to tell you how to express the JSON, because I don't know how to do it in python.

bethskurrie
2018-07-30 22:20
Please tell him what documentation you have already looked at.

bethskurrie
2018-07-30 22:21
For example, the example on the pact-python README appears to have a JSON body https://github.com/pact-foundation/pact-python What is missing from that example that you need to know?

thirumal.net
2018-07-30 23:23
@bethskurrie -Thank you for your quick response and i have gone through the documentation you have mentioned and here is exact issue i am facing : service provider gives lot of jason data in the response but i want to test only some part of it . in order to do that i am trying to mock only portion of the provider response but unable to do it service provider will give below response { *"class": [ "HealthCheck" ],* "properties": { "timestamp": "2018-07-30T02:48:04+0000", "systemName": "minimal-rx , "buildInfo": { "buildDate": "2018-07-27T07:38:19+0000", "appVersion": " ", "revision": " ", "branch": "develop" }, "health": "OK", "checks": [ { "check": "DB connection via Instance of ", "status": "OK", "assertion": "available", "target": "I" }, { "check": "Connection to /userinfo", "status": "OK", "config_id": " .com", "secure_key": " .com", "assertion": "access", "config_type": "OAUTH", "target": userinfo" } ] }, "links": [ { "rel": [ "self" ], "href": "/ " } ] }' ''but i want to verify only class:HealthCheck . to do this one i am mocking as below before running mock service but service is failing error is happening at 'will_respond_with ( 200, body= EachLike({'class': ['HealthCheck'], }, minimum=1) )' 'Error : AssertionError: [{'class': ['HealthCheck']}] != <pact.matchers.EachLike object at 0x06D64E50>'

thirumal.net
2018-07-30 23:25
my test consumer code is : ' url = 'http://localhost:1234' pact.given ( 'the health of the system is OK' ).upon_receiving ( 'a request for the health check' ).with_request ( 'get', '/' ).will_respond_with ( 200, body= EachLike({'class': ['HealthCheck'], }, minimum=1) )'

thirumal.net
2018-07-31 02:36
@bethskurrie - even though i am getting Assertion Error from Consumer side, i am able to generate mock which looks like below ' "consumer": { "name": "consumer" }, "provider": { "name": "provider" }, "interactions": [ { "description": "a request for the health check", "providerState": "the health of the system is OK", "request": { "method": "get", "path": "/" }, "response": { "status": 200, "headers": { }, "body": { "class": "HealthCheck", "properties": { "timestamp": "2016-12-15T20:16:01", "systemName": "minimal-rx", "buildInfo": { "buildDate": "2016-12-15T20:16:01", "appVersion": " 11", "revision": "291a6553f509edc68074d31cd7d5a077a98c5add", "branch": "develop" }, "health": "OK", "checks": [ { "check": "DB connection via Instance of class com. ", "status": "OK", "assertion": "available", "target": "Instance of class com " }, { "check": "Connection to ", "status": "OK", "config_id": " com", "secure_key": " ", "assertion": "access", "config_type": "OAUTH", "target": " o" } ] }, "links": [ { "rel": [ "self" ], "href": "/minimal-rx/v1/admin/healthcheck" } ] }, "matchingRules": { "$.body.properties.timestamp": { "match": "regex", "regex": "\\d+-\\d+-\\d+T\\d+:\\d+:\\d+" }, "$.body.properties.buildInfo.buildDate": { "match": "regex", "regex": "\\d+-\\d+-\\d+T\\d+:\\d+:\\d+" } } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }'

thirumal.net
2018-07-31 02:38
but when i try to to run this jason against real provider service , i am getting below error . i am suspecting this is because of timestamp(in mock creation getting error on dates) .Error from pact verifier is *'Failure/Error: expect(response_body).to match_term expected_response_body, diff_options Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8 '*

thirumal.net
2018-07-31 02:41
can you please help me what might be the issue ? consumer side, i am doing mocking date like below , 'expected = {'class': 'HealthCheck', 'properties': {'timestamp': Term('\d+-\d+-\d+T\d+:\d+:\d+', '2016-12-15T20:16:01'),'

thirumal.net
2018-07-31 02:52
insteading of checking complete response can i check only certain data ? just to make sure class': 'HealthCheck' is coming from provider service ?

bethskurrie
2018-07-31 03:40
The data that is checked is the data that you mock.

bethskurrie
2018-07-31 03:40
You can't mock data, and not check it.

bethskurrie
2018-07-31 03:41
If you want to do that, use another tool.

bethskurrie
2018-07-31 03:41
I often use pact as well as "normal" mocking tools to test my code.

bethskurrie
2018-07-31 03:42
Your response contains a non utf-8 character in it.

bethskurrie
2018-07-31 03:43
According to a quick google, it is the character ‚

bethskurrie
2018-07-31 03:46
If you look at the log files, you should see the response body in there.

shashidesai
2018-07-31 18:35
has joined #pact-python

thirumal.net
2018-07-31 22:40
@bethskurrie -Thank you for your reply but unable to find out the reason why error is still coming up . can you please tell me how to mock only certain data instead of total response body ? out of total response i want to mock only one item from the response like *"class": [ "HealthCheck" ],* instead of total response

thirumal.net
2018-08-01 06:03
just trying to mock only one item like below 'url = 'http://localhost:1234' expected = {'class': 'HealthCheck'} and verifying with pact verifier but unfortunately i am getting error for this one too

matt.fellows
2018-08-01 06:49
has joined #pact-python

bethskurrie
2018-08-01 08:50
@thirumal.net I think you need a developer to pair with you on this.

bethskurrie
2018-08-01 08:57
Here is a list of things I recommend you do

bethskurrie
2018-08-01 09:02
? If possible, create a repository in Github that recreates the issue you are having so that we can actually look at the code ? Find a developer to pair with you ? Look at the pact logs that get created when the verification runs and see what the response body is. Please let me know if you cannot find this file. ? Look at the application logs of your provider to work out why you are getting a 403 ? The fact that you're getting a 403 suggests that you have not set up the authorization headers correctly or that you have not set up the required user data correctly. Make sure you fully understand how provider states work. You can read about them here: https://docs.pact.io/getting_started/provider_states https://github.com/pact-foundation/pact-provider-verifier#api-with-provider-states

matt.fellows
2018-08-01 10:39
I think your issue is not related to only mocking a part of the response. Looking at your code, it should be only mocking this part of the response. If you could provide us with something to run, we?ll be able to help you further

thirumal.net
2018-08-02 03:38
@matt.fellows - Thank you , i have uploaded my code and details in below Github link , can you please kindly help me ? https://github.com/pact-foundation/pact-python/issues/90

thirumal.net
2018-08-02 03:39
@bethskurrie - Thank you, i have uploaded a code in below path :https://github.com/pact-foundation/pact-python/issues/90

thirumal.net
2018-08-02 03:40
sure, i will follow the documentation you have mentioned

thirumal.net
2018-08-02 08:02
@bethskurrie - here is the repository created for the code base https://github.com/thiruHp/PACT-PYTHON-Issue

richard.jones
2018-08-03 04:58
Hi folks. I?ve spent a few hours today integrating my Python pact verification code into the pact-python library using it as the consumer mock server and provider verifier (rather than spawning the external shell process). I have it working, I?m just cleaning up now. I hope to have code up on github next week.

sgarvey
2018-08-06 11:23
has joined #pact-python

richard.jones
2018-08-06 22:54
So: next steps, now that I have the concept working. Should I just push up my fork of pact-python to github with the changes in place, or would folks like to talk about them first? The verifier code also includes a full test suite, including the pact-specification test files (included as git submodules) so I?ll be merging that too.

richard.jones
2018-08-06 22:57
@matthew.balvanz (and maybe @matt.fellows) I think that?s a question for you folks? I am pretty sure you?re the main culprits in pact-python land :slightly_smiling_face:

richard.jones
2018-08-06 22:57
wth slack

richard.jones
2018-08-06 22:57
why u change that name

bethskurrie
2018-08-06 22:58
@richard.jones are you reimplementing the verifier in python?

richard.jones
2018-08-06 22:58
Already did so :slightly_smiling_face:

bethskurrie
2018-08-06 22:58
That's great for you, but we rely on the shared usage of the underlying ruby mock to push out new features quickly across all the implementations.

richard.jones
2018-08-06 22:58
I?m now merging it into the pact-python code to handle the mocking / step also

bethskurrie
2018-08-06 22:59
We don't particularly want to have a separate implementation to manage as part of the pact core library.

richard.jones
2018-08-06 22:59
OK, separate project then, gotcha

bethskurrie
2018-08-06 23:00
For example, there is a new "wip pacts" feature coming, and we'll be able to incorporate that into all the libraries simply by updating the ruby standalone version. There is more logic in pact than just the matching/mocking/verifying.

bethskurrie
2018-08-06 23:01
The Broker interactions are an important part of the story too.

bethskurrie
2018-08-06 23:03
In the future, we will be handling the "shared code" by using a FFI bindings to a Rust implementation.

richard.jones
2018-08-06 23:05
So if I understand correctly, you?re saying that the implementation I?ve created isn?t wanted by the pact community? I?ll just keep it closed source if that?s the case, no worries.

richard.jones
2018-08-06 23:05
I don?t mind. I would have created it anyway, it?s got value here.

bethskurrie
2018-08-06 23:06
I'm quite sure there is somebody who will want it.

richard.jones
2018-08-06 23:06
And it?s been a valuable exercise for me

bethskurrie
2018-08-06 23:06
There are some people for whom the benefits of a native python implementation will be more important than having up to date broker integration (which is mostly what goes into the standalone pact impl these days)

bethskurrie
2018-08-06 23:07
I assume you've implemented v2 matching?

richard.jones
2018-08-06 23:07
v1-v3, yes

bethskurrie
2018-08-06 23:07
oh 3 even. Nice.

richard.jones
2018-08-06 23:07
and the JVM oddities

bethskurrie
2018-08-06 23:07
Well, ruby doesn't have that, so somebody might like it.

richard.jones
2018-08-06 23:07
:smile:

bethskurrie
2018-08-06 23:07
Oh really...

bethskurrie
2018-08-06 23:07
what are the jvm oddities?

richard.jones
2018-08-06 23:08
some of them are captured in the JVM test cases. I?d have to go back thru my code to identify them.

richard.jones
2018-08-06 23:08
I do, however, currently skip all the XML test cases from the JVM implementation.

bethskurrie
2018-08-06 23:08
Yeah, good call

richard.jones
2018-08-06 23:09
picking my battles :slightly_smiling_face:

richard.jones
2018-08-06 23:10
Some of the JVM oddities I ran into I fed back to the pact-specification github project as needing to be addressed in the pact spec text, and I think those all got handled (IIRC, this was months ago)


richard.jones
2018-08-06 23:13
Actually, I just searched, and it looks like all those oddities have been addressed \o/

bethskurrie
2018-08-06 23:14
Go Ron.

richard.jones
2018-08-06 23:15
So yeah, I technically support all the published spec versions. And can generate version 2 and 3 pact files, though at the moment it?s hard-coded to version 3 because I?ve got a TODO to figure how to switch.

richard.jones
2018-08-06 23:16
Probably something like ?if Term is used, then use v3? but probably something more explicit like Consumer(?ConsumerName?, pact_spec_level=2) or something.

richard.jones
2018-08-06 23:16
*shrug*

bethskurrie
2018-08-06 23:17
Usually it's defined when you set up the Pact configuration in the consumer project.

bethskurrie
2018-08-06 23:17
The user specifically says which version.

bethskurrie
2018-08-06 23:17
It's important, because the provider has to support the same version.

bethskurrie
2018-08-06 23:17
So better to be explicit.

richard.jones
2018-08-06 23:17
Yeah, that?s what I was thinking

richard.jones
2018-08-07 06:29
Any suggestions for what I call my (pact-python-fork + pact-verifier + pact-pytest) project are welcome - as long as it doesn?t have the name ?reece? in it :smile:

bethskurrie
2018-08-07 10:23
Naming things is hard!

bethskurrie
2018-08-07 10:24
pure-python-pact?

bethskurrie
2018-08-07 10:24
Might be a bit hard to say :-P

matt.fellows
2018-08-07 10:45
I feel like there is a Monty _python_ angle there :laughing:

bethskurrie
2018-08-07 10:48
:neutral_face:

richard.jones
2018-08-10 00:05
\o/ got mocking of pact working thru direct mocking of urllib3, no mocking service/TCP airgap \o/

richard.jones
2018-08-10 00:05
significant boost to the user experience :smile:

bethskurrie
2018-08-10 00:12
I don't know what that means, but yay?!

richard.jones
2018-08-10 00:16
It means the consumer unit test requests never get as far as making a TCP connection, they?re mocked at a level above that. That means a) no separate thread/process to handle the TCP connection, and b) failure is immediate, not requiring TCP/HTTP connection to be handled fully (a server needs to return something back to the caller even in the case of a mock rejection because the TCP connection is open and must be completed correctly or you get a second, messier exception raised - mocking the TCP connection away avoids that).

richard.jones
2018-08-10 00:17
This was the ultimate goal of handling mocking in pact-python natively, this significant improvement for the people writing / running / debugging the tests using the pact mocks.

bethskurrie
2018-08-10 03:02
Oh, right, that makes sense.

simon.nizov
2018-08-12 09:06
has joined #pact-python

wilkin4
2018-08-12 21:32
has joined #pact-python

richard.jones
2018-08-12 23:20
project ?pactman? progress with merged unit test suite and rebasing: 22 failed, 515 passed, 96 skipped (the XML JVM testcases). I?ve also identified a range of additional tests I?ll be creating to cover off some of the pact spec v3 matching rules that aren?t currently covered by the JVM test cases. They?re being written in the same form as the JVM ones, so are shareable between implementations.

richard.jones
2018-08-13 00:00
536 passed, 129 skipped \o/ - time to publish :smile:

bethskurrie
2018-08-13 00:03
Please do a PR so we can merge the new test cases into the pact spec Richard.

richard.jones
2018-08-13 00:05
Will do!

richard.jones
2018-08-13 02:06
https://github.com/reecetech/pactman (with many TODOs left, including your request above, Beth)

bethskurrie
2018-08-13 22:07
Nice

simon.nizov
2018-08-16 08:06
Hi! I have 2 services that use JWT for authentication. To be able to verify the provider I use the `?custom-provider-header` option to set the correct header (Obviously I don?t want to keep the JWT token inside the pact). Everything works but the output turns out kind of ugly with the warning. Is there a way to suppress that warning or place it at the end/beginning of the output?

simon.nizov
2018-08-16 08:07
``` Verifying a pact between A and B Given at least blan bla a request to bla bla bla with GET /some-url/ returns a response which WARN: Adding header 'Authorization: JWT UIDHDJSfjbsdjfhBKSDFBKSDBfSHDbfhsDF.DSGJJFJKSDFBJSDGBGKSJDHGBSDKJGHBksjdhgsdfgjbdsjhgbsdkjghbKDGHSBKSDjgbsdg.GDKJSKDGJBSDGjbSDKGHBSDG' to replayed request. This header did not exist in the pact, and hence this test cannot confirm that the request will work in real life. has status code 200 has a matching body includes headers "Content-Type" which equals "application/json" 1 interaction, 0 failures ```

simon.nizov
2018-08-19 09:27
:cricket:

matt.fellows
2018-08-19 12:47
@simon.nizov unfortunately not. A similar question came up on the forums the other day, we should update the verification library to allow us to set the log level

simon.nizov
2018-08-19 12:57
Thanks @matt.fellows, I?ll see if I can try to help with that

ashish.dubey91
2018-08-20 20:43
I'm getting some warnings when I run pact-verification ``` WARN: Ignoring unsupported matching rules {"match"=>"type", "min"=>3} for path $['body']['objects'] WARN: Only the first item will be used to match the items in the array at $['body']['objects'] ```

ashish.dubey91
2018-08-20 20:43
can someone help me why they would be?

matt.fellows
2018-08-20 20:45
I think it's a bug, there's one currently open in pact js assuming you have the latest

ashish.dubey91
2018-08-20 20:46
bug in my consumer implementation? I'm using pact-jvm for that

matt.fellows
2018-08-20 20:47
I'm assuming you're seeing it during verification

ashish.dubey91
2018-08-20 20:47
my consumer uses pact-jvm to define the tests. on the provider end, I'm running python's pact-verifier

matt.fellows
2018-08-20 20:48
Yep, There's a known bug in the process that does the verification which is incorrectly warning you. Take a look at the issues in pact js for more details just to check

ashish.dubey91
2018-08-20 20:50
sorry, I see none related in the open issues here https://github.com/pact-foundation/pact-js/issues?q=is%3Aopen+is%3Aissue

ashish.dubey91
2018-08-21 04:58
cc @bethskurrie would love some help here

bethskurrie
2018-08-21 05:25
Its a valid warning @ashish.dubey91

bethskurrie
2018-08-21 05:25
Actually, the second one is, the first one isn't

bethskurrie
2018-08-21 05:26
Please raise an issue asking for the pact-ruby-standalone to be updated to the latest version. I've done some work to remove the invalid warnings.

ashish.dubey91
2018-08-21 05:35
@bethskurrie will it work if I try the ruby impl..just to verify?

bethskurrie
2018-08-21 05:36
Yes, that's a good way to test it.

bethskurrie
2018-08-21 05:36
you can use the CLI - you don't need ruby


ashish.dubey91
2018-08-21 05:47
I get the same warnings. actually more this time like this one ``` WARN: Ignoring unsupported matching rules {"regex"=>"28.4167509"} for path $['query']['lat']* ```

bethskurrie
2018-08-21 05:48
Sigh. Yeah, ok, someone raised the query one.

bethskurrie
2018-08-21 05:48
Sorry, I will fix them.

bethskurrie
2018-08-21 05:48
They have been surprisingly difficult to fix, unfortunately.

ashish.dubey91
2018-08-21 05:49
oops. I see this warning and I wonder if there is something wrong with my pact definition or a bug ``` WARN: Ignoring unsupported matching rules {"match"=>"integer"} for path $['body']['data']['product']['options'][*]['type'] ``` because of this my pact verification fails as it tries to do an exact match

bethskurrie
2018-08-21 05:50
that one is valid

bethskurrie
2018-08-21 05:50
you need to use v2 matching rules.

bethskurrie
2018-08-21 05:50
that's a v3 one

bethskurrie
2018-08-21 05:50
it should be "match": "type"

ashish.dubey91
2018-08-21 08:33
ah. I don't see any documentation of that in pact-jvm project. of v2 matching rules or explicitly setting those

bethskurrie
2018-08-21 09:52
You will be able to set the pact specification version somewhere.

ashish.dubey91
2018-08-21 13:10
interestingly I was able to change the version. the spec version is correct in the generated pact file but the rules still have {"match"=>"integer"}

ashish.dubey91
2018-08-21 19:31
could this be a bug with pact-jvm?

richard.jones
2018-08-21 22:12
@ashish.dubey91 I?d be curious to know whether you have any success using the pactman verifier, which is compatible with spec version 2 and 3. I haven?t made a release yet, but you can clone the repos from https://github.com/reecetech/pactman - note that the command-line arguments for the pactman verifier are a little different to the pact-python one (https://github.com/reecetech/pactman#verifying-pacts-against-a-service)

richard.jones
2018-08-21 22:14
We also need to verify pact-jvm pacts, which is why I needed to support spec version 3 :slightly_smiling_face:

richard.jones
2018-08-22 01:29
I have just pushed up an actual release of pactman - https://pypi.org/project/pactman/

ashish.dubey91
2018-08-22 03:37
that's great! I can try it

ashish.dubey91
2018-08-22 03:42
@richard.jones ``` Traceback (most recent call last): File "/home/ashish/venv/bin/pact-verifier", line 7, in <module> from pactman.verifier.command_line import main File "/home/ashish/venv/local/lib/python2.7/site-packages/pactman/__init__.py", line 2, in <module> from .mock.consumer import Consumer ImportError: No module named mock.consumer ```

ashish.dubey91
2018-08-22 04:06
there seems to be some packaging issue

ashish.dubey91
2018-08-22 04:11
@richard.jones if this helps ``` s/pactman$ pwd /home/ashish.dubey/venv/local/lib/python2.7/site-packages/pactman (staging) ashish.dubey@cicommon6:~/venv/local/lib/python2.7/site-packages/pactman$ ls __init__.py __init__.pyc __version__.py __version__.pyc (staging) ashish.dubey@cicommon6:~/venv/local/lib/python2.7/site-packages/pactman$ ```

ashish.dubey91
2018-08-22 04:11
installed in a virtualenv

ashish.dubey91
2018-08-22 04:12
I want to make this work so badly

richard.jones
2018-08-22 04:57
@ashish.dubey91 thanks! I actually hadn?t tried to use it packaged yet, sorry! If you run cloned from the repos it should be ok. I?ll look into the packaging issue ASAP!

richard.jones
2018-08-22 04:58
hah, yeah, that package is totally broken :disappointed:

ashish.dubey91
2018-08-22 04:58
I tried cloning the repo and putting the files into my packaged directory but that had issues as well

richard.jones
2018-08-22 05:00
Yep, just pushing up a fix now :slightly_smiling_face:

richard.jones
2018-08-22 05:01
1.0.5 is released which should have all the codez

ashish.dubey91
2018-08-22 05:02
should I try again?

richard.jones
2018-08-22 05:02
just verifying ?

richard.jones
2018-08-22 05:03
Yep, 1.0.5 looks good

ashish.dubey91
2018-08-22 05:03
is it up on pypi?

ashish.dubey91
2018-08-22 05:03
I can't find the upgrade


ashish.dubey91
2018-08-22 05:05
not sure if it's cached somewhere or something ... I'm getting 1.0.4 yet

richard.jones
2018-08-22 05:06
the github repos is also updated, so you could pull from that and run python setup.py install in there

richard.jones
2018-08-22 05:07
hurm. there?s an issue in the verifier, yay for fresh codez

richard.jones
2018-08-22 05:09
I renamed one of the command line args just before release and missed a change. Just fixing.

ashish.dubey91
2018-08-22 05:11
this means I'm just stuck :confused:

richard.jones
2018-08-22 05:11
yup, sorry. I?m working on getting it fixed and released. Verifying it works again before release tho :smile:

richard.jones
2018-08-22 05:12
ok, it?s definitely working again locally. pushing it up now.

richard.jones
2018-08-22 05:13
github repos is up to date, just packaging and pushing to pypi now? and done

ashish.dubey91
2018-08-22 05:51
``` (venv) (staging) ashish.dubey@cicommon6:~$ pact-verifier -h Traceback (most recent call last): File "/home/ashish.dubey/venv/bin/pact-verifier", line 7, in <module> from pactman.verifier.command_line import main File "/home/ashish.dubey/venv/local/lib/python2.7/site-packages/pactman/__init__.py", line 2, in <module> from .mock.consumer import Consumer File "/home/ashish.dubey/venv/local/lib/python2.7/site-packages/pactman/mock/consumer.py", line 4, in <module> from .pact import Pact File "/home/ashish.dubey/venv/local/lib/python2.7/site-packages/pactman/mock/pact.py", line 6, in <module> from pactman.mock.request import Request File "/home/ashish.dubey/venv/local/lib/python2.7/site-packages/pactman/mock/request.py", line 49 raise ValueError(f'Invalid Pact specification version={spec_version}') ^ SyntaxError: invalid syntax ```

ashish.dubey91
2018-08-22 05:51
@richard.jones ^

ashish.dubey91
2018-08-22 17:41
@bethskurrie if I simply replace "integer" with "type" in my pact json before verification, it works. somehow I can't generate a pact in that form by pact-jvm, something's up with that

richard.jones
2018-08-22 22:16
@ashish.dubey91 which version of Python did you install with? It?s only compatible with version 3+ and only been tested with 3.6

matt.fellows
2018-08-22 22:23
Looks like python 2.7

richard.jones
2018-08-22 22:26
I?ve pushed up 1.0.7 which clarifies the Python version requirement. Sorry about that!

richard.jones
2018-08-22 22:49
All these wonderful things you discover when you make a public release of software that?s been internal for ? cripes about 6 months now :smile:

bethskurrie
2018-08-22 22:53
welcome to oss support.

matt.fellows
2018-08-22 22:58
And these are the easy/good ones :slightly_smiling_face:

matt.fellows
2018-08-22 22:58
Wait for the ?I want to use your software but am experiencing a completely unrelated problem while doing so. I see you know how a computer works, please help?

richard.jones
2018-08-22 23:19
I?ve been around OSS for a while, I know how fun it is :smile:

richard.jones
2018-08-22 23:20
I kinda rushed the pactman release out tho because of the impending PyCon AU and potential to alleviate some of @ashish.dubey91?s issues

richard.jones
2018-08-22 23:20
Release Early, Release Often :smile:

richard.jones
2018-08-22 23:20
(try not to Release Broken)

matt.fellows
2018-08-22 23:25
ah cool, I did see PyCon is coming up. That?s awesome - nothing like conference-driven-development :slightly_smiling_face:

richard.jones
2018-08-22 23:30
My co-worker Syliva is presenting about Pact on Sunday

matt.fellows
2018-08-22 23:58
awesome!

matt.fellows
2018-08-22 23:58
If you have any social/tweets for us to share, let us know

ayodaiken
2018-08-24 19:11
has joined #pact-python


richard.jones
2018-08-31 00:50
I?ve released version 1.0.9 which just fixes the ?verbose? level console output for the pact-verifier (which I will be renaming in the next release to avoid conflict with the existing tooling of that name) https://pypi.org/project/pactman/

matt.fellows
2018-08-31 00:51
This was great, btw - well done! I?ll pop a link on our docs site to share

richard.jones
2018-09-03 00:41
pactman 1.1.0 released: renames the pact-verifier command to pactman-verifier (as mentioned above); also implements HEAD request verification (oops) and adds a -V/--version command line option.

simon.nizov
2018-09-03 07:57
Hey @richard.jones, I?m a little confused, what?s the difference between `pactman` and the ?official? `pact-python` library?

andyharkinsqa
2018-09-03 16:23
has joined #pact-python

richard.jones
2018-09-03 21:51
@simon.nizov the key difference is all functionality is implemented in Python, rather than shelling out or forking to the ruby implementation. This allows for a much nicer mocking user experience (it can mock urllib3 directly), is faster, less messy configuration (multiple providers -> multiple ruby processes spawned on different ports). It also supports a broader set of the pact specification (versions 1.1 through to 3). There?s a few other quality of life improvements, but those are the big ones.

richard.jones
2018-09-03 21:52
No, I don?t expect anyone is generating version pacts to spec version 1.1 :wink:

simon.nizov
2018-09-04 08:55
@richard.jones Ahh gotcha, thanks! I think you should mention these differences in the opening paragraph of the readme :slightly_smiling_face:

richard.jones
2018-09-04 21:57
@simon.nizov yeah :slightly_smiling_face:

joguespermana
2018-09-05 02:57
has joined #pact-python

bethskurrie
2018-09-09 21:38
There should be a place where you set the pact specification version @ashish.dubey91

privat.sebastian.muel
2018-10-21 09:59
has joined #pact-python

sylvia.yap
2018-10-31 05:27
has joined #pact-python

hima.sanagavarapu
2018-11-07 19:34
has joined #pact-python

hima.sanagavarapu
2018-11-09 16:19
@hima.sanagavarapu has left the channel

kurst03
2018-11-18 00:52
has joined #pact-python

jornhansen
2018-11-24 08:15
has joined #pact-python

zach.the.hammer
2018-11-28 22:26
has joined #pact-python

zach.the.hammer
2018-11-28 22:26
@richard.jones oh wait, i may have been confused by this part of the pactman readme (that i believe was copied over from pact-python) https://github.com/reecetech/pactman#provider-states

zach.the.hammer
2018-11-28 22:27
>>> When setting up the testing of a provider you will also need to setup the management of these provider states. The Pact verifier does this by making additional HTTP requests to the <provider setup url> you provide. This URL could be on the provider application or a separate one. Some strategies for managing state include: Having endpoints in your application that are not active in production that create and delete your datastore state A separate application that has access to the same datastore to create and delete, like a separate App Engine module or Docker container pointing to the same datastore A standalone application that can start and stop the other server with different datastore states

richard.jones
2018-11-28 22:27
So pactman has two mocking modes: straight mocking of urllib3 which covers 90% of use cases, and a separate process for the 10% of folks not using `requests` :slightly_smiling_face:

zach.the.hammer
2018-11-28 22:28
so what i'm confused about is: can you do pact broker verification without using an external `<provider setup url>`? This is the one part puts me off of pact testing

zach.the.hammer
2018-11-28 22:29
i'm at work right now so i think i am typing/explaining rather quickly and not being very clear. i can follow up later

richard.jones
2018-11-28 22:30
oh, you can do pact verification without provider states but it?s *really strongly discouraged* as provider states are kinda a backbone of the pact philosophy

richard.jones
2018-11-28 22:30
I?m also in three convos at the moment, I?ll try to respond here in a timely manner

zach.the.hammer
2018-11-28 22:34
okay. i'll follow up once at home with time to give an example of what i'm looking for. as far as i can tell pact verification in `pact-ruby` can be done in the testing file, without having to both call a `setup url` and a `provider url`. this is what i'm looking at: https://github.com/pact-foundation/pact-ruby/wiki/Verifying-pacts#using-rake-pactverify (specifically `# Require the provider states files for each service consumer`) https://github.com/pact-foundation/pact-ruby/wiki/Provider-states#provider-codebase

richard.jones
2018-11-28 22:36
Pact verification isn?t done in a *test* it?s run as a separate process that slurps in a pact file and runs each interaction in the file against a provider, and records whether the interaction matches the expectation in the pact file. That?s not a *test* (in the ?unit test? or ?behave test? sense).

richard.jones
2018-11-28 22:37
In the ruby example you show above, that?s just configuring the verifier to be callable from rake (the python equivalent is how we invoke the pactman-verifier from tox)

richard.jones
2018-11-28 22:38
For example, from one of our tox.ini: ```[testenv:pact-verifier] envdir = {toxworkdir}/pactman deps = pactman whitelist_externals = sh setenv = PACT_BROKER_URL=http://pact-broker.reecenet.org/ commands = sh -c "pactman-verifier -r -v -p $(python setup.py --version) BranchServicePython \ http://localhost:8000/ http://localhost:8000/branches-service/pact/" ```

richard.jones
2018-11-28 22:39
(the need to `sh` it to get the version from the setup file is something I?d really like to figure a more elegant solution to :smile: )

bethskurrie
2018-11-28 22:42
The ruby version archives the "test" part by using metaprogramming, but I'm not sure if that works in other languages.

bethskurrie
2018-11-28 22:44
We're actually programmatically construct and execute an rspec test.

richard.jones
2018-11-28 22:45
?archives?? Is that just a typo of ?achieves??

bethskurrie
2018-11-28 22:45
Which means we can allow the user to do all the usual rspec things in a test like mocking

bethskurrie
2018-11-28 22:45
Achieve

bethskurrie
2018-11-28 22:45
Sorry typing and walking

richard.jones
2018-11-28 22:45
Yep. BRB, standup :slightly_smiling_face:

zach.the.hammer
2018-11-28 22:47
Haha i am walking while reading

zach.the.hammer
2018-11-28 22:48
This is really helpful @bethskurrie.

zach.the.hammer
2018-11-28 22:53
I?m going to try to write up a few of my questions / thoughts on this in one place for clarity instead of a lot of confused slacks

zach.the.hammer
2018-11-28 23:05
Basically pact seems awesome and i really want to experiment with it in my python services but feel like > Which means we can allow the user to do all the usual rspec things in a test like mocking is essential

zach.the.hammer
2018-11-28 23:09
i?m going to write up a few reasons why when i have time though so i can share / figure out if this is _actually_ essential or if i?m just not thinking this through

bethskurrie
2018-11-28 23:10
Most people get by without it, but I think it's quite handy

richard.jones
2018-11-28 23:10
@zach.the.hammer pactman mocks are basically a lot like regular mocks (using the default use_mocking_server=False) and your tests look like regular tests, and it?s all in-process

bethskurrie
2018-11-28 23:10
Most of the other languages (.net, javascript) wrap the ruby impl

zach.the.hammer
2018-11-28 23:11
@richard.jones when you say pactman mocks you?re talking about the mocks used on the consumer tests, right?

zach.the.hammer
2018-11-28 23:11
that?s where i?m a bit confused

richard.jones
2018-11-28 23:11
@zach.the.hammer yes, the mocks are used in the consumer tests (and not during verification)

zach.the.hammer
2018-11-28 23:11
i also realize ?tests? may not be the preferred word in pact since the code run on the consumer side is not just testing but also driving/creating the contract

richard.jones
2018-11-28 23:11
(pact can be quite confusing when you start out, that?s quite normal)

zach.the.hammer
2018-11-28 23:12
i?m talking about on the provider side.

zach.the.hammer
2018-11-28 23:12
re: verifying contracts w/ the provider. but doing so the way @bethskurrie is explaining is possible in ruby

richard.jones
2018-11-28 23:13
sorry I am in a meeting that I need to concentrate on for a bit, back in a while

zach.the.hammer
2018-11-28 23:13
no problem. i?m going to post a few slack messages here that i hope are clear! i?m about to go see my brother but will try to share the thoughts i have for now in this thread

zach.the.hammer
2018-11-28 23:14
or maybe i will post after drinks with my brother haha

zach.the.hammer
2018-11-28 23:51
okay here are some quickly jotted thoughts

zach.the.hammer
2018-11-28 23:51
pact feels so much like cucumber/gherkin that i instinctively want to setup my provider verification the same way i would a cucumber test. ``` Given there is an alligator named Mary When I send the request """ /alligators?name=Mary """ Then I get the response """ { "items": [{"name": "Mary"}] } """ ``` In python-behave (a python implementation of cucumber) I can define functions like (not perfect syntax) ``` @Given('there is an alligator named Mary') def ...: add_mary_to_db() def after_scenario(): clear_db() ``` And then in the same run of my testing framework use my service as validate my response. i understand that pact and cucumber are different tools for different uses, but the ability to verify specs / validate contracts inside a testing framework feels very crucial to me. a few things that seems like they?d be major headaches without being able to validate pacts inside a testing framework 1. mocking requests to external APIs / general monkeypatching using a call to a `<provider setup endpoint>` seems fine for setting up provider state in a datastore in most cases. in my circleci i already run a postgres instance that i communicate w/ for tests. my `<provider state endpoint>` for `there is an alligator named Mary` could put an alligator named mary in the db and then my call to my provider endpoint would read from that db. using a call to a `<provider setup endpoint>` seems like a MAJOR pain for mocking requests to external apis, however. if my `alligators` microservice is a wrapper service around some public alligator API `https://alligators.gov`, the way i want to do the provider setup is something like ```py def my_there_is_an_alligator_named_mary_fixture(): with mock_response_from('http://alligators.gov', to_be="{...a lot of alligator data including some info about mary}"): yield # my contract test would run here ``` i have no idea how i could do this in a not incredibly hacky / fragile / cumbersome way through a call to `<provder setup endpoint>` 2. tear down at the end of the test suite this is pretty minor, but when you only call a `<provider setup endpoint>` at the beginning of each provider test, you can reset state before each provider test, but you can?t cleanly tear down at the end of your pact test suite, which means there may be lingering state in a test database 3. aws lambda functions (and i imagine lots of functions as a service) don?t have easy ways to call locally as an endpoint if i?m testing a python service written in tornado, i can just have my `pact-verifier` send an HTTP request to my running service and that?ll look just like a real request the service would handle. for aws lambda, i?d have to use some api gateway emulator library (like [serverless-offline](https://github.com/dherault/serverless-offline)) to setup my service to respond to http events from `pact-verifier`. (and serverless offline doesn?t even work for python!) there?s also all sorts of other information aws api gateway passes to a lambda function handler that `pact-verifier` wouldn?t send which i could depend on for my request handling. i?d want / need to be able to control all of this w/in a testing framework.

zach.the.hammer
2018-11-28 23:52
basically i really would love to see what @bethskurrie & co. have implemented in the pact-ruby implementation implemented in python! there are a lot of similar tools in frameworks like `behave` or `pytest`. maybe i can try to write up an mvp of something like this when i have some time.

zach.the.hammer
2018-11-28 23:54
@richard.jones if you have run into any of these issues and have been able to resolve them using the current pactman pact verification, i?d love to hear / see how

richard.jones
2018-11-29 00:40
@zach.the.hammer Wow. That?s really hard to read in a slack thread :disappointed: how about we don?t use Threads :slightly_smiling_face: (I?m familiar with behave - I was a co-author :wink:) So? provider verification of pacts is *stateless* and done *entirely across a HTTP airgap* intentionally. That means pact states can *set up data* but not do any teardown. There may be hooks in ruby that the ruby verifier exploits (I *think* that?s what @bethskurrie is referring to as ?the usual rspec things in a test like mocking?, allowing stateful verification) but that?s not an option in Python (or any other language as far as I know) because of the process/TCP airgap that the ruby verifier forces you to have. I have previously experimented with a closer binding of verification with pytest, but it was a bit of a mess because at the time I?d not implemented my own Python verification code, I was still spawning the ruby process. It might be worth revisiting now that we?ve got a Python verifier. For now though, you need to run the pactman-verifier command line with the provider state URL to control the state of your provider.

richard.jones
2018-11-29 00:42
Our provider states consist of two things: very basic monkeypatching of calls outside of the provider (to other APIs) and creation of data in the database table(s) that the provider relies on to process the request, according to the provider state being requested. The pact state code also clears out any other data from the database (it?s a database brought up just for verification).

richard.jones
2018-11-29 00:42
But the key is: there is no ?after scenario? or other kind of teardown after a pact verification has been attempted. It?s just not part of the pact verification spec.

bethskurrie
2018-11-29 00:43
Regarding point 2, it's best practice to never assume state from a previous test, and to clean everything *before* a test runs, rather than after.

bethskurrie
2018-11-29 00:44
This has the added benefit of leaving your data in a state that you can investigate after a failing test (eg. inspect the database records)

bethskurrie
2018-11-29 00:44
That's why I haven't exposed the tear down hook in the pact-ruby-standalone.

bethskurrie
2018-11-29 00:44
(even though it exists in the ruby impl)

zach.the.hammer
2018-11-29 03:34
hey! first off i am super thankful for all the feedback on these questions.

zach.the.hammer
2018-11-29 03:34
so: point 2 was definitely the least important of the thoughts i?m having

bethskurrie
2018-11-29 03:35
it was the only one I could contribute to :stuck_out_tongue:

bethskurrie
2018-11-29 03:35
Not being a python person!

zach.the.hammer
2018-11-29 03:35
re: 1-- @richard.jones it seems like you have been able to set up mocking in provider verification tests > Our provider states consist of two things: very basic monkeypatching of calls outside of the provider (to other APIs) and creation of data in the database table(s) that the provider relies on to process the request, according to the provider state being requested. i?d be really curious to see how you?ve done monkeypatching here!

zach.the.hammer
2018-11-29 03:36
also @bethskurrie has the issue of functions as a service come up before?

bethskurrie
2018-11-29 03:36
yes, often.

bethskurrie
2018-11-29 03:36
we recommend using pact-message

zach.the.hammer
2018-11-29 03:36
it really is tough to figure out how to send an http request to a provider and make it prod-like

bethskurrie
2018-11-29 03:37
you test using only the function and the payload

bethskurrie
2018-11-29 03:37
sidestep the http

zach.the.hammer
2018-11-29 03:37
Ah! Let me check that out

bethskurrie
2018-11-29 03:37
Make sure you split your code into the "business logic" and the gateway handling parts.

bethskurrie
2018-11-29 03:38
only test the business logic.

zach.the.hammer
2018-11-29 03:38
Is there a pact-message repo?

bethskurrie
2018-11-29 03:38
Yes, for js.

bethskurrie
2018-11-29 03:38
it may be built in to the current pact-js

zach.the.hammer
2018-11-29 03:38
Yeah it seems js is the first class citizen for faas these days


bethskurrie
2018-11-29 03:39
There's no python support, however, given that Richard has already done the leg work on the matching, implementing the framework wouldn't be too much work.

richard.jones
2018-11-29 03:44
@zach.the.hammer yep, I?ll share a snippet of one of our pact provider state implementations

zach.the.hammer
2018-11-29 03:46
Awesome! I?ll look into pact message @bethskurrie. And @richard.jones i?d love to see the monkeypatching example!

richard.jones
2018-11-29 03:47
DM?ed you

zach.the.hammer
2018-11-30 01:48
hey @richard.jones ? is there no support for tags in pactman?


richard.jones
2018-11-30 02:45
tags to send to broker? not yet, no, since we (reecetech) don?t use them yet because we?re bad people :slightly_smiling_face:

richard.jones
2018-11-30 02:45
should be easy enough to add to the broker push tho

bethskurrie
2018-11-30 02:46
Tags are a PUT to /pacticipants/PACTICIPANT/versions/VERSON/tags/TAG

richard.jones
2018-11-30 02:46
(yes, Beth, we?re still running that dev/prod broker split because we?ve not had time to address that very early mistake :wink: )

bethskurrie
2018-11-30 02:46
Remember you can have multiple tags

richard.jones
2018-11-30 02:46
cool.

bethskurrie
2018-11-30 02:47
Fingers in ears, la la la!

richard.jones
2018-11-30 02:47
:smile:

richard.jones
2018-11-30 04:49
pactman version 2.4.0 has been released with some usability improvements and fixes to query parameter handling for pact v3 mocking and verification https://pypi.org/project/pactman/

zach.the.hammer
2018-11-30 20:30
@richard.jones -- I'm still poking around / getting a better understanding of the `pactman` repo. When I run a test with a pact mock, given that the contextmanager exists (/ `pact.verify()`) is called, the pact files will be created in the pact destination dir. But `pactman` doesn't actually publish the pact / check if the pact is 'verified', correct? That would be done separately in the CI / local environment using the `pact_broker-client`?

richard.jones
2018-12-02 21:07
@zach.the.hammer correct, the pact is published using curl at present (one of these days it?d be nice to write the trivial extra bit of pactman to do that) and provider verification is a very separate step using pactman-verifier (we run this as a daily job and also triggered at the end of a successful test run in the provider?s repos)

richard.jones
2018-12-02 21:10
So you?re partially correct in the second para. pactman doesn?t publish the pact, but does verify it.

zach.the.hammer
2018-12-02 21:31
Cool cool. So the bit i mentioned about tagging isn?t relevant since that occurs in the request to the broker and isn?t included inside of the pact file

richard.jones
2018-12-06 22:03
Sneak https://pypi.org/project/pactman/ release yesterday that I forgot to announce, version 2.5.0 fixes an issue we found around verifying empty arrays in body data.

zach.the.hammer
2018-12-12 04:31
hey richard

zach.the.hammer
2018-12-12 04:31
@richard.jones

zach.the.hammer
2018-12-12 04:32
going to post a question issue on the pactman github


zach.the.hammer
2018-12-12 04:43
here?s the issue

richard.jones
2018-12-12 04:45
Thanks, I?m just looking into that now!

zach.the.hammer
2018-12-12 04:47
Awesome! Yeah the implementation here seems to reflect what i?d imagine ?eachlike? would behave

zach.the.hammer
2018-12-12 04:48
Since it?s checking that each element in a list is like the provided spec element

richard.jones
2018-12-12 04:48
I?ve just added a comment in response

zach.the.hammer
2018-12-12 04:51
hmm.. it is an actual case i ran into but with a more complex pact

zach.the.hammer
2018-12-12 04:52
let me take a closer look

zach.the.hammer
2018-12-12 04:54
i?ll also look at those two testcases you mentioned

richard.jones
2018-12-12 04:54
added in some more in that comment you made. if you have an actual pact and failing payload I?d love to see it to run a test. feel free to make a private gist on github if you can share it (or email me directly if you like, I can give my email in DM)

zach.the.hammer
2018-12-12 04:54
sounds good. i will poke around for a bit first

zach.the.hammer
2018-12-12 04:54
make sure i?m not missing something simple

richard.jones
2018-12-12 04:55
sure. happy to be extra eyes if you like, especially to determine whether it?s an intended behaviour or not

richard.jones
2018-12-12 04:56
a lot of the pact edge cases are defined by the JVM test cases (the files in the pact repository ?testcases? folder) and there?s also a lot of edge cases not clearly defined, so I had to make a call on what seemed appropriate given the intent of pact

richard.jones
2018-12-12 04:56
I might have gotten that wrong :slightly_smiling_face:

richard.jones
2018-12-12 05:15
@zach.the.hammer I?m finishing up for the day, chuck me a message with a gist if you get sick of poking around :slightly_smiling_face:

zach.the.hammer
2018-12-12 05:22
haha i?m heading to sleep

zach.the.hammer
2018-12-12 05:23
i posted the test case that i thought would fail but actually seems to be working fine run as a direct test against the verifier

zach.the.hammer
2018-12-12 05:23
i have a feeling i?m missing something on my end. i?ll update once i get a chance to look closer

zach.the.hammer
2018-12-12 06:20
alright now i?m heading to sleep.

zach.the.hammer
2018-12-12 06:21
i just left a final comment. give it a look when you get the chance!

zach.the.hammer
2018-12-12 06:21
had fun `pdb`ing through the codebase

zach.the.hammer
2018-12-12 06:29
Also i deleted some previous comments with my complex case since i found a simpler test case to cause same issue

anushree.shenoy
2018-12-12 10:43
has joined #pact-python

zach.the.hammer
2018-12-13 16:02
@richard.jones commented on the gh issue. my test case now works. didn't get a chance to look over the code change but seems like it works!

anothonyvong
2018-12-13 16:39
has joined #pact-python

richard.jones
2018-12-13 22:21
@zach.the.hammer I?ve released pactman 2.6.0 which includes that fix

madhukar.mishra
2018-12-17 09:18
has joined #pact-python

madhukar.mishra
2018-12-17 09:31
is dius/pact-python unmaintained now?

bethskurrie
2018-12-17 09:36
I didn't even know it existed.

bethskurrie
2018-12-17 09:36
So, I'm going with yes.

bethskurrie
2018-12-17 09:36
There are two other maintained impls.

madhukar.mishra
2018-12-17 09:41
pactman requires python3.6+ only, so that's a dealbreaker, checking out pact-test. Is the ruby standalone also powered by the rust app for generating mocks?

bethskurrie
2018-12-17 09:50
Not yet.

madhukar.mishra
2018-12-17 10:11
dumb question :worried: but is `pact-mock_service` different from `pact-stub-server` functionality wise?

bethskurrie
2018-12-17 10:14
They're different implementations.

bethskurrie
2018-12-17 10:15
Pact mock service is the ruby one, pact stub server is rust, if it's the one I'm thinking of.

bethskurrie
2018-12-17 10:15
Stub server should implement v3 spec, but mock service only implements v2 so far.

madhukar.mishra
2018-12-17 10:34
so both will be maintained in the future, and will maintain parity?

madhukar.mishra
2018-12-17 10:37
pact-stub-server seems to be able to serve stubs for pacts for multiple providers at once, which isn't the case for the ruby mock-service apparently

madhukar.mishra
2018-12-17 10:39
We are using pacts to produce mocks for bigger tests as well (eg for functional testing - in form of testing API endpoints), which often require multiple upstream services. The problem we ran into is that for the first time they behaved differently.

madhukar.mishra
2018-12-17 10:40
So I'm trying to use the same program for both the cases, to avoid this problem if possible.

madhukar.mishra
2018-12-17 10:47
Patching `pact-python` to use the system `pact-stub-server` doesn't seem like a terrible idea

madhukar.mishra
2018-12-17 10:51
one is staler than pact-python, the other is python3 only, rip my hopes of an easy way out.

vishesh92
2018-12-17 10:54
has joined #pact-python

bethskurrie
2018-12-17 19:13
What's the problem with pact-python?

davegallant
2018-12-17 22:00
has joined #pact-python

davegallant
2018-12-17 22:45
hey, new to contract-based testing and love the concept. I'm wondering how well does Pact work with Python micro-services that use HTTP, but also some that use Kafka and S3?

matt.fellows
2018-12-17 22:52
I?m not sure if it _yet_ supports the latter just yet. But it should be fairly easy to add in (Golang and JS have it as first-class citizens now, as does JVM - the original)

matt.fellows
2018-12-17 22:52
the short answer is that the concept is completely transferable

davegallant
2018-12-17 22:54
thx, will look into it some more :slightly_smiling_face:

richard.jones
2018-12-18 02:45
@davegallant we?re only just starting to look at message pacts (we?ve done a ton of HTTP pacts) so we?re on the same journey I expect :slightly_smiling_face:


zach.the.hammer
2018-12-18 15:50
@richard.jones would love to follow your exploration there

zach.the.hammer
2018-12-18 15:50
i've been trying to figure out a good implementation for that

zach.the.hammer
2018-12-18 15:51
most obvious seems like just mocking out message queue service, not sure if that's the best

zach.the.hammer
2018-12-18 15:51
message queue api*

zach.the.hammer
2018-12-18 15:52
could do a decent POC just building on top of: https://github.com/spulec/moto

rjmcguinness
2018-12-18 16:04
has joined #pact-python

richard.jones
2018-12-18 20:59
@zach.the.hammer yep, those are similar to mu thoughts

richard.jones
2018-12-18 20:59
I?m not familiar with moto/boto tho

richard.jones
2018-12-18 22:14
FYI I?ve added this to the pactman API for the next release, since it seems like a good idea: ```pact .given("this is a simple state as in v2") .and_given("also the user must exist", username="alex")```

richard.jones
2018-12-18 22:15
and_given attaches the additional provider state to a pact interaction already being defined, so must follow a given()

zach.the.hammer
2018-12-18 22:52
i'm not familiar with moto. boto is the aws-maintained aws python client

zach.the.hammer
2018-12-18 22:53
moto is mock boto

iamjillsanluis
2018-12-19 04:09
has joined #pact-python

richard.jones
2018-12-20 22:44
pactman 2.8.0 has been released with the following changes (since my last release announcement, 2.6.0): ```2.8.0 - Close up some edge cases in body content during mocking, and document in README 2.7.0 - Added `and_given()` as a method of defining additonal provider states for v3+ pacts - Added more tests for pact generation (serialisation) which fixed a few edge case bugs - Fix handling of lower-case HTTP methods in verifier (thanks Cong!) 2.6.1 - Fix issue where mocked `urlopen` didn't handle the correct number of positional arguments ```

bethskurrie
2018-12-20 23:15
Nice work @richard.jones


richard.jones
2018-12-21 00:10
I tend to add a new validation test case when a pactman user reports a bizarro edge case :slightly_smiling_face:

bethskurrie
2018-12-21 01:13
They'll never stop...

richard.jones
2019-01-02 00:23
I?ve released pactman 2.9.0: ```- Fix with_request when called with a dict query (thanks Cong) - Make start_mocking() and stop_mocking() optional with non-server mocking (WOOT) - Add shortcut so python -m pactman.verifier.command_line is just python -m pactman (mostly used in testing before release) - Handle the None provider state (BLEAH) - Ensure pact spec versions are consistent across all mocks used to generate a pact file```

richard.jones
2019-01-02 00:24
The removal of needing start_mocking/stop_mocking is the final step in the pure-python mock implementation, and allows much cleaner test setup \o/

davegallant
2019-01-02 13:44
just upgraded. It's much cleaner now in my pytest fixture.

hacosta
2019-01-03 13:04
has joined #pact-python

jdesouza
2019-01-03 13:08
has joined #pact-python

hacosta
2019-01-03 14:39
Hi, I read in the pactman documentation that supports version 3 of the pact specification. Is there some example about creating a pact between two micro services ms1 and ms2 that communicates through kafka? suppose that ms2 consumes from a topic a message with json_message structure. I want to create a pact to preserve the json_message structure.

hacosta
2019-01-03 14:40
I appreciate any help

hacosta
2019-01-03 14:40
thanks

richard.jones
2019-01-03 22:10
@hacosta sorry, I?ve not done anything with message pacts yet

matt.fellows
2019-01-03 22:12
@hacosta would you be willing to submit a PR?

matt.fellows
2019-01-03 22:12
We'd love to see it make its way into python

richard.jones
2019-01-03 22:34
I?ve just released pactman 2.10.0 which fixes a bug introduced in 2.9.0 where only one interaction per pact was captured, oops.

richard.jones
2019-01-03 22:37
@matt.fellows are there any deviations in implementation from the pact-specification v3? The spec currently has `"providerState": "or maybe 'scenario'? not sure about this"`

matt.fellows
2019-01-03 22:42
Ah, I forgot that pactman is pure python so can't leverage existing Ruby behaviour.

richard.jones
2019-01-03 22:43
I?m trying to find information about how pact works for message broker pacts, but struggling.

matt.fellows
2019-01-03 22:43
I'm out and about so hard to answer, but I don't think that there are deviations from the spec apart from the fact that the message specific stuff is only a subset

richard.jones
2019-01-03 22:44
There?s JVM testcases, which is fine, I can make sure the matching logic works (trivial) but how does mocking and verification work?

richard.jones
2019-01-03 22:45
AFAIK the ruby impl. doesn?t do messages. Not that I can find in the docs anyway.



matt.fellows
2019-01-03 23:09
Those two links might help. Ruby DSL doesn't technically support it, but the underlying libraries and components do (i.e. the verifier)

richard.jones
2019-01-03 23:14
Thanks!

mtauraso
2019-01-09 19:23
has joined #pact-python

gbivins4
2019-01-12 00:24
has joined #pact-python

chris
2019-01-21 14:38
has joined #pact-python

yousafn
2019-02-01 11:18
has joined #pact-python

richard.jones
2019-02-07 21:02
I?ve just released pactman 2.12.0 which includes the following changes: - Add Equals and Includes matchers for pact v3+ - Make verification fail if missing header specified in interaction - Significantly improved support for pytest provider verification of pacts - Turned pact state call failures into warnings rather than errors

richard.jones
2019-02-07 21:03
pytest support now looks something like this to verify a provider?s pacts: ```from django.contrib.auth.models import User from pactman.verifier.verify import ProviderStateMissing def provider_state(name, **params): if name == 'the user "pat" exists': User.objects.create(username='pat', fullname=params['fullname']) else: raise ProviderStateMissing(name) def test_pacts(live_server, pact_verifier): pact_verifier.verify(live_server.url, provider_state) ``` with the ability to use all your usual pytest fixtures around the verify call, like `live_server` above, and `monkeypatch`, etc.

richard.jones
2019-02-08 02:56
I?ve released pactman 2.12.1 which fixes a pact-python compatibility issue :confused:

bilgehanl.03
2019-02-14 13:23
has joined #pact-python

arian.maykon
2019-03-13 03:43
has joined #pact-python

nikbarch
2019-03-19 02:05
has joined #pact-python

nikbarch
2019-03-19 02:34
Hi everyone! I have a rather silly question: Is there any production-like example pact test suite? I want to try to use pact, but I?m a bit confused of what code should I extract into fixtures and what they should look like. I use Pytest for testing. Any help or links would be appreciated

janneck.wullschleger
2019-03-19 12:18
has joined #pact-python

janneck.wullschleger
2019-03-19 12:18
@nikbarch we are using pytest as well for running our unit and contract tests. What kind of example/data do you need?

nikbarch
2019-03-19 12:40
Hello Janneck! I would like to understand how to setup the testing session, what actions should fixtures do. I suppose that in fixtures we should create provider states. Should we define relationships between consumer & provider in some kind of session test fixtures (i mean this `pact = Consumer('Consumer').has_pact_with(Provider('Provider'), version='3.0.0')`) ?

janneck.wullschleger
2019-03-19 12:52
In your unit-tests/contract generating tests you define what interactions your service/app is having with other services. Out of this interactions, the contracts are generated.

janneck.wullschleger
2019-03-19 12:52
Have you already looked into the examples?

richard.jones
2019-03-19 21:47
@nikbarch we have a large suite of services which use pact. We use pytest and pactman (rather than pact-python) which has a nicer coder experience and has support for pytest.

richard.jones
2019-03-20 21:51
I?ve released pactman version 2.13.0 which adds the ability to supply custom headers to the provider requests for verification (in command line and pytest mode) https://pypi.org/project/pactman/

richard.jones
2019-03-21 22:29
I?ve also just released pactman 2.14.0 which improves some of the verbose rule verification output to make things clearer during provider verification and pytest mock usage. Yay user feedback :slightly_smiling_face:

richard.jones
2019-03-24 23:46
The above was filed against pact-python but I?ve addressed it in a patch to pactman (yeah, I wasn?t handling application/x-www-form-urlencoded POST bodies in my mocking, but I do now thanks to https://github.com/reecetech/pactman/pull/48 which also fixes another issue in v3 pact serialisation of request headers, ugh)

kataramoonlight
2019-03-25 08:57
has joined #pact-python

lekocrod
2019-03-25 14:54
has joined #pact-python

richard.jones
2019-03-28 03:31
I?ve released pactman 2.15.0 which includes these changes: - Fix structure of serialisation for header matching rules. - Add `"never"` to the `file_write_mode` options. - Handle x-www-form-urlencoded POST request bodies. https://pypi.org/project/pactman/

richard.jones
2019-03-28 03:31
This addresses the issue raised by tknino against pact-python.

richard.jones
2019-03-28 03:35
FYI we have a frontend<>BFF<>backend-services architecture here and I?ve been experimenting with using the BFF->backends pact mocks in the BFF when running the frontend<>BFF in local isolated dev mode (ie no connections to backends) and for automated frontend UI testing (which traditionally would be run over a ?full stack?). Obviously any data mutation interactions can?t be completely handled as the mocks always return the same data, but it?s going well so far!

bethskurrie
2019-03-28 03:35
interesting!

richard.jones
2019-03-28 03:36
It requires a level of confidence in pact that my co-workers in other teams haven?t quite achieved :sweat_smile:

bethskurrie
2019-03-28 03:36
yes, I would imagine.

bethskurrie
2019-03-28 03:36
I've done it once, and I don't think anyone else understood it.

murphy.meng
2019-04-17 12:14
has joined #pact-python

murphy.meng
2019-04-18 07:33
@richard.jones, firstly great work for pactman! When I went through pact-python I was thinking oops it did not actually does the verification part itself really. And I am very happy pactman does so.

murphy.meng
2019-04-18 07:51
Contract testing is heavily used in your company right? Before I sell this concept to my company, I wanna double check one of my understanding so far, please help.

murphy.meng
2019-04-18 07:55
Since pact is consumer driven, it looks like the whole testing suites are defined in consumer testing part. Whilst in provider testing part, there is not quite too much too do expect verification. yes you can specify in detail in provider test the description of each test case and do fine granularity verification, but there is nothing more you can do than what is defined in a contract. And a contract is basically defined by consumer. Am I right?

murphy.meng
2019-04-18 08:01
So in a company, one team for building api, the other team builds component as client to the api. When we do pact here, the api consumer team writes all tests and send contracts to the other team for verification. In this case, it seems not a wise idea for the api provider team to create their own test cases again since it will bring tight coupling to the test codes of both teams.

murphy.meng
2019-04-18 08:02
Given any example, this is the example provided in pactman README, a Django project might have such provider test:

murphy.meng
2019-04-18 08:04
The ?the user ?pat? exists? string, being a state, which is defined by consumer testing, by someone in consumer team, in their own repo. What happens some day this guy wanna change it to be ?the user ?pat? does exists??

murphy.meng
2019-04-18 08:05
This will break the provider side testing won?t it? How do you see such coupling?

simon.nizov
2019-04-18 09:01
You consumer team needs to be aware that they are using Pact and that changing the text describing the provider state can break the provider build. The consumer team should communicate and collaborate with the provider team when making such changes to the pact.

murphy.meng
2019-04-18 09:33
That will be painful, particularly if the consumer team is simply doing minor changes, like typo or better description in states, or some refactoring, like merge, spliting, renaming states. In a fast developing company, this can happen often.

murphy.meng
2019-04-18 09:34
And when that happens, I can imagine how api provider team will complain: ?is it necessary??, ?can you be more careful?? ?My sprints finishes tomorrow and now it change the state????

murphy.meng
2019-04-18 09:36
So, back to my statement, creating provider side testing which must reference pact state, seems introducing tight coupling with pact consumer team and can be chaos.

murphy.meng
2019-04-18 09:37
And that is against to pact original purpose, to break integration test to component tests, and thus consumer and provider can test separately.

simon.nizov
2019-04-18 09:43
You should ask this in the #general channel

murphy.meng
2019-04-18 09:46
I will hold a bit till Richard Jones made some clarification. His company seems created tones of provider tests. He might got some best practice already.

matt.fellows
2019-04-18 12:40
Yes

matt.fellows
2019-04-18 12:42
In theory it might sound worse than reality. In most cases the new states don't cone out of thin air - you would talk to the providers

matt.fellows
2019-04-18 12:43
It's in possible to remove all coupling - the fact that 2 systems communicate is a form of coupling. This is a lot less painful than having to setup global state across an entire system of APIs

matt.fellows
2019-04-18 12:44
Everyone using pact has to write provider tests. Richard is a clever guy, but you might get more responses from a broader channel

matt.fellows
2019-04-18 12:46
I'm not sure I follow. The provider should definitely write test cases to ensure it's functionality works (at all levels you'd usually expect)

matt.fellows
2019-04-18 12:46
You wouldn't write consumer specific tests if that's what you're saying

simon.nizov
2019-04-18 12:51
I think another way to look at it is we?re coupling at the testing level in order to de-couple at the deployment level :smile:

murphy.meng
2019-04-18 13:00
Thanks for clarification. Glad to hear I was over concern.

chris.empson
2019-04-18 14:28
has joined #pact-python

richard.jones
2019-04-22 23:01
Hi folks, I?ve been on vacation for a week :slightly_smiling_face: and I?l just reading back thru the messages here.

richard.jones
2019-04-22 23:05
Looks like Murphy?s questions were all very general and thanks everyone for handling them :slightly_smiling_face:

matt.fellows
2019-04-22 23:07
:+1:

murphy.meng
2019-04-23 09:36
@richard.jones, I did not see examples about server side testing in pactman repo, did I miss anything? Really wanna to see some more practical examples in Python.

richard.jones
2019-04-23 22:01
@murphy.meng what do you mean by ?server side testing??

murphy.meng
2019-04-24 06:39
I mean, provider testing. Sorry. Does it make better sense?

ryan.wicken
2019-04-26 09:12
has joined #pact-python

richard.jones
2019-04-28 22:24
@murphy.meng the pactman docs have a section on verifying pacts against a service: https://github.com/reecetech/pactman#verifying-pacts-against-a-service

richard.jones
2019-04-28 23:28
@bethskurrie regarding the `"min": 0` confusion, the pact spec version 3 (https://github.com/pact-foundation/pact-specification/tree/version-3) currently has this in the ?example of a pact file?: ``` "$.data.array1": { "matchers": [ { "min": 0, "match": "type" } ] }, ```

bethskurrie
2019-04-28 23:29
@uglyog has recanted I believe

richard.jones
2019-04-28 23:29
AFAICT though the pactman implementation does not allow min 0

richard.jones
2019-04-28 23:29
I?m trying to trace down how the offending pact was generated

bethskurrie
2019-04-28 23:29
the ruby impl never allowed it, and then ron added that when I was on mat leave

richard.jones
2019-04-28 23:34
Looks like it might be the Java impl

bethskurrie
2019-04-28 23:35
this is what happens when I go away and have kids :stuck_out_tongue:

richard.jones
2019-04-29 00:05
Confirmed, it was generated with the JVM library, but version 3.6.2 (a couple of months out of date). I?m getting the folks here to re-run that pact generation with the latest version, 3.6.5 and we?ll follow up.

bethskurrie
2019-04-29 00:05
it may still allow 0

bethskurrie
2019-04-29 00:05
you can raise an issue in pact-jvm

richard.jones
2019-04-29 00:06
(in short, if you specify `.arrayEachLike()` in a Java pact declaration, it?ll set min 0)

bethskurrie
2019-04-29 00:06
I think we decided to log a warning if someone used 0

richard.jones
2019-04-29 00:06
I think maybe the default shouldn?t be 0 though :slightly_smiling_face:

bethskurrie
2019-04-29 00:06
but I don't think it was ever done

bethskurrie
2019-04-29 00:06
I agre

bethskurrie
2019-04-29 00:06
i agree.

bethskurrie
2019-04-29 00:06
bring it up please.

richard.jones
2019-04-29 00:06
pactman outright rejects min 0, not warn. Will raise it with pact-jvm

bethskurrie
2019-04-29 00:06
:thumbsup::skin-tone-3:

murphy.meng
2019-04-29 08:11
@richard.jones, pactman README does address how to do verification. But I am not after ?how?, but ?why? and ?what should?. I mean, provider side testing seems more than simply replay the contract and validate, is this correct?

richard.jones
2019-04-29 22:21
@murphy.meng no, and that?s why I explicitly call it ?provider verification? and not ?provider side testing? :slightly_smiling_face: It?s *only* about verifying the contract, *not* about testing the provider in any other sense.

richard.jones
2019-04-29 22:23
I think the questions you have are more general Pact questions, and are probably better directed to the #general channel. The pactman docs assume a general understanding of Pact, and I really should have some references in it to the general docs (oops!) I?ll look at adding a link to https://docs.pact.io/ ASAP :slightly_smiling_face:

richard.jones
2019-04-29 22:23
*cough* oh, I do have a link, at the top. heh :slightly_smiling_face:

murphy.meng
2019-04-30 08:04
You do. :smile: I basically look around for all implementions, python, jvm, go, etc. to get how people make use of pact concepts. I did read through pact doc, but some confusings still stay. And thank you for your clarification, that provider testing does not do more even in pactman impl.

richard.jones
2019-05-09 03:13
Hi folks, I?ve just released pactman 2.20.0 which includes: - Fix pytest mode to correctly detect array element rule failure as a pytest failure - Allow restricting pytest verification runs to a single consumer using --pact-consumer-name https://pypi.org/project/pactman/

iamjillsanluis
2019-05-15 14:07
I have a general question about pact-man. Does it have nifty feature that auto document the API? We notice that the ruby version does (`doc_generator`), but I can't seem to find documentation for that feature in pact-man.

iamjillsanluis
2019-05-15 14:08
Actually, the pact broker does this already, so I am happy. :smile:

richard.jones
2019-05-15 23:13
@iamjillsanluis are you referring to the API of pactman itself? Any standard tooling should be able to generate documentation for it, including the `pydoc` command (on the command line run either `pydoc pactman` or `pydoc -p 8001` and then hit `http://localhost:8001/pactman.html` ? and marvel at the color scheme :sweat_smile:)

richard.jones
2019-05-15 23:16
Your reference to the pact broker makes me think you?re referring to a different API though! :slightly_smiling_face:

bethskurrie
2019-05-15 23:42
The ruby cli allows you to generate markdown (which of course shows as HTML in github) from the local contracts.

bethskurrie
2019-05-15 23:43
It was written before the broker existed, so the functionality is basically redundant now.

richard.jones
2019-05-15 23:46
ah, thanks @bethskurrie, and since the broker does the thing I think that?s good enough for @iamjillsanluis? needs

iamjillsanluis
2019-05-16 13:07
> since the broker does the thing... :100:

edwin.tye
2019-05-16 21:22
has joined #pact-python

jinal
2019-05-24 16:04
has joined #pact-python

miiiiauu
2019-05-24 16:07
has joined #pact-python

diandra
2019-05-28 00:22
has joined #pact-python

thakkarjinal29
2019-06-01 11:24
has joined #pact-python

rob.clarken
2019-06-04 22:47
has joined #pact-python

n.chachampis
2019-06-11 06:50
has joined #pact-python

colin.moorehill
2019-06-11 15:48
has joined #pact-python

bxj231
2019-06-18 21:09
has joined #pact-python

richard.jones
2019-06-20 00:18
Ooh, that looks like a nice feature to have! I should add it to pactman :slightly_smiling_face:

matt.fellows
2019-06-20 00:20
Feel free to chat if you have q?s

richard.jones
2019-06-20 00:22
I?m currently working on pact submission/tagging to broker during pact generation at the moment.

richard.jones
2019-06-20 00:22
(saving the need for a separate set of curl commands)

mui_ume
2019-07-06 00:24
has joined #pact-python

mui_ume
2019-07-06 00:25
Hi guys Can I have a simple example of pact in python as provider ? Thanks

kashikar.harsh
2019-08-02 07:05
has joined #pact-python

kashikar.harsh
2019-08-03 15:22
Hey Guys

kashikar.harsh
2019-08-03 15:23
This is regarding pact message queue support implementation in Python. I am willing to contribute if anyone can guide me here *Disclaimer:* Neither I am expert in pact, nor have I contributed to any project yet. thank you

richard.jones
2019-08-05 00:09
Hey @kashikar.harsh and welcome! I?ve not really got a solid idea of how message queue pact mocking/verfication works in other languages, in order to apply those patterns to the Python world. Do you?

kashikar.harsh
2019-08-05 05:59
@richard.jones I did write some sample tests in node and has a high level idea

kashikar.harsh
2019-08-05 05:59
but not how it is implemented in js

richard.jones
2019-08-05 06:08
Ahh, ok. If you have something you could share I?d like to look.

richard.jones
2019-08-05 06:09
(but I?m just finishing up work soon, so will disappear until tomorrow)

richard.jones
2019-08-12 22:09
This is what we?ve mocked out in terms of pactman API for message pacts. We tried to address the two fundamental issues: 1) messaging APIs are all quite different in structure, so we need fairly generic mechanisms which can either call into that API or be monkeypatched into it, and 2) messaging APIs all use wildly differing names for ?content? and ?metadata?, so we need transformers to convert to/from the pact names. So, for verification (where MessageHandler is a stomp.py message handler) ```def test_pact(pact_verifier, patch): sub = Mock() handler = MessageHandler(sub) def handle(pact): handler.on_message(pact['metaData'], pact['contents']) pact_verifier.verify_message(handler=handle, provider_state=provider_state) sub.ack.assert_called_once()``` And for mocking (again, mocking a stomp connection) ```@pytest.fixture def MockConnection(mocker): mock = mocker.patch("stomp.Connection", autospec=True) def transform(**kwargs): return dict(contents=kwargs['body'], metaData=kwargs['headers']) mock.send = pactman.MessageMock() mock.send.register_pact( description="Published credit data", providerState="or maybe 'scenario'? not sure about this", contents={"foo": Like("bar")}, metaData={"contentType": "application/json"}, transform=transform ) yield mock ```

richard.jones
2019-08-12 22:10
We also mocked out what this would look like in AWS SQS as well, which has a very different shape to the API, and it still worked OK.

bethskurrie
2019-08-13 10:36
Please don't expose the unfortunate naming of "metaData" in the code @richard.jones! It should be metadata. It's one word.

bethskurrie
2019-08-13 10:36
I was on mat leave, or that would never have happened.

li.poltorak
2019-08-13 21:56
has joined #pact-python

richard.jones
2019-08-13 22:08
gotcha @bethskurrie! :sweat_smile:

richard.jones
2019-08-13 23:24
I?ve turned the above proposal into an issue in the pactman github https://github.com/reecetech/pactman/issues/68 /cc @kashikar.harsh

li.poltorak
2019-08-14 18:51
Does pact-python support the `--custom-provider-header` option? It's mentioned here in the docs https://docs.pact.io/faq#how-do-i-test-oauth-or-other-security-headers but I'm getting "Error: no such option" when I try to use it.


matt.fellows
2019-08-14 20:44
That seems to map to the underlying flag you?re after - I?ll update the docs

li.poltorak
2019-08-14 20:51
Oh, thank you! I'll give that a try.

li.poltorak
2019-08-14 20:58
Hmm, I'm still getting the same "no such option" error, maybe I'm doing something wrong: `pact-verifier --provider-base-url=(url here) --pact-url=./consumer-provider.json --header=(header goes here)`

matt.fellows
2019-08-14 21:03
oh

matt.fellows
2019-08-14 21:09
have you installed the latest?

matt.fellows
2019-08-14 21:09
I just did a `pip install pact-python` (I don?t use Python much)

li.poltorak
2019-08-14 21:12
I'll double check, I have 0.16.1 specified, but it certainly seems like it's an issue of not having the latest version installed. This specific functionality is the most recent release, I'm not sure why I'm not seeing it.

matt.fellows
2019-08-14 21:15
Hmm multiple versions of python?

matt.fellows
2019-08-14 21:16
Your using pact python, not pactman right?

li.poltorak
2019-08-14 21:16
Yeah, I am. Just one version of python, 3.7.1 if that helps.

kashikar.harsh
2019-08-19 05:16
Thanks @richard.jones

kashikar.harsh
2019-08-19 05:16
naive query, how will this handler handle instance creation of the object upon which the provider method needs to be called

kashikar.harsh
2019-08-19 05:17
also since the handler code will be inside the pactman library, how will it resolve the method? Since we cannot import the provider method's module

kashikar.harsh
2019-08-19 11:01
One more question is, as per the specification, the message part will look like this

kashikar.harsh
2019-08-19 11:02
How will handler know which method to call as I do not see any method name in the above specification

richard.jones
2019-08-19 22:14
I wasn?t clear then: the sample code I pasted is in *your* test suite, so you make any decisions about instantiation of handler objects or which methods to call.

simon.waterhouse
2019-08-20 14:16
has joined #pact-python

r.deboer
2019-08-26 14:42
has joined #pact-python

r.deboer
2019-08-26 14:53
Hi, I have a problem with my tests using Pact. I have set up several pacts with the same consumer, but with different providers. Most are working fine, but for one of the pacts I keep getting the problem that it can't find a matching interaction even though it is there. Looking at pact-mock-service.log, I see the following lines related to this pact: ```I, [2019-08-26T16:34:16.394161 #13280] INFO -- : Registered expected interaction GET /jobs/?workflow_step=foo:bar:/bars/1/steps/1/ I, [2019-08-26T16:34:16.472296 #13280] INFO -- : Received request GET /jobs/?workflow_step=foo:bar:/bars/1/steps/1/ E, [2019-08-26T16:34:16.472296 #13280] ERROR -- : No matching interaction found for GET /jobs/?workflow_step=foo:bar:/bars/1/steps/1/ E, [2019-08-26T16:34:16.472296 #13280] ERROR -- : Interaction diffs for that route: E, [2019-08-26T16:34:16.472296 #13280] ERROR -- : W, [2019-08-26T16:34:16.487924 #13280] WARN -- : Verifying - actual interactions do not match expected interactions. Missing requests: GET /jobs/?workflow_step=foo:bar:/bars/1/steps/1/ Unexpected requests: GET /jobs/?workflow_step=foo:bar:/bars/1/steps/1/ W, [2019-08-26T16:34:16.487924 #13280] WARN -- : Missing requests: GET /jobs/?workflow_step=foo:bar:/bars/1/steps/1/ Unexpected requests: GET /jobs/?workflow_step=foo:bar:/bars/1/steps/1/ ``` Why is it not recognizing the registered interaction?

matt.fellows
2019-08-27 05:29
hmm it looks like the interactions should have matched. Perhaps they should be URL encoded? I?m not sure the `/` is valid in a query string. Is it?

matt.fellows
2019-08-27 05:33
Try removing the extra bits of the query string (i.e. just make it something like `?workflow_step=foo`) and if that works, you know it?s probably the specific query string that?s the issue

r.deboer
2019-08-27 07:01
Thanks for your reply. It is a good suggestion. I will leave the `/` out in the query. It is, however, not the cause of the issue, because the interactions still don't match: ```W, [2019-08-27T08:56:28.164552 #16316] WARN -- : Verifying - actual interactions do not match expected interactions. Missing requests: GET /jobs?workflow_step=foo Unexpected requests: GET /jobs?workflow_step=foo``` Do you have any other suggestions that I can try?

bethskurrie
2019-08-27 07:14
Usually this happens when there is a timing issue, and the order goes: execute real request (that generates the unexpected one), set up expected request (that's what causes the missing one), verify.

bethskurrie
2019-08-27 07:15
It's obviously meant to go: set up expected request, execute real request, verify.

bethskurrie
2019-08-27 07:15
But your logs look like things are in the right order.

bethskurrie
2019-08-27 07:17
I can't see how those two paths don't match. It's like there's some magic character that's not being printed.

bethskurrie
2019-08-27 07:19
In the expectation, are you putting the query string into its own field? Or are you putting it with the path?

bethskurrie
2019-08-27 07:19
They should be declared separately. I suspect it's not matching because it's doing individual matches on path and and query, not a single match on the full path+query.

r.deboer
2019-08-27 07:29
Thanks, that is it! I forgot to put the query as `query=` argument. Thanks for your help!

bethskurrie
2019-08-27 07:32
Np

richard.jones
2019-08-29 05:07
Hey folks, just letting you all know that I finish up with Reece next week, so I won?t be as active in `pactman` land. Development has slowed down anyway, since it?s very stable now and pretty feature-complete (excepting the messages stuff, sadly). There will still be folks here at Reece who will be maintaining the code.

matt.fellows
2019-08-29 08:05
Well, thanks for taking it to where it is - amazing work! Hopefully wherever you go you?ll continue to evangelize!

matt.fellows
2019-08-29 08:05
Where to?

joao
2019-08-29 13:35
has joined #pact-python

richard.jones
2019-09-01 22:23
Off to Biarri Rail to play with trains :slightly_smiling_face:

sahil.goyal2
2019-09-09 12:24
has joined #pact-python

r.deboer
2019-09-13 08:32
Is there any chance that the fix for https://github.com/pact-foundation/pact-support/issues/68 can be included in the Pact-Python package soon?

c.metz
2019-09-13 08:37
has joined #pact-python

bethskurrie
2019-09-13 09:19
@r.deboer raise an issue in pact python to upgrade the version. Or, if you can work out where it's set, you could raise a PR to expedite the process.

bethskurrie
2019-09-13 09:20
With my husband's bestie, Rory Hart. He's happy you're joining him @richard.jones!

r.deboer
2019-09-13 14:04
Thanks for your quick reply. We tried (locally) to upgrade the version, because we hoped that the fix would also be a fix for our problem. Unfortunately that is not the case.

nithinmohan114
2019-09-20 07:44
has joined #pact-python

s.roodhorst
2019-09-24 09:48
has joined #pact-python

s.roodhorst
2019-09-24 09:57
Hi all, I was working on writing python tests for using secure requests over ssl. I noticed that this is not (correctly) implemented in the python pact library. It is still using the requests without https and without the certificates. Can I make an issue and pull-request for my changes to make it work?

matt.fellows
2019-09-24 10:37
yes please!

s.roodhorst
2019-09-24 11:36
It turns out that more changes are needed or I'm doing something wrong. I now added the sslcert, key and ca to the requests as arguments. This works for internal pact testing. But when I am debug the started mock server and do a curl -k https://localhost:1234 command I can also get the contents, without needing the certificate

matt.fellows
2019-09-24 20:50
`-k` says skip validating the certificate (from the clients? perspective). What are you expecting it to do?

jorge.florian
2019-09-25 13:16
has joined #pact-python

jorge.florian
2019-09-25 13:36
Hi guys, my team is planning to use Pact for our multiple web applications and our backend. Our backend is written in python I would like to know how stable is this library and if it's still maintained.

rootuid
2019-10-03 08:53
has joined #pact-python

rootuid
2019-10-04 08:42
Hi @channel, I'm making a requests.get to the pactman mock server but I get a 500 + "received but no interaction registered" back. It appears the mock server is up,returns a 500 and the message as per this code https://github.com/reecetech/pactman/blob/67e17532dc0dff4e41c33cb98cb747670fa6adf2/pactman/mock/mock_server.py#L104 . I don't however know why it's happening. Any tips appreciated

matt.fellows
2019-10-06 22:42
Have you first registered expectations such as a `GET /some/path 200`? If your code is making the call to the mock server, but has not first told it what it?s going to do, you?ll get that error

matt.fellows
2019-10-06 22:42
perhaps you could share some code?

matt.fellows
2019-10-06 22:43
That line would suggest there is no interactions registered, so it can?t find an appropriate response to your request

tony.ibbs
2019-10-07 14:20
has joined #pact-python

rbhati
2019-10-08 17:26
has joined #pact-python

harshavardhan.chowdar
2019-10-10 15:32
has joined #pact-python

ayip
2019-11-15 00:41
has joined #pact-python

rbhati
2019-11-18 22:15
#pact-python :pactman [https://pypi.org/project/pactman/] provides a kiss CLI called pactman_verifier to verify pact; And I wonder if I can achieve same goal of validating pact [available on pact-broker] via pact-python

rbhati
2019-11-18 22:16
any pointers and direction will be great help

rbhati
2019-11-19 16:43
any help here, anybody??

matt.fellows
2019-11-20 04:54
I think the model?s are slightly different. Have you read https://github.com/pact-foundation/pact-python#verifying-pacts-against-a-service ?

matt.fellows
2019-11-20 04:54
what else have you tried?

megha.agrawal
2019-11-26 18:34
has joined #pact-python

megha.agrawal
2019-11-26 18:35
Hi I am able to successfully run the provider tests when the pact file is stored locally but getting 401 error when the pact file is store in pact broker. I am using python. Here is the command I am using ```pact-verifier --pact-url="http://your-pact-broker/pacts/provider/PROVIDER/consumer/CONSUMER/latest" --custom-provider-header='Authorization: Bearer mytoken' --provider-base-url="http://localhost:8080"``` Where am I doing wrong?

megha.agrawal
2019-11-27 00:20
Can someone give me a simple example of provider test that uses pact file from broker?

gordo
2019-12-09 22:27
has joined #pact-python

taisedias
2019-12-22 21:53
has joined #pact-python

vasile.pop
2019-12-23 14:42
has joined #pact-python

david.wang3
2020-01-08 17:04
has joined #pact-python

bethskurrie
2020-01-11 04:33
Hey python users. Would anyone be up for submitting a PR to pact-python to allow pacts to be fetched dynamically from a Pact Broker? This is the issue https://github.com/pact-foundation/pact-python/issues/114

bethskurrie
2020-01-11 04:34
It should be a fairly straightforward change, and perfect for a beginner wanting to start contributing to OSS!

matt.fellows
2020-01-12 21:36
:pray:

dlmiddlecote
2020-01-12 23:39
has joined #pact-python

elliottmurray
2020-01-13 08:06
has joined #pact-python

bethskurrie
2020-01-13 08:55
@matthew.balvanz and @richard.jones, @elliottmurray is a (long standing, most excellent, and sadly, soon to be leaving :disappointed:) colleague from DiUS who is interested in making some python pact contributions. Doing some @ introductions so you'll know to keep an eye out for PRs and questions from him!

bethskurrie
2020-01-13 08:55
Matthew is one of the maintainers of the pact-python implementation, which wraps the Ruby CLI, and Richard is the maintainer of Pactman, which is an independent implementation that came out of Reece.

mokbat
2020-01-13 20:53
has joined #pact-python

dlmiddlecote
2020-01-16 17:34
Anyone available to review the above PR?

matt.fellows
2020-01-16 22:59
LGTM

matt.fellows
2020-01-16 22:59
As a non-Pythoner it?s exactly what I would have done. The code is very easy to comprehend

bethskurrie
2020-01-16 23:01
We may need @matthew.balvanz to do a release


bethskurrie
2020-01-16 23:02
Hm, though we may have permissions for that if he's not free, actually.

bethskurrie
2020-01-16 23:02
Nice docs, yeah, just read them.

matt.fellows
2020-01-16 23:02
I?ll give it a crack now

bethskurrie
2020-01-16 23:02
Nice work Matt B.

matt.fellows
2020-01-16 23:02
indeed

matt.fellows
2020-01-16 23:02
the code is very easy to understand too

matthew.balvanz
2020-01-16 23:10
Get things figured out? I?m on the road vacationing today but could check things out later tonight if needed.

matt.fellows
2020-01-16 23:10
I?ll let you know if I fail :slightly_smiling_face:

matt.fellows
2020-01-16 23:11
Enjoy your break!

matt.fellows
2020-01-16 23:14
Release should be on its way? :crossed_fingers:

matt.fellows
2020-01-16 23:17
#winning

elliottmurray
2020-01-17 00:45
Python guru!

matt.fellows
2020-01-17 00:59
More like the capability of a trained monkey

elliottmurray
2020-01-17 00:59
Your own worst critic!

matt.fellows
2020-01-17 01:00
Best to own that, then you can control the narrative

elliottmurray
2020-01-17 01:00
I?m English - self deprecation is a national past time

bethskurrie
2020-01-17 03:06
@dlmiddlecote @elliottmurray, David has started on pact message support, but has to put it aside for a few weeks while he works on other stuff. Mentioning it as it might be something one of you might be interested in picking up.

david.wang3
2020-01-17 03:07
this will allow you to construct a pact-message and create a pact-message file.. thats as far as I?ve gotten

david.wang3
2020-01-17 03:11
i?ve added a sample test case in the commit comments, you can take a look..

david.wang3
2020-01-17 03:14
additional work items to do is to pass in a event handler and then feed the messages to the handler?

elliottmurray
2020-01-19 20:38
There?s a dependency issue with older versions of python. I?ll look at it later

bethskurrie
2020-01-27 22:21
@matthew.balvanz I'd like to merge https://github.com/pact-foundation/pact-python/pull/106 if it's ok with you (sorry to ping you if you're still on holidays)

matthew.balvanz
2020-01-27 22:44
No worries. Taking a quick glance since I have a moment at work...

matthew.balvanz
2020-01-27 22:46
Looking good to me.

bethskurrie
2020-01-27 22:46
:thumbsup::skin-tone-3:

matthew.balvanz
2020-01-27 22:57
Did we want to get the proposed wording change about `broker_token`/`broker_password` in before merging (or am I missing where that change was made)?

elliottmurray
2020-01-29 00:58
I?ve had real problems re-creating the 27 problems for my changes so I?ve created a docker image to test (which now allows me to see my breaks) Any practices on how to contribute docker images? At the mo I?ve got a dockerfile under a docker folder

matthew.balvanz
2020-01-29 23:35
Is it something for devs to use locally or something you'd expect published to Docker Hub eventually? If it's just a local dev tool, the docker folder seems perfect.

elliottmurray
2020-01-30 05:24
mainly so you have local dev tools. Think I could eventually publish it to dockerhub though

elliottmurray
2020-01-30 05:24
Just a pain getting py27 working on a mac anymore

kulik.olenka
2020-02-07 20:57
has joined #pact-python

paul.white
2020-02-11 09:03
has joined #pact-python

ileshdarji
2020-02-11 11:29
has joined #pact-python

elliottmurray
2020-02-13 04:22
@bethskurrie @matt.fellows I think this is covered by my PR? What?s the process for merging?

bethskurrie
2020-02-13 05:59
If the tests are green and you're happy with it, I think we merge!

bethskurrie
2020-02-13 06:00
I'll see if @matthew.balvanz wants to have a squiz at it

matthew.balvanz
2020-02-13 14:20
Cold and snowy day here. With staying inside I'll try to work in some time today to look at PRs.

adrian.deanda
2020-02-13 15:57
has joined #pact-python

elliottmurray
2020-02-14 00:39
Thanks for the merges @matthew.balvanz

matt.fellows
2020-02-14 08:27
Where are you based again?

niciqy
2020-02-14 11:17
has joined #pact-python

matthew.balvanz
2020-02-14 14:44
Iowa, USA. Right about the middle. Dropped to -10F (-23C I think?) with a wind chill pushing it down toward -30F.

matt.fellows
2020-02-15 12:24
:grimacing:

matt.fellows
2020-02-17 23:47
thanks Beth

bethskurrie
2020-02-17 23:48
@matthew.balvanz a co-worker in aus needed the latest changes to the standalone, so I've taken the liberty of releasing.

bethskurrie
2020-02-17 23:48
Fingers crossed!

bethskurrie
2020-02-17 23:49
There is a bit of weirdness with that 0.20.0 commit going missing from Matt's machine (if it was ever there?). I pulled from the tag into master, so the history is a bit... strange... but the commits are there at least.

matthew.balvanz
2020-02-18 03:16
Thank you!

aorumbayev
2020-02-19 22:57
has joined #pact-python

aorumbayev
2020-02-19 22:59
Hi all, Could someone point out a reference/link to any issue related to v3 specs support? I'm specifically interested in async message contracts support (kafka and etc)

matthew.balvanz
2020-02-19 23:03
I think this is the original issue talking about adding v3 support: https://github.com/pact-foundation/pact-python/issues/88

aorumbayev
2020-02-19 23:12
Hey @david.wang3, looks lke your PR does the initial support for message contracts -> https://github.com/pact-foundation/pact-python/pull/119 . It seems like the travis failed on some basic formatting linting things, do you think this is gonna be merged anytime soon?

bheemreddy181
2020-02-20 04:00
has joined #pact-python

ckkinay
2020-02-26 09:36
has joined #pact-python

joel.whalen
2020-03-02 17:19
has joined #pact-python

osirisnos4a2
2020-03-03 23:51
has joined #pact-python

aaron
2020-03-09 21:35
has joined #pact-python

krosan
2020-03-21 19:29
has joined #pact-python

iamjillsanluis
2020-03-22 14:45
Good morning/afternoon/evening everyone. I hope all is staying safe and healthy. I was trying to get `pact-python` setup last night following the tutorial. As I was setting up the test on consumer side, running the test results in "cannot reach localhost:1234". I know the documentation mentions that the mock server should be reachable by the consumer, but something is not connecting to me. Is this mock server something that we (consumer side developers) have to implement? What I think makes sense to me of how it should work is, `pact-python` spins up a mock server for us when running the test, dumping the appropriate pact after test is run, then we take that pact and verify it against provider side. To spin up instances of mock service ourselves (consumer side) seems tedious/unnecessary. But please help me correct my mental model. This seems consistent with my mental model - https://docs.pact.io/pact_nirvana#2-spike-optional While missing in Python, here is related Ruby implementation of the step I am getting stuck on - https://docs.pact.io/implementation_guides/ruby#3-configure-the-mock-animal-service. In Ruby, seems like pact will spin up and manage that mock service for you and it will run it at host `localhost:1234`

iamjillsanluis
2020-03-22 18:03
alright, i am getting somewhere. I think I figured it out after trying my test in simpler environment (outside docker that is locked down) where ruby can freely spin up a mock server. I will poke around more to get this sorted out and find place to document how this can work for containerized environment that looks like my setup.

elliottmurray
2020-03-24 00:33
So running your consumer tests in a container should work. It is possibly a networking issue with your container struggling with either opening the port or resolving network address? Is there anything unusual with your setup?

matt.fellows
2020-03-24 00:52
Also confirming that you?ve read https://docs.pact.io/docker.

matt.fellows
2020-03-24 00:52
You?ll need to do a little more work if using Alpine

bethskurrie
2020-03-24 00:54
We have found that the underlying Ruby CLI for some reason takes a very long time to spin up on docker, especially when it's being run on a machine with not quite enough resources.

bethskurrie
2020-03-24 00:55
On a recent client, we almost got ot the stage where we ran our own dockerized mock service from `pactfoundation/pact-cli`

bethskurrie
2020-03-24 00:55
For some reason, that one runs perfectly quickly

iamjillsanluis
2020-03-24 01:19
The issue was different things for me: Alpine uses sh instead of bash by default. I managed to figure it out by digging in the guts of the packaged ruby starter scripts. The second issue was the missing APK installs that I found from the past issues. I would like to contribute to documenting this, but not sure where I should. I'm not sure if there is "get started section" this can be added or more appropriate place. Would be happy to document this if I was pointed to right place to do so. Maybe like python guide, kind of like it is done in ruby/java and I believe JS.

iamjillsanluis
2020-03-24 01:21
Interesting findings on slowness. I'm seeing myself spending my weekends getting the full set up in next coming weeks. If there is anything I can help with, would be happy to chip in.

elliottmurray
2020-03-24 01:22
I had a wip in looking at some of dockerizing for python - let me try and dig it out

bethskurrie
2020-03-24 01:22
Most of the scripts should be able to be converted to sh

bethskurrie
2020-03-24 01:23
there's an open issue for it if you're interested in looking at it

bethskurrie
2020-03-24 01:23
You'd need ruby 2.2 installed, but you don't really need to know ruby much.

matt.fellows
2020-03-24 01:25
Those issues / needs are discussed at Also confirming that you?ve read https://docs.pact.io/docker. but I understand that isn?t immediately visible in the Python page

matt.fellows
2020-03-24 01:25
Perhaps just a link from the repo?

elliottmurray
2020-03-24 01:25
I started working on some dockerfiles but now I remember - was for building pact-python not for using it. Though I?m sure they could be re-purposed. There is a python2.7 example docker file under the cryptic docker dir

iamjillsanluis
2020-03-24 01:26
im cool with ruby. i love ruby but i do python in my full time job. :slightly_smiling_face: If you can link the issue my way, i can check it out :slightly_smiling_face:

bethskurrie
2020-03-24 01:27
Ruby/Python - they're the same fam


elliottmurray
2020-03-24 01:27
Like siblings

iamjillsanluis
2020-03-24 01:27
i think this weekend, ill clean up my sample project a bit. I will also read the other lang?s guide maybe pattern the python guide close to those.

bethskurrie
2020-03-24 01:28
The complication is that Travelling Ruby, which is the tool we use to package the Ruby into the standalone CLI, does have some bash files I think.

bethskurrie
2020-03-24 01:28
We'd need to make our own versions and copy them over the bash ones.

bethskurrie
2020-03-24 01:28
Something to be aware of is that we're planning on retiring the standalone and moving to a shared rust impl which will be called via FFI bindings.

iamjillsanluis
2020-03-24 01:29
curious how much does bash actually add to image. if it is negligible, maybe just doing `apk add bash` is not too bad. This way we don?t have to play with the packager you were talking about.

bethskurrie
2020-03-24 01:29
I don't know what the timeline will be for that though. We're working on js at the moment but it's going to depend on who's available to pick it up for python.

iamjillsanluis
2020-03-24 01:29
> retiring ruby oh. i see

bethskurrie
2020-03-24 01:29
So it may or may not be worth the work to remove the bash dependency, and it's one of the reasons I hadn't picked it up.

elliottmurray
2020-03-24 01:29
Have you thought about your own pact alpine image @bethskurrie? It?s pretty easy to setup

iamjillsanluis
2020-03-24 01:29
i?d be interested in code reviewing the js impl and see how it goes for the python

bethskurrie
2020-03-24 01:29
It's already made

bethskurrie
2020-03-24 01:30
pactfoundation/pact-cli

bethskurrie
2020-03-24 01:30
it runs like a breeze.

bethskurrie
2020-03-24 01:30
it's the standalone that runs with the packaged Ruby 2.2 that seems to run like a dog on docker.

iamjillsanluis
2020-03-24 01:31


bethskurrie
2020-03-24 01:31
docker doesn't allow dashes in org names

elliottmurray
2020-03-24 01:32
ah yep - so you publish that to dockerhub?

elliottmurray
2020-03-24 01:35
also I might have a go at that later in the week - you can probably use multi stage bulids now

bethskurrie
2020-03-24 01:35
yes

bethskurrie
2020-03-24 01:35
its `pactfoundation/pact-cli`

iamjillsanluis
2020-03-24 01:37
so just to summarize the general direction the workflow you guys imagine for people building their CI is, when python contract tests from consumer are being run, developers would need an external container (`pactfoundation/pact-cli`) that runs alongside that the tests use for the standalone mock server. _My statement is only covering consumer right now because I haven?t gotten to the verification on the provider side yet._

bethskurrie
2020-03-24 01:38
It's not currently supported, but would be easy to do if the current way was not working for you.

bethskurrie
2020-03-24 01:39
It would just be an extra flag for the python code not to start up/shut down the mock service, and you'd be responsible for managing the docker mock service container.

bethskurrie
2020-03-24 01:40
The ruby impl allows you to manage your own mock service.

matt.fellows
2020-03-24 01:40
> the workflow you guys imagine for people building their CI is, when python contract tests from consumer are being run, developers would need an external container (pactfoundation/pact-cli) that runs alongside that the tests use for the standalone mock server. No. I think that?s the _less ideal_ flow. Ideally, it?s all wrapped up and happens automatically.

bethskurrie
2020-03-24 01:40
So the code already exists.

bethskurrie
2020-03-24 01:40
It would make *your* code a bit more complicated, but that's a trade off you might be willing to make if it wasn't working for you the normal way.

iamjillsanluis
2020-03-24 01:42
It is currently working now in current way after applying my fixes. So I guess I can continue doing that. I am not blocked at the moment. Just generally curious what is the direction of things/vision of how you guys see others integrating this in their CI

iamjillsanluis
2020-03-24 01:42
> No. I think that?s the _less ideal_ flow. Ideally, it?s all wrapped up and happens automatically. Seems like it is like we (users of pact) should not see changes and it is all under the hood.

bethskurrie
2020-03-24 01:42
medium term, we'll be doing away with the pact-ruby-standalone, so you shouldn't need bash

bethskurrie
2020-03-24 01:43
Ideally, the interface doesn't change, yes.

iamjillsanluis
2020-03-24 01:44
thanks for all the guidance.

christian.roepke
2020-03-24 07:47
has joined #pact-python

christian.roepke
2020-03-24 09:17
Hey everyone, good to be here! I?m relatively new to Pact and currently struggling to understand how inside my Python repository Pact `state` is kept. I wanted to simply change the names of the provider and consumer but even when deleting the cache, existing pact-JSON and re-setting the virtual env the ?old? pact keeps showing up when I execute my test with `pytest`. Is there anything that I?m missing? :thinking_face:

bethskurrie
2020-03-24 09:18
Is your mock service definitely shutting down?

bethskurrie
2020-03-24 09:19
Do a `ps -ef` and see if you can see a ruby process running.

bethskurrie
2020-03-24 09:20
The names should come from the pact set up config.

christian.roepke
2020-03-24 09:24
that was the problem!

christian.roepke
2020-03-24 09:25
i didn?t fully understand that in the background ruby is used, thanks so much!


bethskurrie
2020-03-24 09:28
We're hoping to get rid of it, but it's been a long time coming.

matt.fellows
2020-03-24 10:34
we should add a general ?debugging? section to most of our DSL if they don?t have already, to indicate this

matt.fellows
2020-03-24 10:34
> i didn?t fully understand that in the background ruby is used, thanks so much! That?s kind of intended, because you shouldn?t have to know. But you need to know when you need to know :slightly_smiling_face:

matt.fellows
2020-03-24 21:49
@mukheem you should ask your Python questions here

mukheem
2020-03-24 21:49
has joined #pact-python

mukheem
2020-03-24 21:50
Thanks @matt.fellows :slightly_smiling_face:

matt.fellows
2020-03-24 21:50
The reason it?s best to ask here, is that each language has its own nuances - there are general concepts (which http://docs.pact.io aims to teach) but languages have a way of wanting to do things differently

matt.fellows
2020-03-24 21:51
Does the example in the pact-python repository not work?

mukheem
2020-03-24 21:56
Unfortunately No.

mukheem
2020-03-24 22:09
I just went thru those animation slides and I am a bit more clear now.

mukheem
2020-03-24 22:09
Thanks Beth

mukheem
2020-03-24 22:44
Can i be helped in Simulating a PACT consumer server to hit Real HTTP server. Apparently, this code which is driving me skeptical. Question is live_server.url points to which server > -> Real world HTTP server or Simulating one ? Also, Why are we creating User when If condition is true. [ I never worked with Django earlier, so I have no idea ]

bethskurrie
2020-03-24 22:45
@mukheem do you mind if I ask if you're a developer or a tester?

mukheem
2020-03-24 22:47
I am an Automation Tester Beth. :neutral_face:

bethskurrie
2020-03-24 22:49
That'll help then! Pact requires a good knowledge of coding, and of the underlying provider and consumer implementations, so testers who have not coded much before often struggle.

bethskurrie
2020-03-24 22:50
As an automation tester, you may or may not be familiar with the web frameworks that each of the projects use, as often automation testers work from the "outside" of each service, being able to treat each service as a black box.

bethskurrie
2020-03-24 22:51
In this case, it is often beneficial for a tester and developer to pair together when setting up Pact.

bethskurrie
2020-03-24 22:52
The Pact maintainers cannot help you with web framework questions unfortunately. If you don't have experience in this area, is there a developer in your organisation who you can pair with?

mukheem
2020-03-24 22:53
Not Python Developers.(Unfortunately). Else i would have reached to them rather bothering you :white_frowning_face:

matthew.balvanz
2020-03-25 13:27
My hunch is that Django is loading the project configuration from disk in this context, which is verifying against a live Django server that is running locally with the same configuration. That means this code can reach into the database that the "live server" is also connected to and modify state so the database has any required data for the pact being verified. Having the code to manipulate the database mixed with the code to verify the pacts is a little unusual. Most of the other Pact implementations have the provider state logic built into the live server and HTTP requests are made to the a provider state endpoint on the service prior to the pact request.

mukheem
2020-03-25 14:42
Thanks @matthew.balvanz for helping me. I did raise a Server in Flask(by going thru a few tutorials). Now I'm in need to know how can I verify my PACT against provider. Now, I totally understood that the example stated in Documentation is not how most of the audience implement it.

mukheem
2020-03-25 16:44
Can someone help me in getting Pact provider Verification (PACT replayed against it's real server) please.

mukheem
2020-03-27 09:41
Can someone help me in letting me know ```pact_verifier``` fixture pls

mukheem
2020-03-27 11:49
it'd be really helpful if someone can corect me where i went wrong here

matt.fellows
2020-03-27 12:14
What is the problem you?re having. Please post logs, more context etc.

matt.fellows
2020-03-27 12:16
Assuming you are starting a local server on port `8081` and `8082` ? Is there are reason you have 2 servers (it?s OK, just want to make sure that?s what you?re intending)

mukheem
2020-03-27 13:09
Thanks Matt for responding. 8081 is my Live server.[Now my real application is turned down due to Epidemic so created one dummy on local machine to use it as real server] 8082 is my Provider states server. I wanted to make sure am i passingthe right parameters. There is no clear documentation to understand this. Unless it is clear what needs to be passed, mytest won't run succeed. Let me know if you want to see any logs

mukheem
2020-03-27 13:09
Regarding Context: I am trying to test PAC on provider side. and for that purpose I am using Pact_verifier.

elliottmurray
2020-03-27 16:38
So looking at pact-python is the provider only supporting the uri provider states? I take it no way (that I can see) to do what you have in ruby where you can actually write code? Is there a good example of python doing providers generally? Or is that a ?todo??

matt.fellows
2020-03-28 03:20
The parameters for provider states are defined at https://github.com/pact-foundation/pact-python#--provider-states-setup-url. There are just two properties that are passed in: the consumer name, and the state name

matt.fellows
2020-03-28 03:21
Your provide state setup URL needs to parse this, and decide what to do. For example, if the state is ?User A exists? then it may need to create a User in the database

matt.fellows
2020-03-28 03:21
no, this is a TODO from what I can see

matt.fellows
2020-03-28 03:23
The way it works in JS/Go for example, is that I actually spin up a proxy server that takes the provider state functions from the test (and similar features such as request filters) as arguments, and behind the scenes maps to HTTP endpoints for the verifier to call. When the setup endpoint is called, it simply invokes the functions passed in. This way, it appears to the user that it?s just invoking the function instead of all of the rigmarole / confusion of the endpoint

mukheem
2020-03-28 03:24
@matt.fellows I succeeded in executing thru command line and the result is as expected. [ Tested both positive and negative scenarios ] `pactman-verifier -l C:\Users\****\PycharmProjects\pact-python-master\Pact\ConsumerPOC-Provider-pact.json Provider http://localhost:8081/` `http://localhost:8082/setup`

matt.fellows
2020-03-28 03:25
I believe the docs on the Github page could be updated to make the provider side testing clearer - I?m supposing you?re supposed to just call the verifier CLI directly, but would be much nicer if Pact Python wrapped all that for the user

matt.fellows
2020-03-28 03:25
So I can see the confusion

matt.fellows
2020-03-28 03:25
Awesome!

mukheem
2020-03-28 03:25
now what i don't understand is which method is to be called to do it via code when i have n number of pacts. In the above SS, I tried using Pact_verify but i don't undersdtand what it accepts and how itexecuted..

matt.fellows
2020-03-28 03:30
You would usually publish pacts to a Pact Broker (there is an Open Source one and http://pactflow.io if you don?t want to host yourself) and then you can simply point the verifier at the broker - it will find all pacts for a provider and verify them


mukheem
2020-03-28 03:32
Yes @matt.fellows . i read that in documentation. But my organization has it's compliance not to expose things to out side world. Hence we would be hosting it internally or might be using a shared folder. That's where i am stuck. :white_frowning_face:

matt.fellows
2020-03-28 03:32
I would not go down the shared folder path.

matt.fellows
2020-03-28 03:33
You could check the contracts into github, and create your own script to pull down from known consumers

matt.fellows
2020-03-28 03:33
But really, just run the Pact Broker somewhere

matt.fellows
2020-03-28 03:33
If you can?t use a hosted provider that?s no problem, you?ll need to host it yourself is all

mukheem
2020-03-28 03:35
Got it. Say, We have hosted our own server to handle this stuff... Can you help me with the pytest method which helps me in taking the inputs from http://XYZ.com url and verify my pacts

matt.fellows
2020-03-28 03:35
I don?t know pyest I?m afraid

mukheem
2020-03-28 03:36
Any python method which i can use to pull this situation.

matt.fellows
2020-03-28 03:36
The help command will tell you all of the arguments `pact-provider-verifier help`

matt.fellows
2020-03-28 03:36
I don?t know Python that well so I won?t recommend anything there, but the command you have to call is the same (what?s shown above)

matt.fellows
2020-03-28 03:37
These are the general steps though: 1. Start your provider (and provider states server if that?s different) 2. Run the verifier, specifying how to reach your provider, and where to fetch the pacts 3. Check the exit code and print any errors

matt.fellows
2020-03-28 03:38
I?m afraid I can?t teach you anything with Python, you probably know more than me!

mukheem
2020-03-28 03:38
Start your provider --> This means Provider live server. .Am i right ?

matt.fellows
2020-03-28 03:39
It?s a real server, yes. When you run a consumer test, Pact mocks the provider. You?re testing the real consumer. When you run a provider tests, Pact pretends to be the consumer. You?re testing the real provider. The whole point of pact/contract-testing is to avoid testing both sides at the same time.

mukheem
2020-03-28 03:41
Yes. Got it. Thanks a lot @matt.fellows for taking out your precious time for me and explaining things. I'm indeed very grateful to you. It would have been really amazing if any puthon guy have turned up to answer. That's okay I will put it on github. Hopefully someone will answer.

matt.fellows
2020-03-28 03:42
no probs!

matt.fellows
2020-03-28 03:42
Things have been pretty quiet over the past few weeks.

mukheem
2020-03-28 03:44
Yeah. due to Pandemic. I understand, but being a software engineer, we are expected to work from Home as this is the only industry which has that flexibility to it's fullest. I am expected to submit it by Monday. Hoping for the best. :slightly_smiling_face:

mukheem
2020-03-28 03:49
Yes @matt.fellows.Actually we need that documentation to be updated so that audience could feel free to implement on their own servers. When CLI gives that flexibility code should also be giving that freedom.

mukheem
2020-03-28 03:50
i understood concepts by going thru documentation provided in js, Golang, ruby, it is pretty clear and easy to understand. I was wondering why python documentation is left that way. :neutral_face:

mukheem
2020-03-28 04:10
Just one more question @matt.fellows. when you say `Your provide state setup URL needs to parse this, and decide what to do. For example, if the state is "User A exists" then it may need to create a User in the database` For post/patch requests, I presume that the value returned by our provider state setup would be directly injected to request being sent in provider URL. is my understanding correct ?

matt.fellows
2020-03-28 04:15
No. the provider state is a request that is issued to the provider to get the _provider_ into a state, so that the interaction will work as expected

matt.fellows
2020-03-28 04:15
The response mody from the setup URL is completely discarded by the verifier. It just needs to know it was setup correctly (e.g. a `200`)

matt.fellows
2020-03-28 04:15
The state is independent of the type of request `GET` or `POST` etc.

mukheem
2020-03-28 04:16
If this the case, then hoe can i test my `post`requests ?

matt.fellows
2020-03-28 04:17
I'm not following the problem sorry.

mukheem
2020-03-28 04:17
Okay let me put it in another way

mukheem
2020-03-28 04:21
The example i did try and succeeded is a `get` request. My interaction says that it is a `get` request with path /api.[ I shall send you a SS later to this message ] so My Provider test also hits the live server with a `get` request to the path /api. Now, If my interaction is for `post` which takes a parameter say `employee id` as input to fetch details of that employee, then how that `employee id` is fed to the Provider while testing against a Live server

mukheem
2020-03-28 04:22
Here is my Pact for a get request

matt.fellows
2020-03-28 04:39
what is the post doing? Does it need the employee id to do something to that user?

matt.fellows
2020-03-28 04:40
If so, `employee id` is the state - e.g. you may need to use the state to ensure it exists so that your `POST` will work with that ID

mukheem
2020-03-28 04:41
Yes, Employeed Id is used by the request to fetch all the employees details.

mukheem
2020-03-28 04:42
I got your answer. But How does my post request on provider side understand that Empoyee X's details should be fetched. ?

mukheem
2020-03-28 04:43
I shall set up state saying that Employee X should be present. But Question is how will my request get that data during post. the value X . Because Provider state response is completely discarded by the Provider.

mukheem
2020-03-28 04:45
If not, I could fetch any employee id from DB during run time in setup state and return it to the provider so that i can post the request with that ID fetched from DB

matt.fellows
2020-03-28 04:45
You need to be able to control the id. Another option is to have a data fixture that you load where that ID is always present

mukheem
2020-03-28 04:48
let me check what data fixture is and how does it work. Thanks a lot @matt.fellows :pray:

matt.fellows
2020-03-28 05:35
What you're describing actually does exist in pact, but is only supported in JVM and Rust

matt.fellows
2020-03-28 05:35
(sorry didn't hit enter earlier)

matt.fellows
2020-03-28 05:37
What I mean by data fixture is to have something like an SQL script that will reliably create/setup a database with the same IDs etc each run. This way you don't even need to use states feature (although you should still document the states) to set things up

matt.fellows
2020-03-28 05:37
You could then use tools like docker compose to start your API with data already loaded

mukheem
2020-03-28 05:40
Alright. thanks for clearing smoke @matt.fellows

mukheem
2020-03-28 05:41
Any idea who owns/responsible for pact-python version ?

matt.fellows
2020-03-28 06:44
Yes. The maintainers hang in this channel and you can see on GitHub. Please refrain from DM ing people though

elliottmurray
2020-03-28 07:48
I?ll have a deeper look today. See what I come up with

mukheem
2020-03-28 12:31
Hey everyone, My test is failing during Provider verification when the route is not root. Command I am using is `pactman-verifier -l C:\Users\****\PycharmProjects\pact-python-master\Pact\ConsumerPOC-Provider-pact.json Provider http://localhost:8081` `http://localhost:8082/setup` where `http://localhost:8081` is my provider base url. There are two methods one is `/api` which is root route and the other one is `/api/users`. each time i run the verifier, it is hitting only root but not the `/api/users` I have two different pacts one with path `/api` and another one with `/api/users`. First pact is being verified with no issues but the second is always failing. Any help is really approciated.

elliottmurray
2020-03-28 17:56
Why do you have the proxy server in verifier.ts? I see you are setting up filters and states - is that it? Could you do it without a proxy?

elliottmurray
2020-03-28 17:56
And is this right?

elliottmurray
2020-03-28 17:58
Shouldn?t providerBaseUrl point to the proxy you set up in the provider.ts?

matt.fellows
2020-03-29 09:48
I don't believe I could do it without a proxy, because the provider states endpoint still needs to exist. Also, you can't do filters on the request if you don't have one - Ruby doesn't support it but if even if it did, it would be a native experience - so we're back to making the user do it

matt.fellows
2020-03-29 09:48
Also the proxy is completely hidden from the user

matt.fellows
2020-03-29 09:49
The framework does all of that magic behind the scenes

matt.fellows
2020-03-29 09:49
Can do a call or take you through it this week if you want?

elliottmurray
2020-03-29 09:50
Could you have monkey patched requests? I think I get the principle having looked at the code. Just want to make I got it all in my head!

elliottmurray
2020-03-29 09:50
Possibly - back in England now though!

elliottmurray
2020-03-29 09:50
I was a bit confused about the exmaple in the code snippet though - is it correct? Looks like it doesn?t go to the proxy but I?m obviously missing something

matt.fellows
2020-03-29 09:50
You probably could if it's running in the same process, but that's nit always the case

matt.fellows
2020-03-29 09:51
(a lot of people point pact at running staging environments - for better or for worse)

elliottmurray
2020-03-29 09:51
oh

elliottmurray
2020-03-29 09:51
yeah that?s? interesting

matt.fellows
2020-03-29 09:52
I spend a few nights a week talking to someone in Germany or England. I'm sure I could make time for you Elliot!

elliottmurray
2020-03-29 09:52
haha

matt.fellows
2020-03-29 09:52
This being said, I do need to run. Just put #1 down but need to set my wife up on a zoom call with her friends lol

elliottmurray
2020-03-29 09:52
well I?m gloriously unemployed so will work to your schedule!

matt.fellows
2020-03-29 09:52
And then... The cleanup

elliottmurray
2020-03-29 09:53
lol

elliottmurray
2020-03-29 09:53
sure - more important than chatting to me!

matt.fellows
2020-03-29 09:53
This is what happens when you leave DiUS :laughing:

matt.fellows
2020-03-29 11:25
I thought you were using `pact-python`?

matt.fellows
2020-03-29 11:25
Can you please share your pact file?

mukheem
2020-03-29 11:40
Apologies. I just figured out the issue. I was wrong in providing the path in pact.

mukheem
2020-03-29 11:40
thanks @matt.fellows

mukheem
2020-04-01 07:23
Hello everyone. During Provider verification test, Is there any way I can supply data dynamically to Provider as Input ? I know that provider states help us in laying the data setup ready. But what if my request body needs data ? How can i supply data to my request during POST or PATCH ?

matt.fellows
2020-04-01 11:45
Not that I'm aware of in Python @mukheem

matt.fellows
2020-04-01 11:46
It exists only in JVM and Rust at the moment. You can usually work around it though using provider states and better control over your API

mukheem
2020-04-01 14:39
That's okay @matt.fellows. I just wanted to know where i can incorporate as per the architecture of PACT. I will manage with my own code in python.

mukheem
2020-04-01 14:42
There are cases where we supply data by pulling from DB or by fetching value from 3rd party api , where can i put in the related DB Queries so that the output could be easily injected to provider before hitting live URL.

matt.fellows
2020-04-01 21:43
Are you talking about Pact having access to this data, and pact using this data to send the request to the provider? Or are you asking that the provider itself have access to this data? The former is not a feature in Python but the latter is provider states

matt.fellows
2020-04-01 21:43
Also, during pact tests you would typically mock or stub out 3rd party systems (and create pacts between them)

matt.fellows
2020-04-01 21:43
This way you control the data

mukheem
2020-04-02 05:03
Honestly @matt.fellows, Either of the above would suffice my need. So let's talk about the latter feature which is present in Python pact

mukheem
2020-04-02 05:04
How would my provider state define the data which is to be passed in the request hit to the provider(live server) ?

mukheem
2020-04-02 05:05
Because the response from Provider state is completely discarded. :neutral_face:

matt.fellows
2020-04-02 05:12
The state would be something like ?User with ID xyz exists?. The state handler would see this state, and create a record in the database with the ID `xyz`. Then when the real request comes through just after this is setup, `xyz` will exist and it should work. I think you?re trying to say that the test has value `xyz` but it needs to dynamically change to `123` because you can?t control that `xyz` can be created

mukheem
2020-04-02 05:20
yes, the latter is true. I wanted mostly data fetching and in few cases data updating. but not creation.

matt.fellows
2020-04-02 05:21
Pact is not designed that way. It?s designed to get away from that problem - where you have to orchestrate a bunch of calls (e.g. create user, get the id back, query get user) just to test `GET /user` type thing. Provider states are the means to do this sort of testing

mukheem
2020-04-02 05:22
I mean, In Provider state if i write a DB query to fetch a record and that value is to be used as body in Provider Request..!!! Is this possible in PACT now ?

matt.fellows
2020-04-02 05:22
You use the state to setup the test - think of it like the ?setup? step of your ?setup, do, assert? unit tests

matt.fellows
2020-04-02 05:22
> I mean, In Provider state if i write a DB query to fetch a record and that value is to be used as body in Provider Request..!!! Is this possible in PACT now ? No

matt.fellows
2020-04-02 05:23
Pact JVM has a facility like this, but for edge cases. It?s not in the other languages I?m afraid

mukheem
2020-04-02 05:24
Okay thanks @matt.fellows for your time. You have been very good help each time. with your Crisp answers. Thanks a lot. :slightly_smiling_face:

matt.fellows
2020-04-02 05:24
:slightly_smiling_face:

matt.fellows
2020-04-02 05:24
no worries

mukheem
2020-04-02 05:24
If I am interested, I can also join in the PACT development right ?

matt.fellows
2020-04-02 05:25
I know it?s a very different mindset, it does take a little bit of time to fully appreciate the different way of doing itall - but once you do, it will pay off I promise!

matt.fellows
2020-04-02 05:25
of course!

mukheem
2020-04-02 05:25
Yaay Let me think about it .. :slightly_smiling_face:

lbraymusso
2020-04-02 05:43
has joined #pact-python

noel.chin
2020-04-02 14:43
has joined #pact-python

noel.chin
2020-04-02 14:46
```FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.8/site-packages/pact/bin/pact/bin/pact-provider-verifier'```

noel.chin
2020-04-02 14:46
anyone encountered this area? is it an install issue?

elliottmurray
2020-04-02 14:53
Have you created a virtualenv and installed pact-python into that?

noel.chin
2020-04-02 14:55
Im not super familiar with python as I am new to the team but pact-python was installed in a docker container

noel.chin
2020-04-02 14:55
Sorry if this isn't the right response to your question

elliottmurray
2020-04-02 14:56
So pip list and you can see pact-python installed in the output?

noel.chin
2020-04-02 14:59
yup I see it installed

elliottmurray
2020-04-02 15:00
and how did you get that error?

elliottmurray
2020-04-02 15:00
pact-verifer?

noel.chin
2020-04-02 15:00
yeah running the verifier via cli

elliottmurray
2020-04-02 15:01
hmm it seems the install didn?t work - the python here is a wrapper around the ruby cli tool afaik

noel.chin
2020-04-02 15:01
give it the good old uninstall reinstall?

elliottmurray
2020-04-02 15:01
sure

elliottmurray
2020-04-02 15:01
and check the logs on install

elliottmurray
2020-04-02 15:01
so pip uninstall pact-python

elliottmurray
2020-04-02 15:02
why are you using a docker container for this?

noel.chin
2020-04-02 15:02
this is to be run in our ci

elliottmurray
2020-04-02 15:03
so if you just want to run the cli I think you might just be able to run it direct. Not sure on your context

noel.chin
2020-04-02 15:04
it was just a quick check (why I am using the cli)

elliottmurray
2020-04-02 15:04
So that thing you are running wraps this thing:


elliottmurray
2020-04-02 15:05
Which I think is


noel.chin
2020-04-02 15:05
Thanks for all the help Elliott

elliottmurray
2020-04-02 15:05
:+1:

noel.chin
2020-04-02 15:17
I can see that the file exists if I navigate to it

noel.chin
2020-04-02 15:17
so I am confused as to why it can't find it

elliottmurray
2020-04-02 17:20
Permissions?

elliottmurray
2020-04-02 17:21
Assume you are doing this all in the container itself

christopher.richard
2020-04-02 17:47
has joined #pact-python

matt.fellows
2020-04-02 21:54
Are you using Alpine Linux? Either way, Check http://docs.pact.io and read the section on docker and Alpine.

matt.fellows
2020-04-02 21:54
You might be missing one of more key dependencies in the container runtime

christopher.richard
2020-04-03 12:32
Hi everyone! @noel.chin and I figured it out. We were missing some dependencies in our docker-alpine runtime. https://docs.pact.io/docker#alpine-linux ^^ That helped :slightly_smiling_face:

iamjillsanluis
2020-04-03 12:59
nice to see you here @christopher.richard :smile:

christopher.richard
2020-04-03 13:00
Thank you!! @noel.chin and I are working on a POC of PACT for our org. My god is this toolset ever powerful

iamjillsanluis
2020-04-03 14:10
yep! we are bringing it in FreshBooks too. :slightly_smiling_face:

christopher.richard
2020-04-03 14:20
That's awesome!

christopher.richard
2020-04-03 14:20
Even without QAs you guys are still building good test systems :joy:

elliottmurray
2020-04-03 16:13
@bethskurrie @matt.fellows not sure whom I should be directing PR?s to for this repo but created a couple. This one was to help people get started (and also for me to understand all the bits!)

elliottmurray
2020-04-03 16:16
bah - breaking tests. Have to do some configuration first

elliottmurray
2020-04-03 16:24
fixed

matt.fellows
2020-04-03 22:17
Thanks Elliot. Feel free to include us on it, but @matthew.balvanz is the core maintainer. If you keep up the contributions I?m sure Matt would happily have another core maintainer on the list

matt.fellows
2020-04-03 22:17
What is clear is that pactman is a nicer experience, but it?s a) not built in a way that aligns with the long term Pact roadmap and b) is (basically) unsupported

matt.fellows
2020-04-03 22:17
so investing in Pact Python and the Rust lib is our goal

elliottmurray
2020-04-04 09:32
Thanks for the feedback. I kind of agree with reference to pactman though am taking inspiration from it

elliottmurray
2020-04-04 09:33
I?ll get some of your pr comments done over the weekend

bethskurrie
2020-04-04 09:34
Ideally whatever the implementation ends up looking like, it would be nice for it to be able to integrate with the python testing libraries like pactman does.

elliottmurray
2020-04-04 09:35
Pact python works with pytest. Pactman is using nosetest which I?ve had to learn about!

bethskurrie
2020-04-04 09:37
The ability to be able to mock things in the process using the test libraries would be great. Ruby does the verification using a Rack interface, rather than a running process, so it means that it runs really quickly and you can stub stuff out using the normal rspec methods.

elliottmurray
2020-04-04 09:37
Ah I see

elliottmurray
2020-04-04 09:38
Hmmm. That is a stretch for my current Python skills!

bethskurrie
2020-04-04 09:38
Not sure if there's a similar http interface for python or not.

elliottmurray
2020-04-04 09:40
I don?t think so. Forgot about the power of rack... I think you can bring Flask up easily but I?ll have to research a bit more

bethskurrie
2020-04-04 09:43
Ron and Matt have to put up with me raving about how good rack is quite often :-P

elliottmurray
2020-04-09 16:12
any news on my PR?s?

matthew.balvanz
2020-04-09 16:56
I've got a lighter load at work this afternoon. I'll see if I can work some time in to review those.

simon.nizov
2020-04-15 18:22
Hi all, A few months ago in a discussion here with @bethskurrie I asked about stubbing requests to 3rd party services (during pact verification) that are recorded with VCR. I finally got around to implementing this so let me shamelessly plug it :slightly_smiling_face: It?s a little tool that allows you to set up a live HTTP stub server that replays previously recorded VCR cassettes - basically `pact-stub-service` but for VCR. https://github.com/thatguysimon/vcr-stub-server I?m posting it here and not in #general because it currently only supports VCR cassettes generated by `VCR.py` but I figured it might be useful to some of the people here who use python. Cheers.

matt.fellows
2020-04-15 23:24
Awesome Simon!

matt.fellows
2020-04-15 23:25
I think I was in that convo, that sounds useful

matt.fellows
2020-04-15 23:25
> Unfortunately, there is no one standard for cassette YAML files, each VCR implementation is different grr yes! One of the reasons I never created a POC for it in JS land!

matt.fellows
2020-04-15 23:26
Because if it _was_ a standard, we could integrate into the pact ecosystem much better - that?s the benefit of a specification people!!

bethskurrie
2020-04-15 23:27
Very cool Simon!

jayeshdalal7
2020-04-19 12:29
has joined #pact-python

pravera
2020-04-20 14:47
has joined #pact-python

maciej.olko
2020-04-29 17:50
has joined #pact-python

malex.y
2020-04-30 20:19
has joined #pact-python

kaypee90
2020-05-01 00:18
has joined #pact-python

ajinkya.pande
2020-05-05 09:50
has joined #pact-python

ajinkya.pande
2020-05-05 09:51
Hello, a simple question does pact supports async testcases?

bethskurrie
2020-05-05 09:52
Yes, but it depends on which implementation you're using as to whether it's supported or not.

bethskurrie
2020-05-05 09:52
I assume you mean async message rather than HTTP websockets?

ajinkya.pande
2020-05-05 09:58
Actually , my test is running forever. I am using pytest for writing test cases. If i use *await async* then it is never-ending. But in case of eventloop fixture after terminating tests contract is generated. ```def test_get_projects(pact, client, event_loop): expected = json.load(open('qws_get_proj_resp.json')) (pact .given('Projects exists') .upon_receiving('a get projects request') .with_request('get', '/rest/projects') .will_respond_with(200, body=expected)) with pact: response = event_loop.run_until_complete(client.fetch('/rest/projects',method='GET')) print("Here after ") ```

bethskurrie
2020-05-05 09:59
Hm. I don

ajinkya.pande
2020-05-05 09:59
in fetch method getting stuck at this `response = await AsyncHTTPClient().fetch(http_request)`

bethskurrie
2020-05-05 09:59
I don't know. You'll need a python developer (which I am not) to help you there.

ajinkya.pande
2020-05-05 10:06
yes. thanks for replying. I hope someone will look into this.

nhodaly
2020-05-05 18:40
has joined #pact-python

pyasi
2020-05-08 13:47
has joined #pact-python

matt.fellows
2020-05-10 23:56
:clap: thanks Elliot!

elliottmurray
2020-05-11 10:28
:bow:

elliottmurray
2020-05-11 10:28
I?ll finish up one last merge later today or tomorrow and do my first proper release then.

matt.fellows
2020-05-11 10:29
Just don?t do what I did and remove the tag :wink:

elliottmurray
2020-05-11 10:29
git tag?

matt.fellows
2020-05-11 12:19
last time I performed a release, for whatever reason, I did the release, but we lost the tag attached to the release. So it was just _missing_ from git

matt.fellows
2020-05-11 12:19
strange, because from memory the tag is how we create the release!

elliottmurray
2020-05-11 12:48
lol - ok thanks for the heads up

elliottmurray
2020-05-11 15:58
Maybe someone wants to double check for me. But I can see it has been published to pypi (https://pypi.org/project/pact-python/)

pyasi
2020-05-11 17:59
It has indeed

matthew.balvanz
2020-05-11 18:59
Thanks for getting those PRs sorted @elliottmurray! Real life has kept me away for too long.

matt.fellows
2020-05-11 22:55
Man, how much does RL just get in the way of OSS. It's almost as if it matters more! :laughing:

elliottmurray
2020-05-12 06:19
I have pushed some docker files in the last release that might help in future. Initially more for me so I don?t have to install 5 versions of python but they might be useful

pyasi
2020-05-14 03:21
Hey! I really like the https://github.com/pact-foundation/pact-go#match-common-formats functionality in Go. I was thinking about implementing it in the pact-python- seems like an easy enough feature that could be helpful. If agreed, what do you think of this approach in `matchers.py` ```class Format: def __init__(self): self.ip_address = self.ip_address() def ip_address(self): return Term(self.Regexes.ip_address.value, '127.0.0.1') class Regexes(Enum): ip_address = '(\d{1,3}\.)+\d{1,3}'```

bethskurrie
2020-05-14 03:22
Sounds goof.

bethskurrie
2020-05-14 03:22
Good even.

pyasi
2020-05-14 03:22
I prefer goof.

bethskurrie
2020-05-14 03:22
Very goof then.

pyasi
2020-05-14 03:23
This would result in usage like this, if we?re okay with that. ``` expected = { 'username': 'UserA', 'ip': Format().ip_address, }```

bethskurrie
2020-05-14 03:28
:+1:

pyasi
2020-05-15 00:37
So my failure for the PR above is due to enum not being in the std lib for python2.7. However, `enum34` is already in the requirement_dev.txt file. Running `tox` for 2.7 does not install the `enum34` package, thus failing the script `python -c "import pact"` . It does however pass when i manually pip install enum34 prior to running `python -c "import pact"` . Why aren?t packaged being installed as part of that tox script?

pyasi
2020-05-15 00:42
FWIW the above is fixed easily by adding `install: -rrequirements_dev.txt` to the `deps` in `tox.ini` . I?m wondering if that?s intentionally not being done

matt.fellows
2020-05-15 00:43
I?m not a Python expert, but not installing dependencies on build seems strange

matt.fellows
2020-05-15 00:43
did you want to include that in your PR (or a separate one)? If it doesn?t break the build, but fixes yours, that seems like a good reason to bring it in

pyasi
2020-05-15 00:48
Sure! I?ll dig in a bit more to maybe see why it?s done this way, but if not can add it in

matt.fellows
2020-05-15 00:50
thx

pyasi
2020-05-15 00:55
Yep that did the trick. I added just `enum34` as a dependency to that build particular py2.7 build step as it shouldn?t be required for anything else

matt.fellows
2020-05-15 00:56
nice

elliottmurray
2020-05-15 10:03
@pyasi looking good. Couple of things - firstly can you rebase against master? Your version number is behind (there was a release since you started work)

elliottmurray
2020-05-15 10:04
I am looking at the enum dependency. I think it needs to go into setup.py too? requirements dev is for the pipeline not for the package release so I think you might need to add that too. I?ll test locally to check

elliottmurray
2020-05-15 10:04
I am actually thinking of doing a major release and deprecating 2.x support

elliottmurray
2020-05-15 10:04
This would avoid these scenarios

elliottmurray
2020-05-15 11:17
Also you need to make some changes to ?pact/_init_.py?

elliottmurray
2020-05-15 11:17
Otherwise you can?t import the Format into another project

elliottmurray
2020-05-15 11:17
I?ll add these to the PR

pyasi
2020-05-15 12:11
Ahh yeah, i had done this previously. I?ll double check that it works- i had it under the `if major version ==2` condition

pyasi
2020-05-15 12:39
Since ```from pact.matchers import get_generated_values self.assertEqual(result, get_generated_values(expected))``` Was in the docs (and works for me). I figured i wouldn?t have to be explicit in _init_


elliottmurray
2020-05-15 12:43
I have a seperate local install and it didn?t work for me when I tried to import format

elliottmurray
2020-05-15 12:43
not sure about get_generated_values

elliottmurray
2020-05-15 12:43
to replicate try a new virtualenv and install local

elliottmurray
2020-05-15 12:43
pip install -e I think

elliottmurray
2020-05-15 12:43
And then from a repl try

elliottmurray
2020-05-15 12:44
```from pact import Format```

elliottmurray
2020-05-15 12:44
It probably works in e2e because it is in that virtualenv and available

pyasi
2020-05-15 12:44
I?ll give it a shot

elliottmurray
2020-05-15 12:44
This is new to me so happy to be educated

elliottmurray
2020-05-15 12:49
Also in tox.ini should it be:

elliottmurray
2020-05-15 12:50
```envlist=py{27,34,35,36,37,38}-{install}```

elliottmurray
2020-05-15 12:50
?

pyasi
2020-05-15 12:50
Okay i reprod and fix via the import

elliottmurray
2020-05-15 12:50
Tox is a mystery to me

pyasi
2020-05-15 12:50
Yeah i messed that up :smiley:. I?ll put it back

elliottmurray
2020-05-15 12:50
:thumbsup:

pyasi
2020-05-15 12:50
But I?m all for deprecating 2.7 :grimacing:

elliottmurray
2020-05-15 12:51
I?m musing that because I think you also have to add enum to setup.py and I don?t want to do that coz it?s complicated

elliottmurray
2020-05-15 12:58
Did you mean to add the venv27 files?

pyasi
2020-05-15 12:58
Nope! Fixing now :facepalm:

elliottmurray
2020-05-15 13:00
I?m going to have a chat with Matt or Beth and see if I should deprecate 2.x. If I do that I think we can make this change a little easier and just apply yours to 3.x

pyasi
2020-05-15 13:02
From what i can tell this should be safe for 2.7 now since i?ve included setup.py change

elliottmurray
2020-05-15 13:02
ok

elliottmurray
2020-05-15 13:04
If that passes I?ll merge it in for now then

pyasi
2020-05-15 13:09
All passed

elliottmurray
2020-05-15 13:16
merged

elliottmurray
2020-05-15 13:16
I won?t release yet though

pyasi
2020-05-15 13:20
Thanks, no rush on the release

lbraymusso
2020-05-19 17:49
@pyasi

pyasi
2020-05-19 17:50
Thank you!

elliottmurray
2020-05-22 12:55
Fail whale hit me before on publish hence 2nd release

elliottmurray
2020-05-22 12:56
Python-pact 1.x.x will now only support Python 3.x upwards.

zeldigas
2020-05-27 12:58
has joined #pact-python

uglyog
2020-05-30 05:02
has joined #pact-python

uglyog
2020-05-31 03:53
@elliottmurray @matt.fellows I got a initial prototype consumer test (a copy of the todo one in Pact-JS) running with the V3 Rust implementation. It's in the feat/V3 branch :point_right: https://github.com/pact-foundation/pact-python/blob/feat/V3/e2e/v3/todo/tests/test_todo_consumer.py

matt.fellows
2020-05-31 06:45
Wow nice man!

matt.fellows
2020-05-31 06:45
I'll take a look tomorrow

elliottmurray
2020-05-31 10:43
So what?s the roadmap and timeline for v3? I haven?t read the docs/impl - I suppose I should!?

uglyog
2020-05-31 22:57
Nah, nobody reads docs :smile: There is no roadmap or timeline, because nobody has created one

matt.fellows
2020-05-31 23:40
Classic Ron tautological response

ajinkya.pande
2020-06-08 14:54
#pact-python is there any documentation or info about Pact with tornado unit tests?

elliottmurray
2020-06-08 19:35
I?m not aware of any. I?m not familiar with tornado. Does it use unit test as it?s default testing library?

cristian.schez
2020-06-09 11:20
has joined #pact-python

elliottmurray
2020-06-10 20:36
@matt.fellows or @bethskurrie I?ve spent a bit of time looking at doing a Python verifier for providers to create a more ?native? experience. Either of you have some time so I can bounce some ideas around?

matt.fellows
2020-06-10 23:36
Absolutely!

bethskurrie
2020-06-17 01:49
It would be good to look at integrating the Rust impl.

matt.fellows
2020-06-17 02:01
I had a good chat with Elliot yesterday Beth

matt.fellows
2020-06-17 02:01
or the other day

matt.fellows
2020-06-17 02:01
one of the days

bethskurrie
2020-06-17 02:01
oh good :thumbsup::skin-tone-3:

matt.fellows
2020-06-17 02:02
I suggested before jumping into Rust, to address some of the Python idioms first and to look at message support (because frankly, both of those things are more important)

bethskurrie
2020-06-17 02:02
true

matt.fellows
2020-06-17 02:02
Once he wraps his head around those, he?ll be much better placed to do any rust integration because most of the core concepts will be pretty clear

bethskurrie
2020-06-17 02:02
:thumbsup::skin-tone-3:

matt.fellows
2020-06-17 02:03
Also, the provider side is not yet ready for Rust just yet - and I?m going through that exercise (slowly) with Go. So once I?ve pushed through it a bit further I?ll be able to provide much better guidance anyway

sklein
2020-06-19 19:35
has joined #pact-python

joel.whalen
2020-06-22 19:43
Hello, I am using pactman and was wondering if there?s any support for it here. I?ve set up pactman correctly according to the docs, but am getting a `NoneType` error for the `_mock_handler` ```test/util/pact/test_order_service_pact.py:87: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <pactman.mock.pact.Pact object at 0x7ff830112a90> def setup(self): > self._mock_handler.setup(self._interactions) E AttributeError: 'NoneType' object has no attribute 'setup' ../.local/lib/python3.7/site-packages/pactman/mock/pact.py:221: AttributeError``` My test class with some sensitive info edited: ```class TestPactOrderService: def test_pact_submit_order(self): expected = { 'orderId': '<orderId>' } pact.given( '<orderId> exists and has a cart <cartId>, with shippingaddress, billingaddress, and shippingmethod' ).upon_receiving( 'a request to submit order' ).with_request( method = 'POST', path = '/v1/order', headers = { 'Content-Type': 'application/json', # TODO: Make this a global variable/secret 'apikey': 'fakeKey', 'Content-Type': 'text/plain' }, body = mock_submit_cart_fixture ).will_respond_with(200, body=expected) pact.setup() try: # Some additional steps before running the code under test result = OrderServiceClientHelper.submit_order(mock_submit_cart_fixture) # Some additional steps before verifying all interactions have occurred finally: pact.verify() self.assertEqual(result, expected)``` Thanks in advance.

joel.whalen
2020-06-22 19:50
Furthermore, if I do it the other way like this: ``` with pact: result = OrderServiceClientHelper.submit_order(mock_submit_cart_fixture)``` It is failing to catch the request with the mock server and so tries to make a real request to the actual URL: ```E urllib3.exceptions.MaxRetryError: MockConnectionPool(host='localhost', port=5020): Max retries exceeded with url: /v1/order (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c52683048>: Failed to establish a new connection: [Errno 111] Connection refused')) ../.local/lib/python3.7/site-packages/urllib3/util/retry.py:439: MaxRetryError```

matt.fellows
2020-06-22 23:59
Hi Joel, pactman is not supported by the foundation - pact-python is

matt.fellows
2020-06-23 01:20
But hopefully somebody else here can help

matt.fellows
2020-06-23 01:20
We are investing in pact-python, as it lines up with our strategic direction

mukheem
2020-06-23 07:21
Hello @joel.whalen, Though I am not an official member of pactman, I would like to take a chance if I could help. ( I've also started practicing pact recently) Upon going thru the code snippets, I don't see you made a pact In the very first place...

mukheem
2020-06-23 07:21
or did you make it and isn't shown up here ?

joel.whalen
2020-06-23 13:55
I did, I just didn?t post it. In that case I think I?m going to switch to pact-python

joel.whalen
2020-06-23 13:57
here?s the pact ```pact = Consumer('cart-service').has_pact_with(Provider('order-service'))```

joel.whalen
2020-06-23 18:16
So funnily enough, I switched to `pact-python` from `pactman` and am getting the same error. It?s also telling me to check `pact-mock-service.log` for details, but I don?t see that file anywhere. ```E urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=5020): Max retries exceeded with url: /v1/order (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff80005db70>: Failed to establish a new connection: [Errno 111] Connection refused')) ../.local/lib/python3.7/site-packages/urllib3/util/retry.py:439: MaxRetryError``` Here?s my test code with some info removed: ```import unittest import atexit from cart_service.util.order_service_client_helper import OrderServiceClientHelper from pact import Consumer, Provider pact = Consumer('cart-service').has_pact_with(Provider('order-service')) pact.start_service() atexit.register(pact.stop_service) mock_submit_cart_fixture = { "some":"JSON" } class TestPactOrderService(unittest.TestCase): def test_pact_submit_order(self): expected = { 'orderId': 'WB3386288919' } pact.given( 'WB3386288919 exists and has a cart yvjJEDY87VAaXw7ZGSOF, with shippingaddress, billingaddress, and shippingmethod' ).upon_receiving( 'a request to submit order' ).with_request( method = 'POST', path = '/v1/order', headers = { 'Content-Type': 'application/json', # TODO: Make this a global variable/secret 'apikey': 'fakeKey', 'Content-Type': 'text/plain' }, body = mock_submit_cart_fixture ).will_respond_with(200, body=expected) pact.setup() try: # Some additional steps before running the code under test result = OrderServiceClientHelper.submit_order(mock_submit_cart_fixture) # Some additional steps before verifying all interactions have occurred finally: pact.verify() self.assertEqual(result, expected)``` I am also running this in a container using `docker-compose` if that is affecting anything network related. Is it possible that?s the issue?

elliottmurray
2020-06-23 18:27
I?d have to look closer but the docker compose is a bit suspicious. How are you invoking that?

joel.whalen
2020-06-23 18:29
@elliottmurray Sure. Here?s the `docker-compose.yml` ```version: '3.7' services: cart-service-redis: container_name: cart-service-redis image: redis stdin_open: true tty: true networks: - cart-service volumes: - $WORKING_DIR/cart_service/redis.conf:/usr/local/etc/redis/redis.conf entrypoint: - /usr/local/bin/redis-server - /usr/local/etc/redis/redis.conf cart-service: depends_on: - cart-service-redis container_name: cart-service image: zorotools/cart-service build: context: $WORKING_DIR/cart_service dockerfile: $WORKING_DIR/cart_service/Dockerfile.k8s stdin_open: true tty: true networks: - zorotools-net - cart-service ports: - ${CART_SERVICE_PORT:-5040}:5040 environment: GOOGLE_CLOUD_PROJECT: $GOOGLE_CLOUD_PROJECT GOOGLE_PROJECT_ID: $GOOGLE_PROJECT_ID GOOGLE_APPLICATION_CREDENTIALS: /home/zoro/credentials/google-product.json REDISHOST: cart-service-redis PRODUCT_CACHE_HOST: $PRODUCT_CACHE_HOST PRODUCT_CACHE_PORT: $PRODUCT_CACHE_PORT PRODUCT_CACHE_COLLECTION: $PRODUCT_CACHE_COLLECTION LOGGING_SERVICE_ENDPOINT: $LOGGING_SERVICE_ENDPOINT SHIPPING_SERVICE_ENDPOINT: $SHIPPING_SERVICE_ENDPOINT ORDER_SERVICE_ENDPOINT: $ORDER_SERVICE_ENDPOINT PROMO_SERVICE_ENDPOINT: $PROMO_SERVICE_ENDPOINT TAX_SERVICE_ENDPOINT: $TAX_SERVICE_ENDPOINT RUN_GUNICORN: ${RUN_GUNICORN:-false} FIRESTORE_MIN_DELAY_SECONDS: $FIRESTORE_MIN_DELAY_SECONDS FIRESTORE_MAX_DELAY_SECONDS: $FIRESTORE_MAX_DELAY_SECONDS FIRESTORE_DELAY_MULTIPLIER: $FIRESTORE_DELAY_MULTIPLIER FIRESTORE_CALL_DEADLINE_SECONDS: $FIRESTORE_CALL_DEADLINE_SECONDS volumes: - $WORKING_DIR/cart_service:/home/zoro/app - $GOOGLE_APPLICATION_CREDENTIALS:/home/zoro/credentials/google-product.json entrypoint: - docker_vm/run.sh cart-service-test: depends_on: - cart-service container_name: cart-service-test image: zorotools/cart-service stdin_open: true tty: true networks: - cart-service-test volumes: - $WORKING_DIR/cart_service:/home/zoro/app entrypoint: - docker_vm/test.sh # Pact consumer tests cart-service-pact: depends_on: - cart-service container_name: cart-service-pact image: zorotools/cart-service stdin_open: true tty: true volumes: - $WORKING_DIR/cart_service:/home/zoro/app entrypoint: - docker_vm/pact.sh # Pact verification cart-service-verify: networks: - zorotools-net image: pactfoundation/pact-cli:latest container_name: cart-service-verify volumes: - $WORKING_DIR/cart_service:/home/zoro/app depends_on: - cart-service environment: PACT_BROKER_TOKEN: $PACT_BROKER_TOKEN PACT_BROKER_BASE_URL: $PACT_BROKER_BASE_URL CONSUMER_VERSION_TAG: $CONSUMER_VERSION_TAG PROVIDER_APP_VERSION: $PROVIDER_APP_VERSION command: > verify --provider-base-url http://cart-service:5040/v1 --provider "cart-service" --broker-token $PACT_BROKER_TOKEN --pact-broker-base-url $PACT_BROKER_BASE_URL --publish-verification-results --consumer-version-tag=$CONSUMER_VERSION_TAG --provider-app-version=$PROVIDER_APP_VERSION networks: zorotools-net: external: True cart-service: cart-service-test:``` I am invoking this by running this command: ```docker-compose run cart-service-pact```

joel.whalen
2020-06-23 18:30
`pact.sh` just runs pytest

elliottmurray
2020-06-24 13:33
So I was able to reduce the compose file to this:

elliottmurray
2020-06-24 13:33
version: ?3.7? services: # Pact consumer tests pact: image: python:3.6 stdin_open: true tty: true working_dir: /usr/src/myapp volumes: - ./:/usr/src/myapp entrypoint: - bash networks: zorotools-net: external: True cart-service: cart-service-test:

elliottmurray
2020-06-24 13:34
and it works for me on my local test (you get a bash prompt as I have a couple of extra steps for my local test project)

elliottmurray
2020-06-24 13:35
`version: '3.7'` services: # Pact consumer tests pact: image: python:3.6 stdin_open: true tty: true working_dir: /usr/src/myapp volumes: - ./:/usr/src/myapp entrypoint: - bash networks: zorotools-net: external: True cart-service: cart-service-test:

elliottmurray
2020-06-24 13:35
So if you can do the same I suspect it?s something else

elliottmurray
2020-06-24 13:36
Also I could do this which is a lot quicker:

elliottmurray
2020-06-24 13:36
docker run -it -v `pwd`:/usr/src/myapp -w /usr/src/myapp python:3.6 bash

elliottmurray
2020-06-24 13:37
At least if that still breaks for you we?re at the same point - I?m using the python standard image

joel.whalen
2020-06-24 16:54
Running that docker-compose yields this when I run `pact.sh` ```bash: pytest: command not found```

joel.whalen
2020-06-24 16:54
the command is `pytest -k "test_pact"` because there are other unit tests I?m trying to exclude

joel.whalen
2020-06-24 16:58
The reason you?re not getting the error is you don?t have the code that?s making the request to the `order-service` at `localhost:5020`. I?m wondering why I?m getting this error because shouldn?t that request be intercepted and mocked? Why is it making a ?real? request? @matt.fellows if you could take a second look at this error I?d appreciate it, I?m still getting it after switching to `pact-python`

joel.whalen
2020-06-24 17:07
Here?s some more error output if that helps. Again, I cannot find the `pact-mock-service.log` file anywhere ```E AssertionError: Actual interactions do not match expected interactions for mock MockService. E E Missing requests: E POST /v1/order E E See pact-mock-service.log for details. ../.local/lib/python3.7/site-packages/pact/pact.py:293: AssertionError```

joel.whalen
2020-06-24 17:24
Ahah! I failed to setup my pact correctly. I changed from this: ```pact = Consumer('cart-service').has_pact_with(Provider('order-service')``` to this: ```pact = Consumer('cart-service').has_pact_with(Provider('order-service'), port=5020)``` Because the `order-service` default endpoint is on port 5020, that?s why I was getting the original error. I?m getting some different errors now, but I think it has more to do with how the `cart-service` code is executing requests I?m not expecting, which is easier to troubleshoot. Thanks for taking a look at this @elliottmurray, I?ll let you know if I resolve the rest of these issues.

joel.whalen
2020-06-24 17:30
However I still can?t find the log file, it has disappeared into the ether. Assuming related to docker-compose

elliottmurray
2020-06-24 18:37
Happy to be a rubber duck!

matt.fellows
2020-06-25 00:07
Thanks for your help Elliot. Joel - was it surprising to you that the request wasn?t _automatically_ sent to the mock server? In JS at least, it?s probably the second largest class of bug we get (Waaaaay behind people not understanding how promises work, but still a large %)

matt.fellows
2020-06-25 00:08
Perhaps that?s something we could look to address going forward - automatic interception of the requests and redirection to the target mock server

matt.fellows
2020-06-25 00:10
You might want to map the directory the log file is written to to a docker volume, and that way after the container is destroyed the log file remains on the host

elliottmurray
2020-06-25 08:54
Extra logging options for Pact released!

bethskurrie
2020-06-25 09:09
Thanks for the quick turnaround @elliottmurray

suma.papanna
2020-06-25 10:54
has joined #pact-python

tausif8709
2020-06-25 17:31
has joined #pact-python

tausif8709
2020-06-25 17:35
Hi Guys, I am doing a POC on pact-python for microservices , could you please advice on the best approach for testing the consumer pacts locally by setting up dummy provider states? Thanks in advance :slightly_smiling_face: Tausif

ayyamuthutechnical
2020-06-25 17:51
has joined #pact-python

ayyamuthutechnical
2020-06-25 17:53
@here, Currently working on pact-python for microservices, Is there any good documentation or tutorial available for python version as like javascript or Java. Thanks in advance for your support and help. Ayyamuthu

bethskurrie
2020-06-26 00:02
@elliottmurray and @matthew.balvanz would you guys be able to adopt semantic commits (and document this for PRs) for pact-python? I'm syncing the readme and changelog (and any other markdown files you'd like) into http://docs.pact.io to make everything super searchable. If you use semantic commits we can filter out all the noise (also, can completely automate the release note process if you're interested). Have a look at the jvm ones. https://docs.pact.io/implementation_guides/jvm/changelog

bethskurrie
2020-06-26 00:03
It means that any fixes or improvements to things will now come up in the search results on the website which will make finding things much easier.

bethskurrie
2020-06-26 01:35
Pact Python docs are now live at https://docs.pact.io/implementation_guides/python/readme :heart:

elliottmurray
2020-06-26 07:57
I did start looking at this a couple of weeks ago but it didn?t work first time and I got bored! I?ll have another crack at it. It?s been on my todo list

bethskurrie
2020-06-26 08:05
The crux of the logic is in this file here


bethskurrie
2020-06-26 08:06
It could be mostly done with a slight tweak to the current command.

bethskurrie
2020-06-26 08:06
But of course, all the formatting and grouping that you'd get with a package would be nice.



ayyamuthutechnical
2020-06-26 08:53
@elliottmurray thanks for the info.

elliottmurray
2020-06-26 08:54
So the samples need some love but does that not give you an example?

tausif8709
2020-06-26 09:19
@elliottmurray Yes , Thanks for the quick response :100:

elliottmurray
2020-06-26 09:30
@beth happy for me to merge? I?m happy with the PR for the gh action but haven?t tested it.

naz
2020-06-26 13:06
has joined #pact-python

matthew.balvanz
2020-06-26 13:27
I like automating things, so I'd be happy to use semantic commits.

joel.whalen
2020-06-26 14:08
oh that?s a good idea I?ll try that today

joel.whalen
2020-06-26 14:48
Yes it was surprising it wasn?t automatic, but seeing as I didn?t tell the mock server *where* to listen for requests it?s understandable why it didn?t.

amaljayaraj07
2020-06-30 08:30
has joined #pact-python

ayyamuthutechnical
2020-07-03 10:15
@here, Hi team, I am using the pact-python e2e for poc,https://github.com/pact-foundation/pact-python/tree/master/examples/e2e While running the test for provider states using the shell script like ./verify_pact.sh 1 I am getting the below error, Can you please help me on this. Thanks

ayyamuthutechnical
2020-07-03 10:15
```Traceback (most recent call last): File "pact_provider.py", line 3, in <module> from .src.provider import app, fakedb ImportError: attempted relative import with no known parent package Error reading file from http://127.0.0.1/pacts/provider/UserService/consumer/UserServiceClient/latest HTTP request failed: status=404 /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:71:in `block in get_remote_with_retry' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:60:in `times' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:60:in `get_remote_with_retry' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:41:in `render_pact' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:22:in `read' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_source.rb:16:in `pact_json' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_spec_runner.rb:115:in `collect' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_spec_runner.rb:115:in `pact_jsons' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_spec_runner.rb:78:in `configure_rspec' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_spec_runner.rb:32:in `run' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/cli/run_pact_verification.rb:69:in `run_with_pact_uri_object' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/cli/run_pact_verification.rb:50:in `run_specs' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/cli/run_pact_verification.rb:21:in `call' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/cli/run_pact_verification.rb:13:in `call' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:171:in `verify_pact' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:43:in `block in call' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:42:in `collect' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:42:in `call' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:34:in `call' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/cli/verify.rb:58:in `verify' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/cli/custom_thor.rb:17:in `start' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/app/pact-provider-verifier.rb:33:in `<main>' /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:71:in `block in get_remote_with_retry': HTTP request failed: status=404 (Pact::PactFile::HttpError) from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:60:in `times' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:60:in `get_remote_with_retry' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:41:in `render_pact' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.0/lib/pact/consumer_contract/pact_file.rb:22:in `read' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_source.rb:16:in `pact_json' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_spec_runner.rb:115:in `collect' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_spec_runner.rb:115:in `pact_jsons' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_spec_runner.rb:78:in `configure_rspec' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/provider/pact_spec_runner.rb:32:in `run' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/cli/run_pact_verification.rb:69:in `run_with_pact_uri_object' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/cli/run_pact_verification.rb:50:in `run_specs' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/cli/run_pact_verification.rb:21:in `call' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.50.1/lib/pact/cli/run_pact_verification.rb:13:in `call' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:171:in `verify_pact' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:43:in `block in call' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:42:in `collect' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:42:in `call' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/app.rb:34:in `call' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/cli/verify.rb:58:in `verify' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.31.0/lib/pact/provider_verifier/cli/custom_thor.rb:17:in `start' from /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/app/pact-provider-verifier.rb:33:in `<main>' Tearing down Flask server 7195 Kill provider app with pid kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]```

elliottmurray
2020-07-03 13:08
I?ll have a look over the weekend - they?re not yet rigged up to CI so it is very possible there are regressions

elliottmurray
2020-07-03 13:08
Can you check that broker pacts are present:


a.catalucci
2020-07-04 10:28
has joined #pact-python

ayyamuthutechnical
2020-07-06 05:21
No the pacts are not present in my local. How to make it available? How i should i proceed now? Can you please help Thanks

vasile.pop971
2020-07-06 07:44
has joined #pact-python

vasile.pop971
2020-07-06 07:48
Hi there. Does anybody have any documentation/examples on using pact-python for event messaging? (in my case, Kafka)

elliottmurray
2020-07-06 08:09
Hey vasile. Not yet. I believe there are some for other languages. It is on my radar. I?d be willing to work with you on it but at point I?m not sure how to do it!

vasile.pop971
2020-07-06 08:12
found some JVM example, but seems to have built-in functionality

elliottmurray
2020-07-06 08:50
So this worked straight out of the box for me.

elliottmurray
2020-07-06 08:50
I suggest a fresh install, make sure you have docker compose running in a separate shell (in the README)

elliottmurray
2020-07-06 08:50
Instructions I ran:

elliottmurray
2020-07-06 08:51
`git clone git@github.com:pact-foundation/pact-python.git && cd pact-python`

bethskurrie
2020-07-06 08:51
Yeah, pact python works differently

bethskurrie
2020-07-06 08:51
Someone may have started it already? But I lose track!

elliottmurray
2020-07-06 08:51
`# setup viritualenv - I use direnv but that is for you` `pip install -r requirements_dev.txt`

elliottmurray
2020-07-06 08:52
cd examples/e2e pytest --publish-pact=0.1 ./verify_pact.sh 1

elliottmurray
2020-07-06 08:53
sorry typo - above was: `pytest --publish-pact=1`

elliottmurray
2020-07-06 08:54
I get

elliottmurray
2020-07-06 08:55
There is currently nothing built into pact python to deal with Kafka afaik

bethskurrie
2020-07-06 09:51
Message pact just tests the business logic, and avoids testing the protocol.

bethskurrie
2020-07-06 09:52
So there won't ever be anything Kafka specific.

vasile.pop971
2020-07-06 09:54
of course, no messages sent via Kafka, but how do you test the event messages?

ayyamuthutechnical
2020-07-06 10:52
@elliottmurray, Thank you, i have tried to run the command pytest --publish-pact=1 and now i am getting latest pact in the localhost http://127.0.0.1/pacts/provider/UserService/consumer/UserServiceClient/latest But while running the command "./verify_pact.sh" I am getting below error ```Validating provider locally Traceback (most recent call last): File "pact_provider.py", line 3, in <module> from .src.provider import app, fakedb ImportError: attempted relative import with no known parent package INFO: Reading pact at tests/userserviceclient-userservice.json Verifying a pact between UserServiceClient and UserService Given UserA exists and is not an administrator a request for UserA with GET /users/UserA returns a response which has status code 200 (FAILED - 1) has a matching body (FAILED - 2) Given UserA does not exist a request for UserA with GET /users/UserA returns a response which has status code 404 (FAILED - 3) Failures: 1) Verifying a pact between UserServiceClient and UserService Given UserA exists and is not an administrator a request for UserA with GET /users/UserA returns a response which has status code 200 Failure/Error: set_up_provider_states interaction.provider_states, options[:consumer] Faraday::ConnectionFailed: Connection refused - connect(2) for "localhost" port 5001 # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `open' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `block in connect' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:in `timeout' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:878:in `connect' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:in `do_start' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in `start' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:1375:in `request' # ------------------ # --- Caused by: --- # Errno::ECONNREFUSED: # Connection refused - connect(2) for "localhost" port 5001 # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize' 2) Verifying a pact between UserServiceClient and UserService Given UserA exists and is not an administrator a request for UserA with GET /users/UserA returns a response which has a matching body Failure/Error: set_up_provider_states interaction.provider_states, options[:consumer] Faraday::ConnectionFailed: Connection refused - connect(2) for "localhost" port 5001 # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `open' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `block in connect' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:in `timeout' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:878:in `connect' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:in `do_start' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in `start' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:1375:in `request' # ------------------ # --- Caused by: --- # Errno::ECONNREFUSED: # Connection refused - connect(2) for "localhost" port 5001 # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize' 3) Verifying a pact between UserServiceClient and UserService Given UserA does not exist a request for UserA with GET /users/UserA returns a response which has status code 404 Failure/Error: set_up_provider_states interaction.provider_states, options[:consumer] Faraday::ConnectionFailed: Connection refused - connect(2) for "localhost" port 5001 # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `open' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `block in connect' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:in `timeout' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:878:in `connect' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:in `do_start' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in `start' # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:1375:in `request' # ------------------ # --- Caused by: --- # Errno::ECONNREFUSED: # Connection refused - connect(2) for "localhost" port 5001 # /Users/aarchunan/pactpython/lib/python3.7/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize' 2 interactions, 2 failures Failed interactions: PACT_DESCRIPTION='a request for UserA' PACT_PROVIDER_STATE='UserA exists and is not an administrator' /Users/aarchunan/pactpython/bin/pact-verifier --provider-base-url=http://localhost:5001 --provider-states-setup-url=http://localhost:5001/_pact/provider_states tests/userserviceclient-userservice.json # A request for usera given UserA exists and is not an administrator PACT_DESCRIPTION='a request for UserA' PACT_PROVIDER_STATE='UserA does not exist' /Users/aarchunan/pactpython/bin/pact-verifier --provider-base-url=http://localhost:5001 --provider-states-setup-url=http://localhost:5001/_pact/provider_states tests/userserviceclient-userservice.json # A request for usera given UserA does not exist Tearing down Flask server 62907 Kill provider app with pid kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]```

elliottmurray
2020-07-06 10:56
I?m not at my computer but I think 5001 is the port that the provider in the example should be listening to. IIRC it?s a flask app. Make sure that started and shut down properly as I suspect that?s the problem

elliottmurray
2020-07-06 10:56
Ps -ef probably

matt.fellows
2020-07-06 11:26
Here's an example JS Kafka consumer that should help you understand the process https://github.com/pactflow/example-consumer-js-kafka

matt.fellows
2020-07-06 11:26
I responded to your GH issue. There is an Open PR and issues to track this

matt.fellows
2020-07-06 11:26
If you wanted to help I could assist in the how

vasile.pop971
2020-07-06 11:41
Thanks, very limited time, but I would like to try it. Will look at JS example

ayyamuthutechnical
2020-07-06 14:03
@elliottmurray, Now it is working. Thanks for your timely help.

matt.fellows
2020-07-07 11:15
WOW, we missed this: https://www.udemy.com/course/introduction-to-contract-testing-with-pact/ Lewis Prescott from Cancer Research UK created this course. Has anybody completed it?

elliottmurray
2020-07-07 12:56
Was this intended for general?

elliottmurray
2020-07-07 12:57
I have actually been playing around looking at Udemy for publishing content but might be worth an investment to get an official course?

matt.fellows
2020-07-07 13:10
Yes in hindsight. I was linked to it from a python project so assumed it was python content but the blurb doesn't match

camila.pinto-ext
2020-07-07 14:16
has joined #pact-python

fernando.martin
2020-07-07 14:55
has joined #pact-python

danhitchcock
2020-07-07 15:16
has joined #pact-python

danhitchcock
2020-07-07 15:31
Hi there, So i've been asked to write the provider test in Python (the client tests are in JS and i managed to set the state in a similar way to below when running the provider tests in JS, but i am unfamiliar with how i return a header in Python). ```from flask import jsonify, request @app.route('/_pact/provider_states', methods=['POST']) def provider_states(): mapping = {'with auth': setup_auth, 'without_auth': setup_no_auth} mapping[request.json['state']]() return jsonify({'result': request.json['state']}) def setup_auth(): authKey = 'Token abc132' def setup_no_auth(): authKey = 'Token' if __name__ == '__main__': app.run(debug=True, port=5001)```

chawlapriyanka29
2020-07-07 17:15
has joined #pact-python

danhitchcock
2020-07-08 15:52
So far I've yet to find that one liner in Python that sets the header, the provider states is working but setting the header is elusive

danhitchcock
2020-07-09 08:10
So my only other option is to split auth and non auth tests and use the add header command line for each set. I'll update the code if I find a way to update the auth header for each state, as this is my preferred option

joguespermana
2020-07-09 09:13
I would definitely enroll if we have one specifically for python :slightly_smiling_face:

matt.fellows
2020-07-09 10:34
calling @bernardoguerr :stuck_out_tongue:

danhitchcock
2020-07-09 14:02
6 hours later.... ARGGGGGG Ok so you can set env variables in python but there seem to be some conditions i am not meeting as the value isn't updated by ```os.environ["CUSTOM_PROVIDER_HEADER"]="some text" ```

danhitchcock
2020-07-10 07:32
I decided to just split the auth and non-auth tests, python seems to have some restrictions on how you change env variables at runtime. Despite a bit of reading on the pact docs, I am not sure if there is a way i can send back an updated header value to the pact process. Maybe this is my inexperience in python showing through, so more reading on the subject.

joel.whalen
2020-07-10 13:56
There aren?t many people in the ruby standalone channel, so I?ll link my question here as well. I?m using pact-python and am wondering how everyone here has implemented their publish step? I can?t seem to get it to work on the official docker image https://pact-foundation.slack.com/archives/C9WTB2JDV/p1594322837008800

sklein
2020-07-10 14:01
For python consumers... I wrote a base class that looks like ```from django.conf import settings from pact import Consumer, Provider, EachLike, Like, Term log = logging.getLogger(__name__) logging.basicConfig(level=http://logging.INFO) PACT_MOCK_HOST = "localhost" PACT_MOCK_PORT = 1234 PACT_DIR = os.path.dirname(os.path.realpath(__file__)) PACT_BROKER_BASE_URL = settings.PACT_BROKER_BASE_URL PACT_BROKER_TOKEN = settings.PACT_BROKER_TOKEN PACT_PUBLISH_TO_BROKER = settings.PACT_PUBLISH_TO_BROKER PACT_CONSUMER_BRANCH = settings.PACT_CONSUMER_BRANCH VERSION = settings.GIT_COMMIT_SHORT_HASH class PactConsumerSetup: def __init__(self, consumer, provider): self.consumer = consumer self.provider = provider def pact(self): return Consumer( self.consumer, tags=[PACT_CONSUMER_BRANCH], version=VERSION ).has_pact_with( Provider(self.provider), host_name=PACT_MOCK_HOST, port=PACT_MOCK_PORT, pact_dir=PACT_DIR, log_dir=PACT_DIR, publish_to_broker=PACT_PUBLISH_TO_BROKER, broker_base_url=PACT_BROKER_BASE_URL, broker_token=PACT_BROKER_TOKEN, )``` We use django as our web framework of choice so settings are read in using django.settings as environment variables

sklein
2020-07-10 14:02
the `has_pact_with` method takes in `publish_to_broker` flag that will push to the broker if true

joel.whalen
2020-07-10 14:03
oh the `pact` object itself can handle publishing? I had no idea I thought you needed an external CLI tool. The docs don?t mention this at all https://github.com/pact-foundation/pact-python


sklein
2020-07-10 14:04
correct not in the docs. i spent a lot of time in the code base to find some of this

joel.whalen
2020-07-10 14:04
thank you for pointing this out, those docs need some updates then for sure

sklein
2020-07-10 14:07
i've also found that the bundled `pact-verifier` installed with `pact-python` is a bit behind the ruby impl so i've defaulted to fall back to using the cli docker image and wrapping everything up in a compose stack as a part of our pipeline... but that's probably too much information you didnt need :slightly_smiling_face:

joel.whalen
2020-07-10 14:09
No, I definitely am thinking about doing the same thing. I did it that way for our pact-js implementation as well. Except our devops team doesn?t use docker-compose, but pod templates so I really need to learn that next?

sklein
2020-07-10 14:10
if you're using kube the service spec is really basically just a wrapper on top of docker-compose

joel.whalen
2020-07-10 14:11
I?ll take a look, thanks for the heads up

matt.fellows
2020-07-10 14:12
Joel can you elaborate on your pact JS case?

matt.fellows
2020-07-10 14:12
As in, why you don't use the JS verifier (it's good feedback for us)

joel.whalen
2020-07-10 14:15
Ah, sorry for the confusion: Our pact-js implementation is just on the consumer side; the verification happens on the provider which is written in python so we just used the pact CLI in docker to do that. Which is why the docker image was my first go-to for publishing python consumer tests, but as you can see I couldn?t get that to work. Here?s the verification step in docker-compose: ``` # Pact verification cart-service-verify: networks: - zorotools-net image: pactfoundation/pact-cli:latest container_name: cart-service-verify volumes: - $WORKING_DIR/cart_service:/home/zoro/app depends_on: - cart-service environment: PACT_BROKER_TOKEN: $PACT_BROKER_TOKEN PACT_BROKER_BASE_URL: $PACT_BROKER_BASE_URL CONSUMER_VERSION_TAG: $CONSUMER_VERSION_TAG PROVIDER_APP_VERSION: $PROVIDER_APP_VERSION command: > verify --provider-base-url http://cart-service:5040/v1 --provider "cart-service" --broker-token $PACT_BROKER_TOKEN --pact-broker-base-url $PACT_BROKER_BASE_URL --publish-verification-results --consumer-version-tag=$CONSUMER_VERSION_TAG --provider-app-version=$PROVIDER_APP_VERSION```

matt.fellows
2020-07-10 14:20
Ah cool. Gotcha. Thanks yes it looks like we have some docs work to do!

matt.fellows
2020-07-10 14:20
Elliot has recently added a PR to improve the verification there so hopefully that will go a way to improving things

joel.whalen
2020-07-10 14:21
Yes, for both pact-python and the docker hub instructions as well. Awesome, it?s good to see something like this develop and get active work done on it.

matt.fellows
2020-07-10 14:22
We've also got a v3 compatible verifier

joel.whalen
2020-07-10 14:23
I think I?m still on v2 but I?m not sure. That?ll be nice to upgrade to

matt.fellows
2020-07-10 14:23
It's missing a few of the Pact broker integrations but add soon as they are in we should swap over asap

joel.whalen
2020-07-10 14:24
I will keep that in mind. We?re still in the early stages so changing things around isn?t too difficult right now

joel.whalen
2020-07-10 18:51
Alright so I went off of @sklein?s suggestion to create a base pact setup class to handle pact publication, but I don?t think it?s working. For one, I?m getting an error related to `atexit` ```Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__ restore_signals, start_new_session) File "/usr/local/lib/python3.7/subprocess.py", line 1453, in _execute_child restore_signals, start_new_session, preexec_fn) TypeError: expected str, bytes or os.PathLike object, not Head ``` Secondly, the publish step never happens, even if I remove the `atexit.register(pact.stop_service)` call. Here is my setup class: ```from os import environ from pact import Consumer, Provider, EachLike, Like, Term import git repo = git.Repo('.') branch_name = repo.active_branch version_sha = repo.head.object.hexsha PACT_DIR = environ.get('PACT_DIR', 'pacts') PACT_BROKER_BASE_URL = environ.get('PACT_BROKER_BASE_URL', 'https://my.broker.url.au') PACT_BROKER_TOKEN = environ.get('PACT_BROKER_TOKEN') PACT_PUBLISH_TO_BROKER = environ.get('PACT_PUBLISH_TO_BROKER', True) PACT_CONSUMER_BRANCH = environ.get('PACT_CONSUMER_BRANCH', branch_name) VERSION = environ.get('VERSION', version_sha) class PactConsumerSetup: def __init__(self, consumer, provider, port): self.consumer = consumer self.provider = provider self.port = port def pact(self): return Consumer( self.consumer, tags=[PACT_CONSUMER_BRANCH], version=VERSION ).has_pact_with( Provider(self.provider), port=self.port, pact_dir=PACT_DIR, log_dir=PACT_DIR, publish_to_broker=PACT_PUBLISH_TO_BROKER, broker_base_url=PACT_BROKER_BASE_URL, broker_token=PACT_BROKER_TOKEN, )``` And here is the test code:

joel.whalen
2020-07-10 18:51
```import unittest import atexit from copy import deepcopy from cart_service.service.cart_service import CartService from cart_service.client.cart_firestore_client import CartFirestoreClient from cart_service.service.product_cache_service import ProductCacheService from test.fixtures.cart_fixtures import submit_cart_request, submit_payment_request from test.fixtures.product_cache_fixture import product_cache_response from pact import Consumer, Provider import pytest from .pact_setup import PactConsumerSetup pact = PactConsumerSetup(consumer='cart-service', provider='order-service', port=5020).pact() pact.start_service() atexit.register(pact.stop_service) # Module Namespaces cart_service_ns = "cart_service.service.cart_service" service_ns = "cart_service.service" cart_firestore_client_ns = "cart_service.client.cart_firestore_client" pc_ns = "cart_service.service.product_cache_service" mock_submit_order_fixture = { "some":"JSON" } class TestPactOrderService: def test_pact_submit_order(self, mocker): mocker.patch(f"{cart_service_ns}.app") mocker.patch(f"{cart_firestore_client_ns}.app") mocker.patch(f"{pc_ns}.app") mocker.patch(f"{service_ns}.cart_service_decorator.cart_mutating", lambda x: x) mock_firestore_client_init = mocker.patch.object(CartFirestoreClient, "__init__") mock_firestore_client_init.return_value = None mock_firestore_get_cart = mocker.patch(f"{cart_service_ns}.CartFirestoreClient.get_cart") mock_firestore_get_cart.return_value = submit_cart_request mock_cache_helper = mocker.patch(f"{cart_service_ns}.CacheHelper.set") mock_cache_helper.return_value = True mock_cache_get = mocker.patch(f"{cart_service_ns}.CacheHelper.get") mock_cache_get.return_value = {} mocker.patch(f"{cart_service_ns}.CartFirestoreClient.update_cart_status") mocker.patch(f"{cart_service_ns}.CacheHelper.bust_cache") mock_prod_cache_init = mocker.patch.object(ProductCacheService, "__init__") mock_prod_cache_init.return_value = None product_cache_response_c = deepcopy(product_cache_response) mock_get_products = mocker.patch(f"{pc_ns}.ProductCacheService.get_products") mock_get_products.return_value = product_cache_response_c expected = { 'orderId': 'wacky_test_order' } pact.given( 'order does not exist, but cart yvjJEDY87VAaXw7ZGSOF does exist' ).upon_receiving( 'a request to submit order' ).with_request( method='POST', path='/v1/order', headers={ 'Content-Type': 'application/json', }, body=mock_submit_order_fixture ).will_respond_with(200, body=expected) pact.setup() try: # Some additional steps before running the code under test result = CartService().submit_order('yvjJEDY87VAaXw7ZGSOF', submit_payment_request) # Some additional steps before verifying all interactions have occurred finally: pact.verify() assert result == expected``` To recap: Pact is being generated just fine with this method, but publish is failing to happen. `atexit` doesn?t seem to be related, whether I include it or not the publish step doesn?t work.

joel.whalen
2020-07-10 18:58
Sidenote: This is a python newbie question, but how do I get my linter to agree that the class signature for `Consumer` is correct? It seems to think it can only take 2 options instead of 4.

matt.fellows
2020-07-11 03:34
I do know much Python, but will make a note to revisit this convo on Monday

matt.fellows
2020-07-11 03:35
FWIW I typically don?t have the publish as part of the test itself

elliottmurray
2020-07-15 20:50
So I actually didn?t know there was a publish to broker in the consumer interface!

elliottmurray
2020-07-15 20:52
My test project does something like:

elliottmurray
2020-07-15 20:53
`S> 41 def push_to_broker(version):` with open(os.path.join(PACT_DIR, PACT_FILE), ?rb?) as pact_file: pact_file_json = json.load(pact_file) basic_auth = HTTPBasicAuth(PACT_BROKER_USERNAME, PACT_BROKER_PASSWORD) r = requests.put( ?{}/{}?.format(PACT_UPLOAD_URL, version), auth=basic_auth, json=pact_file_json, verify=False ) if not r.ok: log.error(?Error uploading: %s?, r.content) r.raise_for_status()

elliottmurray
2020-07-15 20:53
I?ll have a look at it in a bit

elliottmurray
2020-07-15 21:03
Looking for a volunteer - will be less than an hour of your time if you have a working python pact project. I have a largish refactor waiting to be merged in. I am fairly comfortable I have covered all regressions but it?s a bigger change than I normally like to make and more testing is good. If anyone wants to help out testing it - should take about half hour of your time to get me some quick feedback. In particular (though not only) interested in windows users, anyone doing provider/verification as that?s the bit with the biggest change. Something that is already running in CI extra cool. Please DM me - I?m on UK time.

sairsule
2020-07-20 16:10
has joined #pact-python

sairsule
2020-07-20 16:48
@sairsule has left the channel

ashish_garg5
2020-07-21 07:01
has joined #pact-python

ashish_garg5
2020-07-21 07:03
Hi All, ```http://localhost:8500/pacts/provider/provider/consumer/consumer/version/1.0.0``` I am using this broker url to make a put request in python now i want to add pact-broker-username and pact-broker-password as well, how to do that ? Can i pass in this same url or there is any other way. Thanks.

maciej.olko
2020-07-21 07:33
that may be question to ask on #pact-broker channel

matt.fellows
2020-07-21 07:34
lol he just got referred from that channel, as he?s asking a Python specific question

matt.fellows
2020-07-21 07:34
Sorry Ashish

matt.fellows
2020-07-21 07:34
Look, If we understand correctly, you?re asking a really basic question about how to add basic auth to a python request

matt.fellows
2020-07-21 07:34
For example, if you?re using the Python Requests library, you do it this way: https://requests.readthedocs.io/en/master/user/authentication/#basic-authentication

matt.fellows
2020-07-21 07:35
If you use the Pact CLI docker tools (https://hub.docker.com/r/pactfoundation/pact-cli) you just execute the docker command and pass in the token that way

elliottmurray
2020-07-21 08:17
verifying or publishing?


elliottmurray
2020-07-21 08:18
I?m close to having an api for the provider that is more native (I?ve been stalling) if that?s what you?re after. I?m hoping to have a sample in pytest (actually the sample is there in master but I haven?t finished implementing it fully yet)

elliottmurray
2020-07-21 08:19
It?ll allow broker authentication

elliottmurray
2020-07-21 08:19
Also yes you can use requests

elliottmurray
2020-07-21 08:20
```def push_to_broker(version): """TODO: see if we can dynamically learn the pact file name, version, etc.""" with open(os.path.join(PACT_DIR, PACT_FILE), 'rb') as pact_file: pact_file_json = json.load(pact_file) basic_auth = HTTPBasicAuth(PACT_BROKER_USERNAME, PACT_BROKER_PASSWORD) http://log.info("Uploading pact file to pact broker...") r = requests.put( "{}/{}".format(PACT_UPLOAD_URL, version), auth=basic_auth, json=pact_file_json ) if not r.ok: log.error("Error uploading: %s", r.content) r.raise_for_status()```

elliottmurray
2020-07-21 08:21
urgh - why does threads code blocks suck?

elliottmurray
2020-07-21 08:21
anyway you get the idea from that

ashish_garg5
2020-07-21 08:22
yes exactly m looking for this - ```r = requests.put( "{}/{}".format(PACT_UPLOAD_URL, version), auth=basic_auth, json=pact_file_json )``` but addinglike this auth=basic_auth doesn't work for me

elliottmurray
2020-07-21 08:23
http not https right?

ashish_garg5
2020-07-21 08:24
yes http

elliottmurray
2020-07-21 08:24
and works with something like curl or wget or httpie?

elliottmurray
2020-07-21 08:24
Just reducing the problem to python

ashish_garg5
2020-07-21 08:25
```PACT_BROKER_USERNAME = 'test' PACT_BROKER_PASSWORD = 'test' basic_auth = HTTPBasicAuth(PACT_BROKER_USERNAME, PACT_BROKER_PASSWORD) broker_url = 'http://localhost:8500/pacts/provider/provider/consumer/consumer/version/1.0.0'.format( provider='provider', consumer='consumer', consumerApplicationVersion='1.0.0', auth=basic_auth)```

ashish_garg5
2020-07-21 08:26
so like this m doing

ashish_garg5
2020-07-21 08:26
```resp = requests.put(broker_url, data = open(pactfile, 'rb'), headers=headers)``` and then making this put request

elliottmurray
2020-07-21 08:28
sorry I?m missing something - is broker url a string? Why do you format with those params (as there doesn?t seem to be placeholders for them)

ashish_garg5
2020-07-21 08:29
so i took this from some example not sure why this format is required

elliottmurray
2020-07-21 08:30
I?d expect the auth key to be used in the requests put method

elliottmurray
2020-07-21 08:30
```r = requests.put( "{}/{}".format(PACT_UPLOAD_URL, version), auth=basic_auth, json=pact_file_json )```

elliottmurray
2020-07-21 08:30
Change ?{}/{}?.format(PACT_UPLOAD_URL, version) for broker url

ashish_garg5
2020-07-21 08:31
ok let me try

ashish_garg5
2020-07-21 08:31
thanks

elliottmurray
2020-07-21 08:32
So for my context - would you describe yourself as a dev or a tester?

ashish_garg5
2020-07-21 08:33
dev

elliottmurray
2020-07-21 08:33
ok - if you?re struggling with the python I do find some of the cli tools like curl a way of debugging these calls

elliottmurray
2020-07-21 08:34
as you can demonstrate it is broker or not brokers fault in this case

ashish_garg5
2020-07-21 08:34
ok

ashish_garg5
2020-07-22 06:24
Hi All, I am making a put request to publish the PACT. ```PACT_BROKER_URL+'/pacts/provider/provider/consumer/consumer/version/1.0.0'``` how can i publish TAG to the broker ? Thanks.

bethskurrie
2020-07-22 06:26
@ashish_garg5 please look for the documentation on http://docs.pact.io

bethskurrie
2020-07-22 06:26
There is a search bar in the top right.

bethskurrie
2020-07-22 06:26
type in the word "tags"

bethskurrie
2020-07-22 06:27
I am pretty sure there is support for publishing pacts with tags using the pact python library

bethskurrie
2020-07-22 06:28
Why are you doing manual PUT requests?

ashish_garg5
2020-07-22 06:29
```PACT_BROKER_URL+'/pacts/provider/provider/consumer/consumer/version/1.0.0/tags/tagName'``` yeah there they have given /tags/tagname but its not working for me


ashish_garg5
2020-07-22 06:30
so i am doing the poc so for testing purpose i am doing manually as of now later i will change

bethskurrie
2020-07-22 06:32
can you use docker?

ashish_garg5
2020-07-22 06:33
ok let me check thanks

bethskurrie
2020-07-22 06:34
You should be able to publish pacts with tags via the python interface. if you can't do that, then you can use the pact-cli in the docker container here https://hub.docker.com/r/pactfoundation/pact-cli


bethskurrie
2020-07-22 06:34
If you really must do it manually (which I don't recommend), then you can look at the docs here https://docs.pact.io/pact_broker/tags#creating-tags

matt.fellows
2020-07-22 06:39
@ashish_garg5 the amount of effort in ?doing it manually? seems backwards to me. Use the tools that already exist for this purpose, and ?do it manually? when you need to customise and know what you?re doing

matt.fellows
2020-07-22 06:40
Because after you publish and then tag, I expect the next request will be how do I retrieve based on tags, publish results etc. etc.

bethskurrie
2020-07-22 06:40
Exactly. Manually is much harder and requires you to understand all the underlying APIs.

matt.fellows
2020-07-22 06:40
you?re just going to be building out a CLI that already exists

ashish_garg5
2020-07-22 07:40
ok thanks @matt.fellows and @bethskurrie for your inputs. i will consider this :slightly_smiling_face:

ashish_garg5
2020-07-22 11:12
Hi, Now i am using CLI and running the below command. pact-broker publish PACT_DIRS_OR_FILES ./pacts --consumer-app-version 1.0.0 --tag dev --broker-base-url http://localhost:8500 I have created folder with name pacts in my project and my json is inside that, but getting below error. Not sure if PACT_DIRS_OR_FILES path i have to give like this Errno::ENOENT: No such file or directory @ rb_sysopen - PACT_DIRS_OR_FILES

matt.fellows
2020-07-22 11:40
Ashish, that message looks very clear to me.

matt.fellows
2020-07-22 11:40
`PACT_DIRS_OR_FILES` is not a file or a path. just remove it, it is a placeholder for where you can put a path to a file, a directory or multiple files/directories

ashish_garg5
2020-07-22 11:44
ohh ok thanks

bethskurrie
2020-07-25 03:24
@elliottmurray you've been keeping Github busy. Appreciate your work!

matt.fellows
2020-07-25 10:57
Yes - it?s awesome to see!

matt.fellows
2020-07-25 10:58
Pact for Data Science, Elliot?

wesleythomaswilliams
2020-07-27 11:48
has joined #pact-python

david025
2020-07-29 11:19
has joined #pact-python

vishwa.amit
2020-07-30 12:39
has joined #pact-python

maciej.olko
2020-07-31 11:33
Hi, after bumping pact-python to 1.2.0 one of our contract verifications fails with: ```$ pact-verifier --provider-base-url http://fake-?:8000 https://?/pacts/provider/?/consumer/?/latest --custom-provider-header "?" --provider-states-setup-url http://fake-?:8000/setup_states/ --provider-app-version $CI_COMMIT_REF_NAME 87 WARN: Ignoring unsupported matching rules {"match"=>"type"} for path $['query']['start'][0] 88 WARN: Ignoring unsupported matching rules {"match"=>"type"} for path $['query']['end'][0] 89 INFO: Reading pact at https://?/pacts/provider/?/consumer/?/latest 90 Verifying a pact between ? and ? 91 Given ? 92 ? 93 with GET ? 94 returns a response which 95 has status code 200 (FAILED - 1) 96 has a matching body (FAILED - 2) 97 includes headers 98 "Content-Type" which equals "application/json" ? 1) Verifying a pact between ? and ? ? ? with GET ? returns a response which has status code 200 202 Failure/Error: expect(response_status).to eql expected_response_status 203 expected: 200 204 got: 401 205 (compared using eql?) 206 2) Verifying a pact between ? and ? ? ? with GET ? returns a response which has a matching body 207 Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example 208 Actual: {"error":true,"message":"The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required."} 209 Diff 210 -------------------------------------- 211 Key: - is expected 212 + is actual 213 Matching keys and values are not shown 214 -? 221 +{ 222 + "error": true, 223 + "message": "The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required." 224 +}``` Did something change with authorisation on mocks or headers? Do you have any hints?

elliottmurray
2020-07-31 14:27
Hmm it might have been an introduced bug. I did a refactor. I?ll look at it tomorrow. Take it it works on 1.1?

maciej.olko
2020-07-31 14:29
Yes, works on 1.1.0

maciej.olko
2020-07-31 14:32
Feel free to contact me if more details are needed.

elliottmurray
2020-08-01 10:06
Thanks - I think I have found the issue. Should be a small fix. Might get you to test it if you?re happy to do that? Shouldn?t be too hard


elliottmurray
2020-08-01 10:11
You should be able to download that commit locally and link via pip locally (and uninstall pact-python that you had) and see this work.

elliottmurray
2020-08-01 10:12
I?m on holiday next week so might be a bit slow in responding but don?t want to do a release if it?s not ?good?

maciej.olko
2020-08-03 11:20
I?m also on holiday this week, so it is the same with me ? but I will try to find a moment to check the fix, maybe closer to Wednesday, thanks

elliottmurray
2020-08-03 12:49
:+1:

maciej.olko
2020-08-06 21:22
Unfortunately setting up authentication for verification locally occurred not to be easy for me. Checking it on CI would be much faster for me. Would alpha release (or regular one) be an option?

vishwa.amit
2020-08-07 04:54
Hi I am trying to use pact-python with pactflow to run the published contract against the provider, I am providing all the details while running but it doesn't seem to `--custom-provider-header`.your inputs are really appreciated.. ```pipenv run pact-verifier --provider-base-url=http://0.0.0.0:8081 \ --pact-url="https://pactflow.int.co.uk/pacts/provider/UM Service/consumer/latest/0.1.0" \ --pact-broker-username username \ --pact-broker-password password \ --publish-verification-results \ --custom-provider-header='Authorization:Bearer tkn'``` output is ```Error: no such option: --custom-provider-header```

elliottmurray
2020-08-07 07:26
I should be able to do that. I?ll try and get it done over the weekend

elliottmurray
2020-08-07 07:30
There is a thread a little bit before this you might want to read specifically mentioning custom headers

elliottmurray
2020-08-07 07:44
Also try dropping the = for that param

vishwa.amit
2020-08-07 10:19
```so I have removed = and getting this error to while using it with pactflow .. pact-verifier --provider-base-url http://0.0.0.0:8081 \ --pact-url "https://pactflow.co.uk/pacts/provider/UM%20Service/consumer/Supplier%20Hub/latest" \ --pact-broker-username usrname \ --provider-app-version 0.1.0 \ --pact-broker-password pwd \ --publish-verification-results \ --custom-provider-header='Authorization:Bearer Tkn'```


vishwa.amit
2020-08-07 10:20
RESP ```Error: The following Pact files could not be found: "https://pactflow.pacts/provider/UM%20Service/consumer/Supplier%20Hub/latest" Aborted!```

matt.fellows
2020-08-07 10:42
Just confirming that you meant to use `--pact-url` and not `--pact-broker-url` also?

elliottmurray
2020-08-07 14:55
It looked like you were having problems with the custom header (an array) over the pact url? I?m away from a computer right now but IIRC pact url will need an = and custom headers is a list. I?ll try and get you an exact syntax example at some point

elliottmurray
2020-08-08 09:34
as I?m back now I just did a bump release with the bug fix - 1.2.1

maciej.olko
2020-08-08 09:35
thank you, I will try to confirm the fix asap

maciej.olko
2020-08-08 10:04
confirming the fix works, thank you @elliottmurray!

elliottmurray
2020-08-08 10:16
brilliant!

hzhang1
2020-08-10 13:20
has joined #pact-python

hzhang1
2020-08-11 14:13
hello all, anyone has some code sample for using pact-python against graphql endpoint?

ashish_garg5
2020-08-12 10:38
.

lbraymusso
2020-08-12 18:09
if not pact-python, i'm similarly curious if there's any GraphQL reference examples available for the `pactman` library fork :slightly_smiling_face:

matt.fellows
2020-08-13 01:00
You could probably look to the Pact JS repository. There is an example there

matt.fellows
2020-08-13 01:00
GraphQL is just a basic layer on top of HTTP, so it?s doable right now

alecgerona
2020-08-24 03:32
has joined #pact-python

alecgerona
2020-08-24 03:33
Hi all, really interested in implementing Pact for our microservices architecture testing. I'm currently at the last stages of our POC at our company and am currently stuck at implementing the contract verification. For context, we're using a Django backend as the provider with Gitlab CI. I've implemented the webhook that calls the pipeline but that's where it falls short. I'm using the pact-cli docker image to call the `verify` command that will publish the results to our broker. Now this requires a url to replay the requests to. I was hoping to use Gitlab CI to run the Django app for me then just have verify call it since `pact-python`'s `Verifier` class doesn't appear to have a publish option as of yet and/or I haven't yet seen a guide that can run a local instance of a Django app during a pytest run unlike, say, a Flask app that is shown on the `pact-python` example. Problem is it seems like it's not possible for Gitlab CI to run a standalone server on itself if it's using a docker based runner? Am I overcomplicating things or is there a simple way to do this? I would hate for our POC for Pact to be wasted at this final step. Any help is much appreciated. Thank you! Relevant part for pact verification step on my `.gitlab-ci.yml` file: ```test: image: alecgerona/python-docker:python3.6 services: - postgres:11 - docker:dind stage: test script: - build server here - setsid nohup python manage.py runserver > nohup.out & - make verify_publish # Call pact-cli's verify command with appropriate arguments``` Reposting here for relevance.

matt.fellows
2020-08-24 03:33
Thanks, I?ll move my answers heere too

matt.fellows
2020-08-24 03:34
> > I haven?t yet seen a guide that can run a local instance of a Django app during a pytest run unlike, say, a Flask app that is shown on the†`pact-python`†example. I assume there must be a way to startup your Django app like the python example, but I?m not familiar enough with Python to suggest how to do it intelligently

matt.fellows
2020-08-24 03:34
But even if you can?t do that, your `setid nohup?` option should work just fine - is it not working and if so, what?s the issue?

matt.fellows
2020-08-24 03:35
> †Problem is it seems like it?s not possible for Gitlab CI to run a standalone server on itself if it?s using a docker based runner Can you please elaborate on this? What is not possible by running in docker? (running docker in docker, for example might be a pain)

alecgerona
2020-08-24 03:36
> I assume there must be a way to startup your Django app like the python example, but I?m not familiar enough with Python to suggest how to do it intelligently Even if I can do this, `pact-python` has no publish option. It just verifies. I suppose I'll have to fire the webhook manually if I somehow manage to spin up the Django app during the test-runner?

matt.fellows
2020-08-24 03:36
you mean publish the verification results?

alecgerona
2020-08-24 03:38
> But even if you can?t do that, your `setid nohup?` option should work just fine - is it not working and if so, what?s the issue? It runs. Its logs look okay as well. It's just that it's not a valid connection? I keep getting ``Address not available - connect(2) for "localhost" port 8000`` I tried all possible hosts, "localhost", "docker", "0.0.0.0". Nada.

matt.fellows
2020-08-24 03:39
hmmm, that seems very strange and likely some artifact of how your pipeline runs or the CI container.

matt.fellows
2020-08-24 03:39
Is it Pact libraries that are failing or something else?


matt.fellows
2020-08-24 03:39
`--publish-verification-results`

alecgerona
2020-08-24 03:40
Oh not the cli, the internal class for test runner usage. I suppose I can use the cli to avoid the docker in docker scenario...

matt.fellows
2020-08-24 03:40
ahhh

alecgerona
2020-08-24 03:41
So I'm following the e2e example on the Pact guide. It's using a Makefile to centralize all these commands from publish contracts to publishing verification results. That's why I didn't use the cli option.

matt.fellows
2020-08-24 03:41
Should be easy enough to add to the Verifier class - probably faster just to submit a PR and get a new release out than any shims around it

alecgerona
2020-08-24 03:42
Still the same issue about getting the app to run during a test. Afaik it needs a live URL to point to yes?

matt.fellows
2020-08-24 03:42
yes, the HTTP app needs to be started

matt.fellows
2020-08-24 03:43
Is it possible that by the time the verification step runs the server hasn?t yet been started?

matt.fellows
2020-08-24 03:43
i.e. you might need a ?wait for port 8000` to be ready before executing `verify_publish`?

matt.fellows
2020-08-24 03:44
FWIW the underling verification library has a `--wait-for` option, it just doesn?t seem to be exposed in the python interface

matt.fellows
2020-08-24 03:44
again, just a simple flag so easy enough to get in

alecgerona
2020-08-24 03:44
I already added a sleep 10 to the nohup command. And before the verification job happened the nohup command is already on "listening"

matt.fellows
2020-08-24 03:45
can you `curl localhost:8000` type thing in place of the `verify_publish`? Does that work? Just trying to rule out pact problem vs gitlab issue

alecgerona
2020-08-24 03:45
Also, since the Makefile command is using the pact-cli docker image it needs to pull it everytime so that adds to the sleep 10.

alecgerona
2020-08-24 03:46
Okay will try curling it now.

matt.fellows
2020-08-24 03:46
ah, that sounds more like the `verify_publish` command is running in a separate docker container on another network. So no suprises it can?t access the hosts network (by default)

alecgerona
2020-08-24 03:47
This is possible, yes. Is there a way to workaround it?

matt.fellows
2020-08-24 03:47
i.e. from within the pact-cli docker container, `localhost` may not be the same `localhost` as the host system

matt.fellows
2020-08-24 03:47
I?m not familiar enough with your gitlab/docker setup

alecgerona
2020-08-24 03:47
But I think curling the route should work first if that is indeed the case.

matt.fellows
2020-08-24 03:47
yeah

matt.fellows
2020-08-24 03:48
you can kind of prove that problem by running some other arbitrary linux host and doing a curl from that

alecgerona
2020-08-24 03:48
If that is indeed the problem, might be easier to incorporate the pact-cli to my image.

alecgerona
2020-08-24 03:49
My image right now is just python base image with docker support.

matt.fellows
2020-08-24 03:49
what cli command are you actually running in that step, btw?+

alecgerona
2020-08-24 03:49
```verify_publish: @"${PACT_CLI}" \ verify \ --provider ${PARTICIPANT} \ --provider-base-url ${PROVIDER_BASE_URL} \ --consumer-version-selector '{"tag":"master", "latest": true}' \ --consumer-version-selector '{"tag":"staging", "latest": true}' \ --publish-verification-results \ --provider-app-version ${CI_COMMIT_SHORT_SHA} \ --provider-version-tag ${CI_COMMIT_REF_NAME}```

alecgerona
2020-08-24 03:50
where PACT_CLI is ```PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD pactfoundation/pact-cli:latest"```

alecgerona
2020-08-24 03:50
Just like the example.

matt.fellows
2020-08-24 03:50
cool, looks good but just wanted to check!

matt.fellows
2020-08-24 03:51
you may still want the `--wait-for` but as you say, the pull will likely impact it

matt.fellows
2020-08-24 03:52
So my guess is that it?s going to be the network. You may need to explore the various network flags e.g. bridge/host: https://docs.docker.com/network/network-tutorial-host/

matt.fellows
2020-08-24 03:52
again, this advice is without knowing the gitlab dind setup very well

matt.fellows
2020-08-24 03:52
? or at all

alecgerona
2020-08-24 04:14
Will try. I'm currently rerunning the pipeline as I forgot to add the sleep to the new curl so it's connection refused again.

alecgerona
2020-08-24 04:34
@matt.fellows it worked! Haha. It really was because of the docker network. Now to figure out how to access the host network.

matt.fellows
2020-08-24 04:34
:smile:

matt.fellows
2020-08-24 04:35
awesome, well that?s a form of progress :stuck_out_tongue:

alecgerona
2020-08-24 04:35
Weird tho, if I use the pact-cli docker image on my local, localhost works okay.

matt.fellows
2020-08-24 04:36
mac/linux/windows?

alecgerona
2020-08-24 04:36
linux

matt.fellows
2020-08-24 04:36
cool, the default network must be shared with the host

matt.fellows
2020-08-24 04:37
actually, is python running on your host, or another container?

matt.fellows
2020-08-24 04:38
`host <-[Docker [container 1] [container ?]]` (docker next to docker) `host <- [Docker [container 1 [container 2]]` (docker in docker)

alecgerona
2020-08-24 04:38
it's running on the gitlab docker runner

matt.fellows
2020-08-24 04:38
ah ok, no idea how that works

alecgerona
2020-08-24 04:38
```test: image: alecgerona/python-docker:python3.6 services: - postgres:11 - docker:dind stage: test script: - build server here - setsid nohup python manage.py runserver > nohup.out & # HERE - make verify_publish # Call pact-cli's verify command with appropriate arguments```

matt.fellows
2020-08-24 04:38
:man-shrugging:

alecgerona
2020-08-24 04:39
That's what I said.

matt.fellows
2020-08-24 04:39
:smile:

alecgerona
2020-08-24 04:39
I kinda don't like the idea of installing the pact-cli to the base image.

alecgerona
2020-08-24 04:40
Since that would add friction to developer adoption

alecgerona
2020-08-24 04:40
Since they have to install it on their local machines

matt.fellows
2020-08-24 04:40
ah

matt.fellows
2020-08-24 04:41
so you don?t even need the CLI docker image, because pact-python installs the CLI for you anyway

alecgerona
2020-08-24 04:41
but that's the pact-python cli. Not pact-cli.

alecgerona
2020-08-24 04:41
I'm using pact-cli for my Makefile.

matt.fellows
2020-08-24 04:41
actually, pact python installs the _actual_ pact CLI (i.e. the ones the docker cli version exposes)

matt.fellows
2020-08-24 04:42
this may be confusing, I know

alecgerona
2020-08-24 04:42
oh really?

alecgerona
2020-08-24 04:42
Can I call it directly then?

matt.fellows
2020-08-24 04:42
so wait for it. Actually, pact-python wraps a set of Ruby ?binaries? :exploding_head:

alecgerona
2020-08-24 04:42
Okay that I know.

matt.fellows
2020-08-24 04:42
you can just call them directly

matt.fellows
2020-08-24 04:42
ok then it?s not so confusing :stuck_out_tongue:

matt.fellows
2020-08-24 04:42
Those binaries get installed when you install pact-python anyway

matt.fellows
2020-08-24 04:42
I just forget where they go, but probably on some Python path

matt.fellows
2020-08-24 04:43
something like `find <python package dir> -name pact-broker` should help you

alecgerona
2020-08-24 04:44
so my Makefile will call this instead?

matt.fellows
2020-08-24 04:44
```? find /usr/local/lib/python3.8/site-packages -name pact-broker /usr/local/lib/python3.8/site-packages/pact/bin/pact/bin/pact-broker /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/bin/pact-broker /usr/local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.27.0/bin/pact-broker```

matt.fellows
2020-08-24 04:44
there you go

alecgerona
2020-08-24 04:44
No need to download the release binaries from pact-cli? :thinking_face: interesting. In our part of the world downloading from Github is at a breakneck speed of 20 kB/s :smile:

matt.fellows
2020-08-24 04:45
so all of the binaries are in `/usr/local/lib/python3.8/site-packages/pact/bin/pact/bin/` already

matt.fellows
2020-08-24 04:45
(or whatever python equiv for you)

matt.fellows
2020-08-24 04:45
> No need to download the release binaries from pact-cli?†:thinking_face:†interesting. In our part of the world downloading from Github is at a breakneck speed of 20 kB/s†:smile: Ah, I see you have the NBN

alecgerona
2020-08-24 04:46
Hahahah you with NBN? It only happens with Github tho. Maybe they don't have an oceanic/SEA CDN? Idk.

matt.fellows
2020-08-24 04:47
:man-shrugging:

matt.fellows
2020-08-24 04:48
I?m with Aussie Broadband and it?s actually pretty good (I get basically what I paid for 100/20)

matt.fellows
2020-08-24 04:48
Uplink not looking amazing right now, but.. it?s pretty good

alecgerona
2020-08-24 04:50
How much you paying for that?

matt.fellows
2020-08-24 04:51
$89 /mth

matt.fellows
2020-08-24 04:51
It was worth it, doubly so now that we?re all WFH

alecgerona
2020-08-24 04:52
hmm. I'm paying $50 for 50/10.

alecgerona
2020-08-24 04:52
How's your github download speed?

matt.fellows
2020-08-24 04:52
I splurged.

matt.fellows
2020-08-24 04:52
I don?t recall it ever being slow

alecgerona
2020-08-24 04:53
I downloaded the pip source code the other week and wow was it slow. 20 kB/s

matt.fellows
2020-08-24 04:53
I?m working on a few wip repos with binaries in them - not noticing any differeneces

matt.fellows
2020-08-24 04:53
are you with Aussie or somebody else?

matt.fellows
2020-08-24 04:53
Aussie have laid their own sea cables, so they don?t share

alecgerona
2020-08-24 04:54
I'm not in Aus actually :joy:

alecgerona
2020-08-24 04:55
Anyway, so I have pact-python installed. And the only executable I have is the pact-verifier.

matt.fellows
2020-08-24 04:55
ah, sorry. I?m guessing nearby - Tasmania? :stuck_out_tongue:

matt.fellows
2020-08-24 04:56
> Anyway, so I have pact-python installed. And the only executable I have is the pact-verifier. Where is that located?

alecgerona
2020-08-24 04:57
located on my virtualenv's bin.

alecgerona
2020-08-24 04:58
I should already be able to call pact-broker from here right?


matt.fellows
2020-08-24 04:59
they are wrapped by python and not exposed as local binaries, so you?ll need to reference them absolutely for now

alecgerona
2020-08-24 05:00
Ahh.

alecgerona
2020-08-24 05:05
Hmm. Seem to be getting some ruby specific issues.

matt.fellows
2020-08-24 05:05
such as?

matt.fellows
2020-08-24 05:06
just ensure you run the ones _not_ in the `gems` subfolder

matt.fellows
2020-08-24 05:06
e.g. this is a good one `/usr/local/lib/python3.8/site-packages/pact/bin/pact/bin/pact-broker`

alecgerona
2020-08-24 05:06
How do I run the binaries? `sh`?

matt.fellows
2020-08-24 05:07
they should be executable by default, I believe they do need Bash though


matt.fellows
2020-08-24 05:07
(if using Alpine)

alecgerona
2020-08-24 05:07
yup I've tried it. `venv/lib/python3.6/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/bin/pact-broker: line 9: require: command not found` Got this.

alecgerona
2020-08-24 05:08
I think simplest is the pact-verifier exposed by pact-python

matt.fellows
2020-08-24 05:08
strange, because it will literally send the command direct to the same binary

matt.fellows
2020-08-24 05:08
it might be a virtualenv related thing though

matt.fellows
2020-08-24 05:08
but yes, it seems that might be the way to go

matt.fellows
2020-08-24 05:09
any flags missing that are available on the CLI should be a cinch to add, and we?ll merge / release quickly if you need

alecgerona
2020-08-24 05:09
Thank you so much! I'll try incorporating this first and get back to you. Would love to open some PRs regarding docs as I think the python section of it is lacking.

matt.fellows
2020-08-24 05:10
thx, that?d be great

alecgerona
2020-08-24 05:10
Might be nice if we have some great examples good to go for frameworks such as Django and Fastapi.

matt.fellows
2020-08-24 05:10
Elliot has started to pickup a lot of the work here, and would be great to have more contirbutors so let us know how we can support you

alecgerona
2020-08-24 05:10
Developers I believe tend to ask how can I use this new service for my framework.

alecgerona
2020-08-24 05:13
Ah I think I already found an option missing. The `consumer-version-selector`

alecgerona
2020-08-24 05:20
I've created the issue

alecgerona
2020-08-24 06:00
Also @matt.fellows I've noticed that the pact-python cli does not read from environment? Such as the pact-broker-url? Hmm.

elliottmurray
2020-08-24 11:23
Looking at it I think it?s just token and password. Easy to add - you want broker username and url?

alecgerona
2020-08-24 11:44
Hi @elliottmurray, I think username, password, and token should be great. It's the same environment variable as the one with pact-cli's right?

elliottmurray
2020-08-24 11:45
BROKER_USERNAME & PACT_BROKER_BASE_URL?

ashish_garg5
2020-08-24 12:18
Hi, Does pact-python supports MQ communication ? I saw before that it has some restrictions and supports only REST communication. Thanks.

charliemic
2020-08-24 14:15
has joined #pact-python

elliottmurray
2020-08-24 15:03
PACT_BROKER_USERNAME & PACT_BROKER_BASE_URL

elliottmurray
2020-08-24 15:03
I settled on - doing a release

alecgerona
2020-08-24 20:09
AFAIK you have to mock your publisher. Instead of publishing to a real queue you just send the message to Pact.

matt.fellows
2020-08-24 23:42
Awesome, thanks Elliot

matt.fellows
2020-08-24 23:42
they map to the same ones as the CLI - so that?s :ok_hand:

heytaco
2020-08-25 03:57
has joined #pact-python

heytaco
2020-08-25 03:57
Hi there! My name is HeyTaco!, and you can use me to give people tacos to show your appreciation. My tacos will spread joy through Slack!

maciej.olko
2020-08-25 06:35
@elliottmurray :taco:

alecgerona
2020-08-25 09:16
@elliottmurray thanks for the help! :taco:

matt.fellows
2020-08-26 12:15
:tada:

alecgerona
2020-08-27 07:59
Who can I ask to review this? :heartpulse: @elliottmurray? @matt.fellows? Haha

elliottmurray
2020-08-27 12:21
I?ve already looked at it and looking good! I?ll try and carve out some time to test it locally and approve. Assuming I can?t see any issues I?ll merge and release. Probably tomorrow my time?

alecgerona
2020-08-27 14:20
Great! Thanks @elliottmurray!

elliottmurray
2020-08-27 14:25
@alecgerona this one?s for you. Thanks for the contribution.

elliottmurray
2020-08-27 14:25
:taco: @alecgerona

matt.fellows
2020-08-27 23:48
Awesome, thanks Elliot - you just ticked off an item from today?s TODO

matt.fellows
2020-08-27 23:48
@elliottmurray :taco:


elliottmurray
2020-08-28 08:26
Thanks! Done


alecgerona
2020-08-28 13:19
Is there someone who's working on messaging implementation? This is a core requirement for our architecture and would like to take over if people would be willing to guide me.

maciej.olko
2020-08-31 07:21
I don?t know about anyone. There is a small pull request with some changes connected to messaging: https://github.com/pact-foundation/pact-python/pull/119/files

maciej.olko
2020-09-01 13:04
Hi, is there a way in pact-python to match format of dicts which are list elements without fixed order?

gianrubio
2020-09-01 13:51
has joined #pact-python

maciej.olko
2020-09-07 15:50
@elliottmurray could you take a look at my pull request at your leisure? :slightly_smiling_face:

elliottmurray
2020-09-07 18:43
Sorry mate. Been a bit offline last week or two. I?ll have a proper look tomorrow

maciej.olko
2020-09-07 18:45
No worries. Thank you!

elliottmurray
2020-09-08 08:46
Hey. Checked it out and looks good but Beth has one query around the cli flags. We get this to resolution I?ll merge and release. Good work. I?m still learning Python and liked the multi test options!

maciej.olko
2020-09-08 09:26
Ok, thank you!

francesco.bartoli
2020-09-08 09:29
has joined #pact-python

maciej.olko
2020-09-09 08:12
@elliottmurray do we plan to drop support for Python 3.4? that would enable us to use type annotations which make maintenance easier Python 3.4 reached end of life on March 16, 2019 by the way Python 3.5 reaches end of life on September 13th, 2020 so we could also consider dropping its support

elliottmurray
2020-09-09 09:00
I only dropped python 2.7 support a couple of months ago!

elliottmurray
2020-09-09 09:00
But yes we probably should. I?m a little wary - normally needs a bump in versioning

elliottmurray
2020-09-09 09:00
I?ll have a think about it

elliottmurray
2020-09-09 09:01
The thing I struggle with on this is knowing who is using pact and what versions they are running. User testing is hard in OSS it seems

elliottmurray
2020-09-10 09:25
Thanks to @maciej.olko pending flags added to the verifier cli

matt.fellows
2020-09-10 12:17
@maciej.olko :taco:

copalco
2020-09-10 12:53
has joined #pact-python

maciej.olko
2020-09-10 12:54
@copalco :taco:

matt.fellows
2020-09-10 21:39
@elliottmurray :taco: awesome work keeping all of this moving forward!

copalco
2020-09-11 07:59
:taco: @elliottmurray

maciej.olko
2020-09-11 08:00
:taco: @elliottmurray thank you for those releases!

elliottmurray
2020-09-11 08:00
~:taco @copalco~

elliottmurray
2020-09-11 08:01
:taco: @copalco

elliottmurray
2020-09-11 08:01
typo damn it!

elliottmurray
2020-09-11 08:01
Thanks for all the contributions!

elliottmurray
2020-09-11 08:02
I?m going to look at Python deprections now btw but need to gather some stats first

ctelles
2020-09-21 19:05
has joined #pact-python

ajayarooon
2020-09-22 07:56
has joined #pact-python

ajayarooon
2020-09-22 07:58
@here I'm trying to perform contract testing using pact-python. Due to less number of resources, I couldn't proceed. Could anyone please guide me?

matt.fellows
2020-09-22 10:48
:wave:

matt.fellows
2020-09-22 10:48
what help do you need? Perhaps it?s worth trying a workshop in another language, and then looking at https://github.com/pactflow/example-consumer-python and https://github.com/pactflow/example-provider-python

matt.fellows
2020-09-22 10:48
howtolearn

2020-09-22 10:48
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-09-22 10:48
:point_up: workshops

ajayarooon
2020-09-22 13:06
Thanks @matt.fellows. Let me explore it.

bethskurrie
2020-09-25 01:00
There's a pact python question here on stackoverflow if anyone has a minute https://stackoverflow.com/questions/64046658/pact-error-when-trying-to-setup-mock-provider

elliottmurray
2020-09-25 07:21
As I DM?d you I believe this is a configuration issue and am helping him fix it

ajayarooon
2020-09-25 10:11
Yes @bethskurrie. I sought @elliottmurray's help. Posted in stackoverflow before my conversation with Elliot. Thanks anyway!!

nazar.khmil
2020-10-05 10:34
has joined #pact-python

xandebianchi
2020-10-05 13:05
has joined #pact-python

dorin.enache
2020-10-05 15:01
has joined #pact-python

ledinhcuong99
2020-10-06 12:53
has joined #pact-python

dothetan.040490
2020-10-07 09:14
has joined #pact-python

dagostino.remy
2020-10-07 23:03
has joined #pact-python

abhi.nandan
2020-10-08 06:38
has joined #pact-python

przemyslaw.dabrowski
2020-10-08 12:36
has joined #pact-python

emiliano.righi
2020-10-08 13:25
has joined #pact-python

sklein
2020-10-08 15:29
Running into some interesting behavior when using the `Verifier` with `consumer_selectors` where in addition to the correct contracts it also seems to be pulling back the api root as a part of the pacts to verify :shrug:. The pacts return a successful verification but then the ruby library is throwing a `Pact::UnrecognizePactFormatError` because the root payload doesn't contain the `interactions` attribute in the payload. Anybody else run into anything weird like this before?

sklein
2020-10-08 15:32
Here's the stack trace with the company obfuscated

sklein
2020-10-08 15:32
```/home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.1/lib/pact/consumer_contract/consumer_contract.rb:47:in `from_hash': This document does not use a recognised Pact format: {"_links"=>{"self"=>{"href"=>"https://mycompany.pactflow.io", "title"=>"Index", "templated"=>false}, "pb:publish-pact"=>{"href"=>"https://mycompany.pactflow.io/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}", "title"=>"Publish a pact", "templated"=>true}, "pb:latest-pact-versions"=>{"href"=>"https://mycompany.pactflow.io/pacts/latest", "title"=>"Latest pact versions", "templated"=>false}, "pb:tagged-pact-versions"=>{"href"=>"https://mycompany.pactflow.io/pacts/provider/{provider}/consumer/{consumer}/tag/{tag}", "title"=>"All versions of a pact for a given consumer, provider and consumer version tag", "templated"=>false}, "pb:pacticipants"=>{"href"=>"https://mycompany.pactflow.io/pacticipants", "title"=>"Pacticipants", "templated"=>false}, "pb:pacticipant"=>{"href"=>"https://mycompany.pactflow.io/pacticipants/{pacticipant}", "title"=>"Fetch pacticipant by name", "templated"=>true}, "pb:latest-provider-pacts"=>{"href"=>"https://mycompany.pactflow.io/pacts/provider/{provider}/latest", "title"=>"Latest pacts by provider", "templated"=>true}, "pb:latest-provider-pacts-with-tag"=>{"href"=>"https://mycompany.pactflow.io/pacts/provider/{provider}/latest/{tag}", "title"=>"Latest pacts for provider with the specified tag", "templated"=>true}, "pb:provider-pacts-with-tag"=>{"href"=>"https://mycompany.pactflow.io/pacts/provider/{provider}/tag/{tag}", "title"=>"All pact versions for the provider with the specified consumer version tag", "templated"=>true}, "pb:provider-pacts"=>{"href"=>"https://mycompany.pactflow.io/pacts/provider/{provider}", "title"=>"All pact versions for the specified provider", "templated"=>true}, "pb:latest-version"=>{"href"=>"https://mycompany.pactflow.io/pacticipants/{pacticipant}/latest-version", "title"=>"Latest pacticipant version", "templated"=>true}, "pb:latest-tagged-version"=>{"href"=>"https://mycompany.pactflow.io/pacticipants/{pacticipant}/latest-version/{tag}", "title"=>"Latest pacticipant version with the specified tag", "templated"=>true}, "pb:webhooks"=>{"href"=>"https://mycompany.pactflow.io/webhooks", "title"=>"Webhooks", "templated"=>false}, "pb:webhook"=>{"href"=>"https://mycompany.pactflow.io/webhooks/{uuid}", "title"=>"Webhook", "templated"=>true}, "pb:integrations"=>{"href"=>"https://mycompany.pactflow.io/integrations", "title"=>"Integrations", "templated"=>false}, "pb:pacticipant-version-tag"=>{"href"=>"https://mycompany.pactflow.io/pacticipants/{pacticipant}/versions/{version}/tags/{tag}", "title"=>"Get, create or delete a tag for a pacticipant version", "templated"=>true}, "pb:metrics"=>{"href"=>"https://mycompany.pactflow.io/metrics", "title"=>"Get Pact Broker metrics"}, "pb:can-i-deploy-pacticipant-version-to-tag"=>{"href"=>"https://mycompany.pactflow.io/can-i-deploy?pacticipant={pacticipant}&version={version}&to={tag}", "title"=>"Determine if an application can be safely deployed to an environment identified by the given tag", "templated"=>true}, "pb:provider-pacts-for-verification"=>{"href"=>"https://mycompany.pactflow.io/pacts/provider/{provider}/for-verification", "title"=>"Pact versions to be verified for the specified provider", "templated"=>true}, "beta:provider-pacts-for-verification"=>{"name"=>"beta", "href"=>"https://mycompany.pactflow.io/pacts/provider/{provider}/for-verification", "title"=>"DEPRECATED - please use pb:provider-pacts-for-verification", "templated"=>true}, "curies"=>[{"name"=>"pb", "href"=>"https://mycompany.pactflow.io/doc/{rel}?context=index", "templated"=>true}, {"name"=>"beta", "href"=>"https://mycompany.pactflow.io/doc/{rel}?context=index", "templated"=>true}], "pb:api-tokens"=>{"href"=>"https://mycompany.pactflow.io/settings/tokens", "title"=>"API tokens", "templated"=>false}, "pb:audit"=>{"href"=>"https://mycompany.pactflow.io/audit", "title"=>"Audit trail", "templated"=>false}, "pb:secrets"=>{"href"=>"https://mycompany.pactflow.io/secrets", "title"=>"Secrets", "templated"=>false}, "pf:admin-users"=>{"href"=>"https://mycompany.pactflow.io/admin/users", "title"=>"Admin users", "templated"=>false}, "pf:admin-teams"=>{"href"=>"https://mycompany.pactflow.io/admin/teams", "title"=>"Admin teams", "templated"=>false}, "pf:admin-system-accounts"=>{"href"=>"https://mycompany.pactflow.io/admin/system-accounts", "title"=>"System accounts", "templated"=>false}}} (Pact::UnrecognizePactFormatError) from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.15.1/lib/pact/consumer_contract/consumer_contract.rb:52:in `from_json' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/provider/rspec.rb:34:in `honour_pactfile' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/provider/pact_spec_runner.rb:125:in `block in initialize_specs' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/provider/pact_spec_runner.rb:119:in `each' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/provider/pact_spec_runner.rb:119:in `initialize_specs' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/provider/pact_spec_runner.rb:33:in `run' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/cli/run_pact_verification.rb:69:in `run_with_pact_uri_object' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/cli/run_pact_verification.rb:50:in `run_specs' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/cli/run_pact_verification.rb:21:in `call' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-1.51.1/lib/pact/cli/run_pact_verification.rb:13:in `call' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:171:in `verify_pact' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:43:in `block in call' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:42:in `collect' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:42:in `call' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/app.rb:34:in `call' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/cli/verify.rb:47:in `verify' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.32.1/lib/pact/provider_verifier/cli/custom_thor.rb:17:in `start' from /home/vscode/.local/lib/python3.8/site-packages/pact/bin/pact/lib/app/pact-provider-verifier.rb:33:in `<main>' INFO: Reading pact at https://mycompany.pactflow.io ```

cariaga.bh
2020-10-08 21:03
has joined #pact-python

matt.fellows
2020-10-08 23:57
hmm

campellcl
2020-10-09 00:06
has joined #pact-python

elenitsaa043
2020-10-09 10:00
has joined #pact-python

adriangabrieloros
2020-10-09 11:05
has joined #pact-python

adriangabrieloros
2020-10-09 11:06
hey guys, i just opened an issue -> https://github.com/pact-foundation/pact-python/issues/176 if there is anything I can do to help, let me know. cheers

elliottmurray
2020-10-09 11:11
I?ve responsed - thanks for that

elliottmurray
2020-10-09 11:11
I just want a quick clarification on something

adriangabrieloros
2020-10-09 11:14
responded :smile:


elliottmurray
2020-10-09 11:25
Would that fix it?

adriangabrieloros
2020-10-09 11:32
think so, by the looks of it

elliottmurray
2020-10-09 11:54
@adriangabrieloros I?ve pushed a release just now (1.2.7) Give it five minutes to publish and let me know if any problems

adriangabrieloros
2020-10-09 11:55
okay, will wait

elliottmurray
2020-10-09 11:57
Shouold be there now

sh.ilgam_pact
2020-10-11 16:13
has joined #pact-python

anastasiia.bielik
2020-10-12 11:13
has joined #pact-python

deepika.krishnakumar
2020-10-12 15:03
has joined #pact-python

anbansal27
2020-10-12 23:02
has joined #pact-python

prabhakar.thippa
2020-10-13 04:58
has joined #pact-python

giadinhluong
2020-10-13 06:24
has joined #pact-python

pavank
2020-10-13 08:41
has joined #pact-python

stephane.meng
2020-10-13 09:06
has joined #pact-python

abirlal.bose
2020-10-13 09:45
has joined #pact-python

campellcl
2020-10-13 23:13
Hey all, got a noob question for you. In the Serverless JS example of pact available here: https://github.com/pact-foundation/pact-js/blob/7174a7c1fdf40425df262a93ee73fcaacbf429c5/examples/serverless/provider/message-provider.spec.js#L14 they actually exercise the producer's logic during the pact verification test on the producer side. In the Python version of this available here: https://github.com/pact-foundation/pact-python/blob/master/examples/e2e/tests/provider/test_provider.py#L66 the logic does not appear to use the provider at all. I understand that they are using an external server to configure the pact provider states. But shouldn't the Python Producer logic still be executed to get the response from the producer that is compared against the pact? I'm having trouble figuring out where the output of the producer should go when calling `verifier.verify_pacts(...)` on the producer side. What am I missing here?

bethskurrie
2020-10-13 23:15
I wrote the underlying verification engine that the python lib uses, but I'm not familiar with the python lib itself.

bethskurrie
2020-10-13 23:15
Under the hood, it starts an HTTP server, that then makes the call to the producer code to get the message, and then verify it against the pact.

bethskurrie
2020-10-13 23:16
The reason there is a proxy in the middle is to allow us to re-use the existing verification infrastructure, and provider a technology agnostic interface between the verifier and the producer.

bethskurrie
2020-10-13 23:17
under the hood, I would expect there to be some configuration that hooks the proxy up to the producer.

bethskurrie
2020-10-13 23:17
it may just be that this particular example isn't actually exercising any producer logic.

campellcl
2020-10-13 23:20
Well, then, I guess my question becomes: How do I exercise the producer logic in the python version of pact? Does anyone have a good example of this where the provider logic is actually included in the `verifier.verify_pacts(...)` call? Because from the source code here: https://github.com/pact-foundation/pact-python/blob/f4787ed659a84eae28622f0ac84d3af78f0ee371/pact/verifier.py#L33 it is not at all evident that the method can take the actual output of the provider to do a comparison against the existing pact. Unless its in the `**kwargs` , but I can't find any documentation on this as it pertains to the Python lib.

campellcl
2020-10-13 23:21
In the readme, they also don't actually use the output of the provider in the verification: https://github.com/pact-foundation/pact-python#python-api

bethskurrie
2020-10-13 23:21
@matt.fellows?s fingerprints are all over that file, but it looks pretty old. He may be able to remember how it works.

campellcl
2020-10-13 23:26
Hopefully @matt.fellows will come to the rescue yet again. haha. I'm starting to get the feeling that Python is not really a first class citizen here. :grin: Or at least, not using the same architectural paradigms as on the Node side of things.

bethskurrie
2020-10-13 23:26
It's not.

bethskurrie
2020-10-13 23:26
It's a sad fact.

campellcl
2020-10-13 23:26
I also checked out @matt.fellows example here: https://github.com/pactflow/example-provider-python/blob/master/app/main.py but that doesn't really give me a clear picture of how the provider verification is supposed to work in code. It is helpful for the CI/CD setup however.

bethskurrie
2020-10-13 23:27
Node and JVM get the most attention.

matt.fellows
2020-10-13 23:27
So I?ll qualify with I?m not a python expert

matt.fellows
2020-10-13 23:27
The JS example you linked to is specifically for messages (think MQ etc.), but the process is similar for regular HTTP provider verification

matt.fellows
2020-10-13 23:28
I know Elliot is working to tidy up and improve the Python project - you?ll see it?s under quite active development

matt.fellows
2020-10-13 23:29
for provider verification, I think the example you referred to does actually exercise the real provider

matt.fellows
2020-10-13 23:29
I think the example is misleading though, because of prefixes like `PACT_MOCK_`


matt.fellows
2020-10-13 23:30
If I read that correctly, it?s starting a new server using `app` (which is the actual provider code)

matt.fellows
2020-10-13 23:30
The verifier then uses a local pact json file as the contract source

matt.fellows
2020-10-13 23:31
I think you?d use `verify_with_broker` for pactflow with the `broker_token` auth option: https://github.com/pact-foundation/pact-python/blob/f4787ed659a84eae28622f0ac84d3af78f0ee371/pact/verifier.py#L61

matt.fellows
2020-10-13 23:31
The example I put together used the CLI verifier, literally because I had less than one hour to scrap together a python example for a demo

matt.fellows
2020-10-13 23:32
honestly though, in many cases, the CLI verifier is what you want (in fact, at least one of the maintainers things it?s a better approach altogether and I have put forward a case that we should improve the CLI and do away with language specific verifiers altogether - but that?s another thing)

campellcl
2020-10-13 23:33
Good to know, thanks Matt! Yup it does seem to be actively maintained, always a plus. So, I see that they are starting a flask server. I see them passing the provider server to the `test_get_user_non_admin(...)` method as a PyTest test fixture. I don't see them ever using `provider` in that context though. And looking at https://github.com/pact-foundation/pact-python/blob/f4787ed659a84eae28622f0ac84d3af78f0ee371/pact/verifier.py#L61 its the same problem. No where does that method take the actual output of the provider to send to the broker for verification.

campellcl
2020-10-13 23:34
I'm just confused on how you can verify a pact without providing the output from the provider.

matt.fellows
2020-10-13 23:34
That method simply invokes the underlying CLI process Beth was alluding to (the very same CLI I use in my demo you linked to)

matt.fellows
2020-10-13 23:35
so https://github.com/pact-foundation/pact-python/blob/f4787ed659a84eae28622f0ac84d3af78f0ee371/pact/verifier.py#L85 is the argument that is passed to the CLI, which in turn will issue HTTP requests to that flask server

matt.fellows
2020-10-13 23:35
`test_get_user_non_admin` -> `verify_pacts` -> `underlying provider verifier CLI` -> `calls your actual provider over HTTP`

matt.fellows
2020-10-13 23:36
something like that

matt.fellows
2020-10-13 23:36
Have you tried running it? If you add logging, you?ll see the actual server is hit. You should be able to alter how it responds to see if it breaks the contract

matt.fellows
2020-10-13 23:36
suffice to say - if it _doesn?t_ actually call the provider, this is a bad thing!

campellcl
2020-10-13 23:42
That is very helpful, thanks Matt. I see what you are saying now about the Python implementation being a wrapper for the CLI. Looking at the CLI documentation helps: https://github.com/pact-foundation/pact-python#cli Your right, it appears to be issuing calls to the provider at the localhost address to retrieve the providers output.... although that documentation is not very clear as well. They appear to be passing local files to `--pact-url=...` which I assume is overloading what that argument would actually be if the provider was not running on localhost.

matt.fellows
2020-10-13 23:43
So the provider base URL passes the address of the running service - whether it?s running on localhost or somewhere else

matt.fellows
2020-10-13 23:44
the pact URL is where to find the contract - most of the time this will be from the pact broker, but in the example here it?s using a locally stored contract file (presumably to prevent flakiness in the test suite)

campellcl
2020-10-13 23:49
Right, that was my interpretation. In our case, we would be running the verification code inside Python though. The code itself would be producing the output to be fed to the `--provider-base-url`. Our logic would not necessarily have a host behind it (localhost or otherwise). That's somewhat on us. We have a serverless IaaS application. So we don't really have a dedicated producer and consumer pipeline. Sometimes our lambdas are producers, and sometimes they are consumers. We want pacts in place to cover both functionalities, when the lambda is producing, and when the lambda is consuming. But we don't necessarily want to open up our lambda endpoint to API Gateway just for pact to be able to issue HTTP requests to the endpoint. Instead, we would rather run our lambda locally, take the output JSON that in production would be serialized and send over HTTP, and we want to relay that to the pact broker for verification.

campellcl
2020-10-13 23:49
It's looking like that is not really feasible?

matt.fellows
2020-10-13 23:50
aha - yes this is referred to as message pacts

campellcl
2020-10-13 23:51
Is there support for message pacts in Python like there is in the NodeJS version?

matt.fellows
2020-10-13 23:52
I believe there are a few open issues for it, but it looks like currently no

campellcl
2020-10-13 23:53
Or do you have to use the CLI and target localhost or a running provider?

campellcl
2020-10-13 23:53
Dang it.

matt.fellows
2020-10-13 23:53
From last talking to Elliot (a new core contributor) he was refactoring the provider verification first as a pre-requisite to doing the message bit

matt.fellows
2020-10-13 23:53
as you saw in the NodeJS example, there is some infrastructure required to make that work (basically, the ?architecture? is a transparent proxy that registers handlers etc.)

matt.fellows
2020-10-13 23:54
So you have a couple of options


matt.fellows
2020-10-13 23:54
(I can?t vouch for it?s goodness)

campellcl
2020-10-13 23:55
Ah, so I'm too early. Hmmmm. Well that's a bummer.

matt.fellows
2020-10-13 23:55
I know others have added a test-phase-only HTTP server in front of their lambdas/message functions and used the standard tooling. It?s a bit shit, but I believe it should work

matt.fellows
2020-10-13 23:56
alternatively, the underlying infrastructure is there and I can give you some pointers

campellcl
2020-10-14 00:03
Good to know. I'm unfortunately fighting an uphill battle here with management. They are wondering why it is taking so long to implement a testing framework. I was able to sell them on Pact because of the multi-language support (as our other dev uses NodeJS). I'll have to relay that information to the higher-ups and see if they are still willing to approve additional dev time on the testing infrastructure. I know that we are using pact not really in the way it was meant to be used. So thanks a ton for taking the time to explain all of the above. Your explanations were super helpful. That definitely gives me three paths to go forward with. Let me see what the consensus is on the dev team, about how they want to proceed and i'll be sure to let you know!

campellcl
2020-10-14 00:04
HTTP server is not a bad idea for a workaround.

matt.fellows
2020-10-14 00:04
no, you are definitely _not_ using it the way it?s not intended to be used

matt.fellows
2020-10-14 00:04
Everything you?re asking for is totally reasonable

matt.fellows
2020-10-14 00:05
(I use AWS/lambda/kinesis etc. heavily and Pact is perfectly suited to those use cases)

bethskurrie
2020-10-14 00:06
> I know others have added a test-phase-only HTTP server in front of their lambdas/message functions and used the standard tooling. @tjones had a nice pattern for this. Having done some pact work with some offline serverless stuff that required docker containers to start up each time you needed to run tests, I 100% prefer the little http wrapper. It's so much quicker.

bethskurrie
2020-10-14 00:06
I don't want to wait 30 seconds for a docker container to start every time I want to run my pact tests.

bethskurrie
2020-10-14 00:07
Insert eye stabbing emoji

matt.fellows
2020-10-14 00:07
:point_up: I think you?re referring to SAM. the serverless framework is much better

bethskurrie
2020-10-14 00:07
You're probably right.

matt.fellows
2020-10-14 00:07
(in that specific regard)

campellcl
2020-10-14 00:07
@matt.fellows Well I can tell from the documentation that it seems to be designed for more traditional HTTP workflows with dedicated producer and consumer build pipelines that are seperate. That doesn't really fit too well with the Serverless IaaS infrastructure. There isn't really a concept of a separate build pipeline.

bethskurrie
2020-10-14 00:07
I get confused between Serverless and generic serverless.

campellcl
2020-10-14 00:07
Oh yeah, Serverless is way better than SAM.

matt.fellows
2020-10-14 00:08
> There isn?t really a concept of a separate build pipeline. We?ll have to agree to disagree there in general terms, but I think your point is that it?s common for a single ?serverless app? to have many discrete components that are still deployed together, which is very common indeed

campellcl
2020-10-14 00:12
Yes, that is what I meant. What is a "provider build pipeline" and "consumer build pipeline" in the serverless context? There isn't a clear cut definition. That clear cut distinction in tutorials such as: https://docs.pactflow.io/docs/workshops/ci-cd/set-up-ci/ is what made me think I wasn't really using pact for what it was intended to be used for. Although, clearly it can still be used in our context, hence me being here right now trying to get it to work haha.

matt.fellows
2020-10-14 00:12
Yes, our documentation / workshops are lacking in this space, so I can see how many people would have this very impression

campellcl
2020-10-14 00:18
@bethskurrie We already have a pretty complex build process. Running dockerized Jenkins in EC2 (with a persistent EFS store), with https://hub.docker.com/r/lambci/lambda/ as the underlying docker configuration for our Jenkin's build agents. So although we are not opposed to running more docker containers.... as I previously mentioned, whenever we start running docker-in-docker-in-docker that's when I start questioning my sanity. Which is partially why we were avoiding the dockerized pact CLI. haha

campellcl
2020-10-14 00:19
@matt.fellows The CI/CD workshop is great! But yeah, having one for Serverless would be good. As well as Jenkins. Although I understand that TravisCI is way easier to set up for demo purposes than Jenkins can be.

matt.fellows
2020-10-14 00:59
I actually wrote one for a customer (albeit it was in Go) and was hoping to open source that. But then we need to 11x it to _all the languages_. You can see the challenge!

elliottmurray
2020-10-14 09:11
I think I?m not needed here! But to confirm?

elliottmurray
2020-10-14 09:11
I did make some changes to start putting in native Python features but haven?t added new ones in a while as I?m not personally using it and not sure what people out there are. If there?s a strong push to get a messaging or serverless example could plan that out.

matt.fellows
2020-10-14 09:17
Cc: @sklein if I recall you may have wanted this?

mateusz.mrzyglod
2020-10-14 09:32
has joined #pact-python

cathleen.yuan
2020-10-14 11:16
has joined #pact-python

ramana.jaladurgam
2020-10-14 16:10
has joined #pact-python

ramana.jaladurgam
2020-10-14 16:12
HI, https://docs.pact.io/implementation_guides/python/ Pact Python doesn't seem to support AMQP based tests. Is there any plan to upgrade Pact Python or any alternatives for writing AMQP based tests on python tests. Thank you for the references.

alik.berezovsky
2020-10-14 18:38
has joined #pact-python

a.robecke
2020-10-14 19:24
has joined #pact-python

campellcl
2020-10-14 19:46
@elliottmurray We could definitely use it. I'm about to be instructed not to use Pact specifically because we can't get Message Pacts working with the Python producer verifier in a trivial way. I was about to implement @matt.fellows?s solution of having an API Gateway and lambda function which the CLI can hit as the `--provider-base-url`. But that lambda method will then need to handle the routing to the actual provider logic. I'm not convinced that what is sent by the pact CLI is enough to do that routing. I will most likely have to include the intended lambda ARN in the pact itself, only for the purposes of routing based on that ARN. That's overall a pretty hacky solution for getting it to work in Python. The alternative would be to stick an HTTP API Gateway in front of every single lambda method, which we aren't going to do. More importantly, having to hit an external API Gateway endpoint means that I can no longer run pact verification tests locally. I have to deploy the full platform, in order to run pact tests against the live endpoint. Which defeats the purpose of the async testing paradigm.

campellcl
2020-10-14 19:46
But I can't speak to the popularity of Pact among other Python devs.

campellcl
2020-10-14 19:47
For us it may end up being the difference between rolling our own bare-bones solution, and leveraging Pact.

campellcl
2020-10-14 20:24
Does anyone know where I can find the CLI documentation specifically for https://github.com/pact-foundation/pact-ruby-standalone? Does this take the same commands as the Pact Broker CLI, or the Pact CLI?

mikahchapman
2020-10-14 21:47
has joined #pact-python

matt.fellows
2020-10-14 23:00
Thanks Chris

matt.fellows
2020-10-14 23:00
it?s helpful feedback!

matt.fellows
2020-10-14 23:00
Just so my point is clear though

matt.fellows
2020-10-14 23:00
I?m _not_ suggesting putting an API gateway in front of your lambdas - that would result in a number of complications as you?ve mentioned

matt.fellows
2020-10-14 23:01
I?m suggesting (and have suggested to others in the past) to be able to abstract away your function code (essentially the lambda handler) from the exact runtime - which in this case is the Lambda runtime. One approach is to put a really simple http wrapper (e.g. with Flask/FastAPI) in front of your lambda function, and then use standard HTTP pact

matt.fellows
2020-10-14 23:02
this way you can still run locally and do all of those things

matt.fellows
2020-10-14 23:02
If you go down the pact path. Of course, a message pact contribution would be awesome :stuck_out_tongue:

matt.fellows
2020-10-14 23:03
@ramana.jaladurgam saw your question in the channel - please see this thread :point_up:


matt.fellows
2020-10-14 23:04
this sort of thing?

matt.fellows
2020-10-14 23:04
The pact broker CLI is one of the utilities provided in that package

campellcl
2020-10-14 23:31
@matt.fellows Thank you for clarifying. I had misunderstood you! That is a much better idea than my misinterpretation of what you said. If I am understanding you correctly now, you think we should do: PactPythonLib -> PactRubyCLI -> LocalFlaskServer -> LocalPythonLambda Is that right? Basically have the localhost Flask service perform the routing to the lambdas on disk? The idea is that the Pact CLI can then still hit the flask server as the provider endpoint, while still executing locally?

matt.fellows
2020-10-14 23:47
yes! exactly

matt.fellows
2020-10-14 23:48
I?ve had this idea for a ?recipe? book for these sorts of (current edge cases) but also other things - i?ll try and prioritise in the next week or so.


hem_kec
2020-10-15 00:44
has joined #pact-python

campellcl
2020-10-15 01:02
@elliottmurray I can't get example https://github.com/pact-foundation/pact-python/tree/master/examples/e2e to run and pass all the test cases, only 2/3 pass. I have the broker up and running per your instructions (although Docker desktop threw an error warning about using windows files when WSL2 is being used instead of the Windows Hypervisor so you might want to look into that). The broker appears to be working though, I can login and see the pact broker screen. But running `pytest` in the `e2e` root directory returns an error in `e2e/tests/provider/test_provider.py` on line 54 when the Flask server is supposed to start with: `server.start()`. It looks like an internal Flask error.

campellcl
2020-10-15 01:07
Also, you might want to cleanup the command arguments in `e2e/README.md` on lines 14-17. You may have meant to have them in the `bash` section of the markdown. I'm using Anaconda and can't get `pipenv` to work inside Anaconda. So I just ran `pip install -r requirements.txt` and `pip install ../../` then skipped the `pipenv` section of the readme. Which might be part of the problem. Have you encountered this issue with `pipenv install` from within Anaconda?

campellcl
2020-10-15 01:11
Anaconda works nicely with `pip` but I'm not sure how nicely it plays with `pipenv`. I get `Failed to create virtual environment` with `pipenv` looking for a file/directory that does not exist in the Anaconda `Anaconda3/venv/scripts/nt/python.exe` directory.

campellcl
2020-10-15 01:16
So for me at least @matt.fellows, the current python example in `master` does not run fully.

elliottmurray
2020-10-15 08:59
So pipenv was inherited from a previous example. To keep it simpler I can probably remove that. It does manage having a separate virtualenv for examples a bit easier.

elliottmurray
2020-10-15 08:59
Thanks for pointing out the readme. I?ll have a look

elliottmurray
2020-10-15 09:12
So I checked Makefile and it is using plain old pip for examples in CI. I think that should be ok and I?ve updated the readme to reflect that

elliottmurray
2020-10-15 09:13
I?m not sure I can help you with Anaconda/Flask. I suspect it will be to do with processes

elliottmurray
2020-10-15 09:14
You can share some of the stack trace and I can see if something is obvious

marco.cordeiro
2020-10-15 10:54
has joined #pact-python

adriangabrieloros
2020-10-15 11:39
hey guys! j have a question: can we use pact for contract tests that involve kafka and not endpoints? thanks

betty.he
2020-10-15 14:32
has joined #pact-python

maciej.olko
2020-10-15 14:50
hi, unfortunately pact-python doesn?t support messaging contracts yet

seda.urguplu6
2020-10-15 15:15
has joined #pact-python

seda.urguplu6
2020-10-15 15:42
Hi everyone. I wrote only a basic consumer side test using pact-python. It takes more than 1 minute for start_service() method to run. Also as I see in the pact-mock-service.log, test completed in 4 minutes. Is there a problem with me or is it a normal situation?

elliottmurray
2020-10-15 17:19
That is a lot longer than it takes for me

matt.fellows
2020-10-15 23:23
hi @adriangabrieloros take a look at this thread: https://pact-foundation.slack.com/archives/C9VECUP6E/p1602630833022400

matt.fellows
2020-10-15 23:24
There is a strategy to do this sort of thing, I?d like to document it up to make it easy for people to understand

matt.fellows
2020-10-15 23:24
To be honest, it?s not a huge amount of work to add to python library itself (based on my experience doing it for both JS and Go). It should be a couple of days work MAX

matt.fellows
2020-10-15 23:24
so if you wanted the feature, and didn?t want to spend as much time doing workarounds, a contribution would be the simplest way forward (I think)

tamer
2020-10-16 09:08
has joined #pact-python

mario.gioiosa
2020-10-16 18:57
has joined #pact-python

campellcl
2020-10-16 19:01
@matt.fellows @bethskurrie Me and @elliottmurray were discussing the Python side of things. It turns out that it is non-trivial to get the example logic working on a Windows machine due to a bug in the `multiprocessing` module on Windows. The guys over at Flask do not recommend running Flask in a separate thread the way it is being leveraged currently in `pact-python`. It's looking like Pact is going to need to fundamentally revisit how it does things on the Python side in order to support Windows with the multiprocessing constraints. After looking into this for 8+ hours I do not believe this will be a couple days of work to fix. The Flask guys were adamant about using their `test_client` instead of a seperate thread. The `test_client` does not dispatch external HTTP calls, and as such cannot be used with `pact-python` to dispatch HTTP calls via the Ruby CLI to the Flask server.

campellcl
2020-10-16 19:03
Since using the `test_client` will not work with the Python wrapper around the Ruby CLI, they suggested using a separate process to spin up the Flask server and then returning control to Pact to handle the `Verifier` logic. That is not an ideal solution by any means. The other suggestion they gave was to use a proper WSGI server in conjunction with Flask. This is also outside the purview of Pact's currently functionality.

campellcl
2020-10-16 19:06
So, in its current state. It appears that `pact-python` does not fully support Windows. The pact mock provider needs to be run externally of Pact, and monitored for deployment, before returning control to the Pact `Verifier` to dispatch calls via the Python wrapper (and hence the Ruby CLI) over HTTP on localhost.

campellcl
2020-10-16 19:15
In short, that is rather a mess. And it isn't at all easy to set up, defeating the purpose of Pact. I would strongly consider dropping support for Windows, or revisiting the idea of sending HTTP calls via the Ruby CLI (where the Python logic cannot intercept or modify the payloads). Ideally, I should be able to use the Flask `test_client` with the Pact `Verifier` internally, without needing to dispatch the actual HTTP call to the Pact mock provider. If you want to keep the paradigm of making the actual HTTP call (to simulate the network stack fully) then you have some non-trivial architectural decisions to make, in relation to supporting Python on the Windows environment with Flask.

simon.nizov
2020-10-17 12:56
Heya! Can we add the Hacktoberfest Topic/Label to the `pact-python` repo? :smile: https://hacktoberfest.digitalocean.com/hacktoberfest-update

elliottmurray
2020-10-17 14:11
@beth or @matt.fellows I?ll need you to do this I think. I?m not admin

matt.fellows
2020-10-17 21:34
done, sorry I thought I?d added them

matt.fellows
2020-10-17 21:40
The longer term plan is to use a shared library written in Rust (see https://github.com/pact-foundation/pact-reference). It?s currently used in a few of the implementations, and is in beta for JS. Hopefully in the next few months we?ll roll out the Golang and Swift iOS editions. It?s going to take some time to fully migrate of course, so it?s sad to hear stories like this (we know of some related underlying Ruby bundling issues, but this is a new one)

matt.fellows
2020-10-17 23:57
For now, I'd recommend running the CLI verifier directly (as per the example I think you've seen that uses Docker) - that's of course if you even stick with Pact!

alik.berezovsky
2020-10-18 17:58
@alik.berezovsky has left the channel

lior.baber
2020-10-19 07:33
has joined #pact-python

matt.fellows
2020-10-19 13:27
@simon.nizov thanks for your contributions! :taco:

simon.nizov
2020-10-19 14:23
Got that Hacktoberfest spirit :all_the_things:

jeffbdye
2020-10-19 17:10
has joined #pact-python

jace
2020-10-19 19:22
has joined #pact-python

almaak
2020-10-20 09:35
has joined #pact-python

andra.moraru
2020-10-20 14:13
has joined #pact-python

camila.coder91
2020-10-20 17:06
has joined #pact-python

julzelements
2020-10-21 05:25
has joined #pact-python

kapil.mathur
2020-10-21 06:40
has joined #pact-python

kapil.mathur
2020-10-21 06:43
Hi team, I am trying to install pact-python in a python 3.8.2 virtualenv but its failing with a huge stack track complaining about something regarding the psutil package which seems to be a dependancy for pact-python this is the shorter version of the error i am getting ``` Running setup.py clean for psutil Failed to build psutil Installing collected packages: psutil, pact-python Running setup.py install for psutil ... error```

kapil.mathur
2020-10-21 06:44
has anyone else faced this issue as well.. if yes plz help me out

kapil.mathur
2020-10-21 06:44
Also sending the complete stacktrace below

kapil.mathur
2020-10-21 06:45
Any help is highly appreciated as this is a bit urgent for me..thanks in advance

maciej.olko
2020-10-21 06:51
which version of pip do you use?

maciej.olko
2020-10-21 06:51
have you tried with most recent version?

kapil.mathur
2020-10-21 08:34
actually i just upgraded my python3 version to 3.8.5 from 3.8.2 (installed 3.8.5 basically)

kapil.mathur
2020-10-21 08:34
and psutil got installed with the latest version

kapil.mathur
2020-10-21 08:35
and then the pact-python got installed with version1.2.9 as well

kapil.mathur
2020-10-21 08:35
basically just bumping the virtual env p ython3 version helped :neutral_face:

maciej.olko
2020-10-21 08:35
:+1:

mark.hudson
2020-10-21 10:45
has joined #pact-python

cluu
2020-10-21 17:16
has joined #pact-python

camila.campos
2020-10-21 21:35
has joined #pact-python

ajayarooon
2020-10-22 05:40
Hello People, Could someone please help me with setting up pact-broker using python? I succesfully created the consumer pact file. I'm a bit clueless how to move forward from here. Any help would be greatly appreciated

maciej.olko
2020-10-22 05:42
Hello, pact-broker is available as a Docker image, that?s the easiest way to set it up. Or do you mean setting up a connection with pact-broker?

ajayarooon
2020-10-22 06:18
@maciej.olko Thank you for the reply. Sure, I'll explore it. You're right, I'm trying to set up a connection with pact-broker.

maciej.olko
2020-10-22 06:25
The easiest way should be setting `publish_to_broker=True` in `has_pact_with()` method: ```Consumer('foo').has_pact_with( 'bar', publish_to_broker=True, broker_base_url="http://localhost:8000" )```

longlevan
2020-10-22 09:15
has joined #pact-python

ashish_garg5
2020-10-22 09:55
Hi All, I am trying to make use of provider_states_setup_url, but no matter whatever values i pass in response it's always passing. I am using the below line in my .verify_with_broker ```provider_states_setup_url="{}/_pact/provider_states".format(pact_mock_url)``` And added the below method for states mapping ```@app.route('/_pact/provider_states', methods=['GET', 'POST']) def states(): mapping = { 'get inventory': {"productName": "Laptops", "locationName": "Bangalore", "quantity": 1000} } mapping[request.json['state']]() return jsonify({'result': request.json['state']})``` Now if i change this get inventory response also then also build is not failing, it means it's not checking the state response at all. Could someone please help me. Not sure what i am missing here. Thanks.

justin.garfield
2020-10-22 16:15
has joined #pact-python

guppy0356.nakira
2020-10-23 00:34
has joined #pact-python

guppy0356.nakira
2020-10-23 00:43
Hi Team

guppy0356.nakira
2020-10-23 00:46
I try to use pact-python in Lmabda(Python) + WebAPI. `pact-python` is great package but it is not suitable in my case. I think following step is better. Would you give me some comments? Of course, It is not perfect because if Lambda use RDS, I have no idea to setup test dataset. ```1. Run `sam local start-api` 2. Run `pact-provider-verifier` 3. Check exit status code```

matt.fellows
2020-10-23 00:49
is https://pypi.org/project/webapi/ what you mean by WebAPI?

matt.fellows
2020-10-23 00:50
> Of course, It is not perfect because if Lambda use RDS, I have no idea to setup test dataset. I would either a) use a docker database locally or b) stub the database layer entirely for these tests

matt.fellows
2020-10-23 00:50
so when you run `sam local start-api` you might need to have a test variant, which has all downstream/external dependencies stubbed

matt.fellows
2020-10-23 00:51
What you?re suggesting is reasonable, I think

guppy0356.nakira
2020-10-23 00:55
Oops! WebAPI is not correct expression. It's API Gateway which is content in AWS.

matt.fellows
2020-10-23 00:56
OK yes that?s what I thought

matt.fellows
2020-10-23 00:57
Then I would go with your solution indeed. No need to use the Python verifier package, and you can use the same strategy for any other language behind API gateway too

guppy0356.nakira
2020-10-23 01:01
> you can use the same strategy for any other language behind API gateway too I think so too. By the way, Thank you for invitation for this Slack.

matt.fellows
2020-10-23 01:01
You?re most welcome!!

ashish_garg5
2020-10-23 05:44
Hi, Is there any examples for python AMQP ? If anyone can provide some reference. And i checked pact-python doesn't support AMQP and pactman doesn't support AMQP for version below 3.6. So is there any alternative ? Thanks.

bethskurrie
2020-10-23 06:01
Python doesn't support messages yet @ashish_garg5 but I believe the development is underway

ashish_garg5
2020-10-23 06:02
Is there any timeline ?

bethskurrie
2020-10-23 06:02
I'm not sure who is working on it, sorry.

ashish_garg5
2020-10-23 06:02
Ok np thanks :slightly_smiling_face:

bethskurrie
2020-10-23 06:02
I don't know much about the python impl.

bethskurrie
2020-10-23 06:03
Someone will probably reply over the next few days. @elliottmurray might be looking at it?

ashish_garg5
2020-10-23 06:06
ok sure :thumbsup:

ajayarooon
2020-10-23 07:06
Thanks @maciej.olko ... I'll try

elliottmurray
2020-10-23 09:52
Hey Ashish - unfortunately I haven?t been looking at messaging recently. I?ll try and carve some time out. It?s been on my radar but just hasn?t progressed yet.

seda.urguplu6
2020-10-23 11:28
Hi. Can you please check what is wrong with Eachlike here? Real response is like this: `{` `"count": 30,` `"results": [` `{"hotel_code": "111"},` `{"hotel_code": "222"},` `{"hotel_code": "333"}` `]` `}` `expected = {` `'count': 1,` `"results":` `EachLike({` `"hotel_code": "1"` `})` `}`

ercalbwar
2020-10-24 19:24
has joined #pact-python

andrewshtamburg
2020-10-25 13:04
has joined #pact-python

siad.ardroumli
2020-10-25 18:16
has joined #pact-python

srikanthpmailid
2020-10-26 01:02
has joined #pact-python

seda.urguplu6
2020-10-26 14:29
Can someone help me with this problem please? I'm getting AssertionError. Expected :{'count': 1, 'results': [{'hotel_code': '1'}]} Actual :{'count': 1, 'results': <pact.matchers.EachLike object at 0x103b38150>}

photesthesis_geospiza
2020-10-26 15:10
has joined #pact-python

sklein
2020-10-26 15:35
You're asserting on the EachLike object instead of asserting on an array of hotel_code object things. How i normally structure my assertions is something like this... ```expected = {"count": 1, "results":[{"hotel_code": "1"}]} ... .will_respond_with(body={"count":1, "results": EachLike(expected.get("results"))}) ... with pact: assert actual = expected ```

seda.urguplu6
2020-10-26 16:10
Thanks for your reply. I changed the code but now I'm getting this error. Expected :{'count': 1, 'results': [[{'hotel_code': '1'}]]} Actual :{'count': 1, 'results': [{'hotel_code': '1'}]}

matt.fellows
2020-10-26 21:33
Each like usually accepts an individual object which is used to match each item in the array. So you usually don't pass the array in to the matcher (hence the extra nested array)

ashish_garg5
2020-10-27 05:06
Sure @elliottmurray Thanks for the update.

seda.urguplu6
2020-10-27 08:45
This solved the problem ```body={"count":Like(1), "results": EachLike(expected["results"][0])}``` Thanks Sean and Matt :slightly_smiling_face:

matt.fellows
2020-10-27 09:02
Yep, that makes sense

jackbwheatley
2020-10-27 21:02
has joined #pact-python

carlosalmeida.xon
2020-10-27 22:06
has joined #pact-python

nasir.amin
2020-10-28 11:07
has joined #pact-python

jimish.shah.-nd
2020-10-28 11:26
has joined #pact-python

adam_figgins
2020-10-28 14:20
has joined #pact-python

aperdomobo
2020-10-28 15:42
has joined #pact-python

diazguerra2
2020-10-28 16:06
has joined #pact-python

xsamore
2020-10-28 19:52
has joined #pact-python

simon
2020-10-28 20:49
has joined #pact-python

ruben.cagnie
2020-10-29 01:24
has joined #pact-python

272939217
2020-10-29 05:33
has joined #pact-python

driloni92
2020-10-29 09:05
has joined #pact-python

pauloavra
2020-10-29 12:33
has joined #pact-python

cluu
2020-10-30 15:35
Hi, could someone please point me to an example of a file upload request? From what I?ve read so far, I have to place the content of the file in the body, which is not ideal. Any pointers will be greatly appreciated.

jikogay728
2020-10-30 17:20
has joined #pact-python

blmlcu
2020-10-31 14:51
has joined #pact-python

andrewshtamburg
2020-10-31 17:26
Hey! I?m trying to get started with pact. Tried to run tests from https://github.com/pact-foundation/pact-python/tree/master/examples/e2e and got this error. Anything obviously wrong I?m doing here? Python version: `3.8.2`

elliottmurray
2020-10-31 21:25
Are you on Windows? Flask has problems running in a back ground process on Windows. I do have an action to treat it out on fastapi. I don?t have Windows so it?s not trivial for me to test

andrewshtamburg
2020-11-01 08:21
Nope, I?m on mac OS Catalina. Version 10.15.3

elliottmurray
2020-11-01 10:56
Hmmm

elliottmurray
2020-11-01 10:57
Let me try updating python version

elliottmurray
2020-11-01 11:10
hmmm you?re right. I get the same issue on 3.8.3. Ok let me think about this. It?s something I need to have a better example of.

elliottmurray
2020-11-01 11:10
FYI it?s an issue with trying to run Flask as a subprocess

andrewshtamburg
2020-11-01 11:12
Ok, great, at least I didn?t waste your time on non issue. > FYI it?s an issue with trying to run Flask as a subprocess Actually, that is what I was about to ask. Is there a strong reason why you are running it as a subprocess in these examples?

elliottmurray
2020-11-01 11:45
Well to just use pytest as a testing framework so more a dev-ex thing


elliottmurray
2020-11-01 11:46
I have sh script that should be a good starting point

elliottmurray
2020-11-01 11:46
Let me know if that solves the immediate problem

elliottmurray
2020-11-01 11:47
I should do a FastApi example. That might work with pytest as is

andrewshtamburg
2020-11-01 12:12
The immediate issue seems to be resolved, thanks! Although, now I?m getting the same test failed. Seems like connection to broker refused? I have the broker running locally

andrewshtamburg
2020-11-01 12:24
Sorry, ignore all that. Wasn?t running provider service before executing tests All good

elliottmurray
2020-11-01 12:50
:+1:

272939217
2020-11-02 08:55
can anyone help me out? thanks a lot. i got an issue when to post a request

272939217
2020-11-02 08:56
the contract file is correct, like this.

272939217
2020-11-02 08:56
{ ?method?: ?post?, ?path?: ?/data?, ?body?: { ?username?: ?UserA? } }

272939217
2020-11-02 08:56
but when i try to verify the provider. the api said post.data is None (which is expect ?username: UserA?)

272939217
2020-11-02 08:57
File ?/Users/jfu/workspace/downstream/src/downstream.py?, line 32, in get_data name = data.get(?username?) AttributeError: ?NoneType? object has no attribute ?get?

matt.fellows
2020-11-02 09:18
Hmmm. Looks like the content-type header isnt set. Some API frameworks don't like this

272939217
2020-11-02 09:20
thanks, let me try with header

272939217
2020-11-02 09:37
?1 interaction, 0 failures? it works:)

matt.fellows
2020-11-02 09:41
Awesome. I think it's worth adding to the readme. I think I have it on both JS and Golang because it's common

272939217
2020-11-02 09:48
may i ask another generic question? our company?s microsystem is developed by JAVA mainly, our QA team are better in python. contract test is written by java version pact better, right? is it possible to write unit test by python on consumser side (which is by java)?

matt.fellows
2020-11-02 09:52
On the consumer side, it has to be Java. It?s a unit test, so there is really no other way

matt.fellows
2020-11-02 09:52
on the provider side, you could do it in Python, but it really is best done in Java also

272939217
2020-11-02 09:53
ok, got it

matt.fellows
2020-11-02 09:53
On the provider side, you could use the CLI verifier (https://docs.pact.io/implementation_guides/cli/#provider-verifier)

matt.fellows
2020-11-02 09:53
but provider states get hard, and almost certainly at some point you?ll need to change Java. So it?s just easier that way

272939217
2020-11-02 09:55
thanks, it seems our QA need to look into java version of pact now.


matt.fellows
2020-11-02 09:56
It?s not the most eloquently written, but it probably helps

272939217
2020-11-02 09:57
yes

jamescourtoy
2020-11-02 21:04
has joined #pact-python

telmo.ferreira.costa
2020-11-03 11:32
has joined #pact-python

sergii.kopovskyi
2020-11-03 12:35
has joined #pact-python

silverton.gimenes
2020-11-03 17:58
has joined #pact-python

colber16
2020-11-03 18:34
has joined #pact-python

cvoong
2020-11-03 18:55
has joined #pact-python

joel.whalen
2020-11-06 19:42
Hello, is there an easy way to configure multiple log files to be written across different pact tests? We currently have 4 pact files being written, but all the log outputs are going to the same file. This makes it confusing when working on individual tests.

elliottmurray
2020-11-06 20:17
A lot of the python impl uses a ruby subprocess. I?m guessing you?re giving them the same file handle and it?s overwriting rather than appending? You?d probably have to give me a bit more info about what you?re trying to do. Like is it a Consumer testing 4 Providers? Or vice versa? Different CI?s etc.

elliottmurray
2020-11-06 20:17
Cool profile pic btw

cluu
2020-11-06 20:19
Correct me if I?m wrong, the log file name is hard-coded to be `pact.log` for Provider test. You can change the `log_dir` value for each of your pact test though.

elliottmurray
2020-11-06 20:22
I think for Provider you are correct

elliottmurray
2020-11-06 20:22
```def call_verify( self, *pacts, provider_base_url, provider, enable_pending=False, include_wip_pacts_since=None, **kwargs ): """Call verify method.""" verbose = kwargs.get('verbose', False) self._validate_input(pacts, **kwargs) provider_app_version = kwargs.get('provider_app_version') options = { '--provider-base-url': provider_base_url, '--provider': provider, '--broker-username': kwargs.get('broker_username', None), '--broker-password': kwargs.get('broker_password', None), '--pact-broker-base-url': kwargs.get('broker_url', None), '--provider-states-setup-url': kwargs.get('provider_states_setup_url'), '--log-dir': kwargs.get('log_dir'), '--log-level': kwargs.get('log_level') }```

cluu
2020-11-06 20:35
Hi, I?m stuck on `EachLike` and hoping someone can provide a pointer. ``` expected = { "data": [ { "dataType": "numeric", "name": "code" }, { "dataType": "string", "name": "description" }], "results": [ [ { "name": "code", "value": 1233 }, { "name": "description", "value": "desc1" } ], [ { "name": "code", "value": 1234 }, { "name": "description", "value": "desc2" } ] ] }```

cluu
2020-11-06 20:35
```.will_respond_with(200, body={"data": Like(expected["data"]), "results": EachLike(Like(expected.get("results")[0]))}))```

cluu
2020-11-06 20:36
but it?s not working as expected.

cluu
2020-11-06 20:36
I?m getting assertion error ``````

elliottmurray
2020-11-06 20:39
I?m not totally sure but result has arrays in an array. So maybe EachLike(Like(expected.get(?results?)[0][0]

elliottmurray
2020-11-06 20:39
???

elliottmurray
2020-11-06 20:40
I?m not sure what you?re response is doing though?

cluu
2020-11-06 20:47
Each result is an object or a record. Below is a result. The results is an array of records ```[ { "name": "code", "value": 1233 }, { "name": "description", "value": "desc1" } ]```

cluu
2020-11-06 20:47
I hope that makes sense

elliottmurray
2020-11-06 21:09
So I think the extra [0] I put in is what you need?

cluu
2020-11-06 21:13
I tried that and it will not work since it only matches the first part of the record.

cluu
2020-11-06 21:14
I wanted to match an array containing like records

bethskurrie
2020-11-06 21:14
Each like doesn't need a like inside it.

bethskurrie
2020-11-06 21:15
it needs a single item. it looks like it was given an array.

cluu
2020-11-06 21:26
hmm?.I changed it to below and still does not work. My thought is that I want to match each record to be like `expected.get("results")[0]` ```.will_respond_with(200, body={"data": Like(expected["data"]), "results": EachLike((expected.get("results")[0])```

bethskurrie
2020-11-06 21:37
So, "data" is a hash with a name and value, and results is an array where each item has a name and value?

bethskurrie
2020-11-06 21:37
Oh, no, they're both arrays

bethskurrie
2020-11-06 21:38
```.will_respond_with(200, body={"data": EachLike({ "name": "", value: ""}), "results": EachLike({ "name": "", value: ""})```

bethskurrie
2020-11-06 21:38
Just try with the hardcoded stuff for now.

bethskurrie
2020-11-06 21:39
the looking up the data is confusing me :laughing:

cluu
2020-11-06 21:39
Thanks. I?ll give it a go. It can be. The reuse of name/value can be confusing, but it makes sense in a way :slightly_smiling_face:

cluu
2020-11-06 21:46
Still does not work. Looks like I?ll have to match exact value route.

cluu
2020-11-06 21:47
Thanks for your help though

joel.whalen
2020-11-09 18:43
It?s a consumer writing pact files for 4 different providers, yes. And that?s the thing, I?m not supplying the file name, just the directory. I think pact is defaulting to `pact-mock-service.log` as the file name

joel.whalen
2020-11-09 18:44
Yes, this is true. The issue is all 4 are writing to the same `pact-mock-service.log` file

cluu
2020-11-09 19:44
Does anyone know if there?s a way to pass parameters (or will it be implemented in the future) to call back functions for provider states?

elliottmurray
2020-11-09 20:25
Sorry I don?t understand

pbobba
2020-11-09 23:03
has joined #pact-python

jun.li
2020-11-09 23:05
has joined #pact-python

douweicai
2020-11-10 04:11
has joined #pact-python

christian.huber
2020-11-10 09:20
has joined #pact-python

vuttithatkrongyot
2020-11-10 10:57
has joined #pact-python

dan.iosif
2020-11-10 17:06
has joined #pact-python

rodrigo.costa20
2020-11-12 00:59
has joined #pact-python

yong.gong188
2020-11-12 09:13
has joined #pact-python

anandhadeepak
2020-11-12 13:03
has joined #pact-python

david.dias
2020-11-12 20:04
has joined #pact-python

billal.patel
2020-11-13 10:31
has joined #pact-python

billal.patel
2020-11-13 10:42
@billal.patel has left the channel

louis.oliver
2020-11-16 10:33
has joined #pact-python

ashishkujoy
2020-11-16 15:08
has joined #pact-python

pradeepchoube
2020-11-17 03:49
has joined #pact-python

meng-lingtao
2020-11-17 14:39
has joined #pact-python

pabvidcal
2020-11-17 15:30
has joined #pact-python

magesh.nagamani
2020-11-18 05:15
has joined #pact-python

jstoebel
2020-11-18 13:53
has joined #pact-python

daniel.sayer89
2020-11-19 10:33
has joined #pact-python

art.ptushkin
2020-11-19 10:34
has joined #pact-python

pact457
2020-11-19 10:36
has joined #pact-python

ajerthan.sivayoganath
2020-11-19 10:38
has joined #pact-python

philipchardwick
2020-11-19 11:05
has joined #pact-python

tanzmann
2020-11-19 11:09
has joined #pact-python

olivier.quere
2020-11-19 12:10
has joined #pact-python

wilfried.vandenberghe
2020-11-19 12:19
has joined #pact-python

alan.hanafy
2020-11-19 19:28
has joined #pact-python

michael.deutscher
2020-11-19 21:39
has joined #pact-python

gerry.power
2020-11-20 03:31
has joined #pact-python

alex900
2020-11-20 05:08
has joined #pact-python

tomas.panik
2020-11-20 08:28
has joined #pact-python

marc.ferland
2020-11-20 14:43
has joined #pact-python

sebastien.crapoulet
2020-11-20 15:24
has joined #pact-python

adutrillaux
2020-11-20 15:28
has joined #pact-python

he
2020-11-20 15:59
has joined #pact-python

ivgeni.slabkovski
2020-11-20 21:52
has joined #pact-python

serhatburakyildirim
2020-11-21 21:57
has joined #pact-python

alnasl
2020-11-22 18:46
has joined #pact-python

ashutosh23802
2020-11-23 06:20
has joined #pact-python

leonty
2020-11-23 10:33
has joined #pact-python

dariusz.piwko
2020-11-23 11:34
has joined #pact-python

praneeth.kumar
2020-11-23 16:18
has joined #pact-python

mark.white
2020-11-24 09:03
has joined #pact-python

ufuk.ozcelik
2020-11-24 14:58
has joined #pact-python

stefanos.varsanis
2020-11-24 16:48
has joined #pact-python

lalexander2810
2020-11-24 16:53
has joined #pact-python

sivaprasad9
2020-11-24 20:46
has joined #pact-python

scyr
2020-11-25 14:56
has joined #pact-python

timotheus.ruprecht
2020-11-25 22:12
has joined #pact-python

manali.mogre
2020-11-26 11:44
has joined #pact-python

erik.terpstra
2020-11-26 12:08
has joined #pact-python

kjayachandra2000
2020-11-26 20:40
has joined #pact-python

kjayachandra2000
2020-11-26 22:00
@kjayachandra2000 has left the channel

sushil.kumar
2020-11-27 01:45
has joined #pact-python

zhujian
2020-11-27 07:54
has joined #pact-python

h.octavian
2020-11-27 14:08
has joined #pact-python

noel
2020-11-28 23:12
has joined #pact-python

muraalee
2020-11-30 01:56
has joined #pact-python

pooja.sharma
2020-11-30 08:52
has joined #pact-python

mo
2020-11-30 09:24
has joined #pact-python

jstoebel
2020-11-30 14:29
Hello! I am new to the pact eco-system so feel free to route my question somewhere else if this is the wrong place to ask: I'm curious if there is a mechnisim to enforce uniformity in how services are referenced in pacts. For example let's say one consumer has this: ```Consumer('consumer-1').has_pact_with(Provider('users'))``` What's to stop another service from referring to the same users service by a different name? ```Consumer('consumer-service-2').has_pact_with(Provider('users-service'))```

maciej.olko
2020-11-30 14:37
Pact Broker has such a feature, it recognises similar names and suggests using same name for too similar but not equal name

david.greene
2020-11-30 21:47
has joined #pact-python

matt.fellows
2020-11-30 23:12
So there are a few options. There are no automatic standards at this moment in time (but you?re not the first, not just for naming things but also for APIs themselves): 1. In Pactflow, you can restrict creating of new contracts by using roles and permissions 2. Some customers/users have ?admins? who look after the broker and curate it regularly 3. One option would be to create a webhook that fires for new contracts, the target (e.g. a lambda) reads the contract and sends a notification to an admin if it?s not using a consistent style

matt.fellows
2020-11-30 23:12
just some thoughts on the top of my head!

jstoebel
2020-11-30 23:39
good ideas, thanks!

matt.fellows
2020-11-30 23:43
oh, you could also (probably) extend/modify the broker validation logic to ensure it matches your needs. I?m sure you could find a way to customise that without breaking upgrades etc.

jstoebel
2020-12-01 00:01
I bet I could. Because Ruby :slightly_smiling_face:

bas
2020-12-01 09:00
has joined #pact-python

wainstead
2020-12-01 14:57
has joined #pact-python

jerobinson
2020-12-01 20:32
has joined #pact-python

sumedhagamage
2020-12-02 03:33
has joined #pact-python

fealaer
2020-12-02 11:40
has joined #pact-python

fealaer
2020-12-02 11:58
@fealaer has left the channel

patrick.hendron
2020-12-02 14:44
has joined #pact-python

lpratt
2020-12-02 18:19
has joined #pact-python

sandragnzalez
2020-12-03 11:04
has joined #pact-python

kristian
2020-12-03 14:34
has joined #pact-python

me1466
2020-12-03 23:42
has joined #pact-python

wenfeng.li
2020-12-04 11:42
has joined #pact-python

cdambo
2020-12-05 11:59
has joined #pact-python

gayatree.eee
2020-12-08 04:50
has joined #pact-python

c.pavan1986
2020-12-09 04:18
has joined #pact-python

william.pritchard
2020-12-09 15:28
has joined #pact-python

parveshchaudhary111
2020-12-09 17:54
has joined #pact-python

w.sobasik
2020-12-10 10:39
has joined #pact-python

thanuxxxx
2020-12-12 22:41
has joined #pact-python

ian.hamilton
2020-12-13 06:53
has joined #pact-python

colm.j.murphy91
2020-12-13 07:02
has joined #pact-python

danhitchcock
2020-12-13 11:55
@danhitchcock has left the channel

victoria.kruczek
2020-12-13 14:13
has joined #pact-python

wuddarwin
2020-12-14 05:23
has joined #pact-python

connor.aird
2020-12-14 15:52
has joined #pact-python

arman.najafian
2020-12-14 15:52
has joined #pact-python

praveen.lakkaraju
2020-12-14 16:12
has joined #pact-python

alejandro.germain
2020-12-14 16:26
has joined #pact-python

josh.ellinger
2020-12-15 01:22
has joined #pact-python

nikitsenka
2020-12-15 09:35
has joined #pact-python

hibahawes
2020-12-15 09:53
has joined #pact-python

ashish_garg5
2020-12-15 10:00
Hi All, I am using consumer_tags in my provider Verifier.verify_with_broker(consumer_tags={"latest", "dev"}) I want to run my provider against latest dev tag of consumer and latest tag of consumer whatever is the latest tag present, but by writing this above line it is running against the latest dev tag but not running against the latest tag present in the broker. I think it is looking for latest latest tag in this case. Please let me know how i can fetch latest tag also from the broker with this. Thanks.

sarvar
2020-12-15 14:24
has joined #pact-python

suruchipatidar14
2020-12-16 05:35
has joined #pact-python

smatheson
2020-12-16 06:33
has joined #pact-python

elliottmurray
2020-12-16 15:05
I am actually not sure on this - have you tried #pact-broker as that may be a better answer for this. Python sdk just proxies calls in most cases.

olayemifolakemi
2020-12-16 15:23
has joined #pact-python

ania.kovalchuk
2020-12-17 00:09
has joined #pact-python

writetojoshma
2020-12-17 05:52
has joined #pact-python

rejeesh.g
2020-12-17 11:07
has joined #pact-python

lukas.kempec
2020-12-17 12:45
has joined #pact-python

vikas543
2020-12-17 16:28
has joined #pact-python

bpugh
2020-12-17 17:05
has joined #pact-python

elliottmurray
2020-12-19 12:45
Well that was unnecessarily painful (a bit of self harm I fear!) but pact-python now published via Github Actions. Thanks to @matthew.balvanz

jeff.burmood
2020-12-19 17:45
has joined #pact-python

kyle.florence
2020-12-19 19:21
has joined #pact-python

ankurmalik22
2020-12-19 21:14
has joined #pact-python

vsukumaran
2020-12-20 01:56
has joined #pact-python

omer.morad
2020-12-20 08:10
has joined #pact-python

ringo
2020-12-20 10:51
has joined #pact-python

omer.moradd
2020-12-20 18:01
has joined #pact-python

jeff.burmood
2020-12-20 18:07
Howdy, I'm relatively new to Pact and have, what might be, a rookie question. I'm trying to set up pacts for some PUT and POST endpoints where the request body is several hundred lines in a JSON file. There are updated_at timestamp fields in the response body so unless I use a Matcher on these timestamp fields, the pact verification always fails against the provider due to the timestamp in the actual response being different than the value in the associated pact. I'm trying to use a basic Term() call or a Like() call with these fields. Here's the issue, I store these huge response bodies in a file and read them into the test case when running the test. Since there is a Term() or Like() call for some fields, I can't treat these files as JSON since json.load can't parse the lines with Matcher function calls. Consequently the whole expected response body gets read in as a string (file.read().text). And I'm having a hard time figuring out how to then work with the body with embedded Matcher function calls. The method get_generated_values() won't work on these string objects that essentially contain the dict defining the response body, it just returns any string it encounters (rightly so I guess). Sorry for the long explanation, my question boils down to how to handle creating and using pacts created with Matcher functions on some fields in a request/response schema I read in from a file? Thanks for any thoughts!

elliottmurray
2020-12-20 18:30
Hey Jeff and welcome! I?m not sure I fully understand. Is this for a consumer test? If so I feel there?s a core misunderstanding. Define in the dsl the response you need to test and then pact will play that back for you when you call the relevant http end point. I?m not clear how the static json comes into play?

souravsen1
2020-12-21 11:28
has joined #pact-python

jeff.burmood
2020-12-21 14:10
Hi @elliottmurray thanks for jumping in, I appreciate it. OK, I'll try and provide a better explanation. I'm probably making this tougher than it is. I have test for a GET endpoint that will always return the same json formatted response body given the same request parameters so I can easily generate a pact that successfully verifies for the consumer and the provider. However, when I make a call to a particular PUT endpoint, the response body includes a new date-time stamp in a field called "updated-at". This is all perfectly normal behavior and, I assume, one of the reasons that Matchers exist. So, I use a Term() or Like() matcher to match the format of the updated-at field, but ignore the value. Here's an example and this is all working fine for this small example of an endpoint response (json) body: expected = { 'id': 1, 'name': 'Leanne Graham', 'username': 'Bret', 'email': ', 'address': {'street': 'Kulas Light', 'suite': 'Apt. 556', 'city': 'Gwenborough', 'zipcode': '92998-3874', 'geo': {'lat': '-37.3159', 'lng': '81.1496'}}, 'phone': Term(_r_'\d+-\d+-\d+-\d+(\s\w\d+)*',''), 'website': 'http://hildegard.org', 'company': {'name': 'Romaguera-Crona', 'catchPhrase': 'Multi-layered client-server neural-net', 'bs': 'harness real-time e-markets'} }

jeff.burmood
2020-12-21 14:12
OK, hopefully that help set the stage, here's where I'm stuck. The Matcher processing works fine because I can do this and the Matcher code generates the values I need for the assertion: _with_ pact: result = get_one_user(1) _assert_(result == get_generated_values(expected))

elliottmurray
2020-12-21 14:16
get_one_user is returning json itself?

jeff.burmood
2020-12-21 14:18
This works because the "expected" object in tis example is a python dict object so it gets processed properly by the get_generated_values() call. But, I have a scenario where the PUT endpoint returns a huge json response - hundreds of lines. I do not want to hard code this response body in the test code for the consumer and provider tests, I want to read it from a file, and then process it just like the example above. However, I cannot read in the response file as json because the Term() call cannot be json parsed: 'phone': Term(_r_'\d+-\d+-\d+-\d+(\s\w\d+)*',''), So I have to read it in as text (string). So now I have a response body with embedded Matcher code that is a string, not a dict and the get_generated_values() ignores the string when parsing, and I don;t have a clean way to convert the whole thing to dict. Soooo, I think I'm missing something because this has to be a common scenario.

jeff.burmood
2020-12-21 14:19
yes, get_one_user() is returning a json object


elliottmurray
2020-12-21 17:48
So do you need to test every value in that GET response or just a few? The point of CDC is that you test first so have only the things you need. Do you need all of those fields tested in this consumer that you had in the put? If you really do I'd take a one time task to create your dict with your matchers (might be a bit of copy and paste) and or have some smart json builder or template to help you out. It is white box testing remember so test the part of the contract you know you need to test. I know it's tempting to re-use the PUT response but I think the cyclical nature of that is setting yourself up for more problems later on.

andoni.arroyo
2020-12-21 17:51
has joined #pact-python

jeff.burmood
2020-12-21 18:06
Hi Elliot, so this is only a problem for the PUT, namely, when I'm updating an existing object and I'm comparing the expected response from the PUT with the actual response (and I do need to check all of the fields). The expected response I have stored in a file and used to create the pact during consumer-side testing, will not match the actual response from the endpoint because the "updated_at" field will have a different (newer) date-time stamp in the actual API response during the provider test. That's why I'm using Matchers, because they address this very scenario (which I know that you know better then I do, just want you to know that I think I understand how to use them). So I think my only course of action is to parse the huge json-like object (that I have to read in from the file as a string because of the embedded Matcher calls) into a Python dict() object and then everything should work fine. Someone has probably run into this scenario before because I'm not doing anything bizarre here, I just can't find a Google or Stackoverflow example for a solution on building a pact from an object read from a file that has Term() and Like() calls as some of the dictionary values. (again, it's because of these embedded Matcher function calls that the file won't load/parse into a python dict object using json.load(). So I'm probably not providing any real clarification here but I appreciate your efforts to help all the same.

elliottmurray
2020-12-21 20:37
Hey Jeff, thanks for clarifying the PUT bit and I understand a bit better but I think you're still missing the sweet spot for Pact a little. How I would go about testing your scenario. Firstly on the Provider have a test (can be unit or whatever type of test) that proves that if you give the endpoint a request a response is returned. There are plenty of unit testing tooling to allow you to match a map/dict for only certain key elements so ignore the date ones. Then on the consumer test the interaction happened as expected. Do you need values back from the PUT in your Consumer? Only test the ones your Consumer has a hard dependency on because that is your contract. Do not test for basic correctness of your Provider in your Consumer is the salient point I'm trying to make. It's subtle but Pact is to test contracts not behaviour.

elliottmurray
2020-12-21 20:39
This means your contract test should pass in a body on the 'REQUEST' but that will not need dates checking.

elliottmurray
2020-12-21 20:40
Oh and the Provider test in this scenario should again test that for the Consumer Contract Test you save or do whatever it is you need to do test Provider side.

elliottmurray
2020-12-21 20:41
That is obviously the whole point! Might seem you have an overlapping test on the Provider but they are for different things.

jeff.burmood
2020-12-21 21:15
OK, thanks @elliottmurray I think I'm following that, I'll do some experiments along the approach you've outlined. Again, I appreciate your time and help!

armorsmith42
2020-12-22 05:07
has joined #pact-python

theovanessen
2020-12-22 10:47
has joined #pact-python

stuart3166
2020-12-22 12:35
has joined #pact-python

winfante
2020-12-22 22:51
has joined #pact-python

lars.bonnes
2020-12-23 13:05
has joined #pact-python

eungjun.yi
2020-12-25 14:25
has joined #pact-python

ebanster
2020-12-27 13:18
has joined #pact-python

onur.baskirt
2020-12-28 10:48
has joined #pact-python

cdambo
2020-12-28 12:43
Hi I?ve installed pact-python 1.2.10 on my Mac, and I get the Linux ruby binary. On 1.2.9, I get the OSX binary.

elliottmurray
2020-12-28 20:58
What does the uname command return?

elliottmurray
2020-12-28 21:37
Or even better from the repl

elliottmurray
2020-12-28 21:37
import platform

elliottmurray
2020-12-28 21:37
platform.platform().lower()

cdambo
2020-12-28 22:46
On my machine? `macos-10.16-x86_64-i386-64bit`

elliottmurray
2020-12-29 09:09
So we?re expecting

elliottmurray
2020-12-29 09:09
`Darwin-19.6.0-x86_64-i386-64bit`

elliottmurray
2020-12-29 09:09
I?m on Catalina 10.15.7 and haven?t updated for a while. What are you on?

massimo.daros
2020-12-29 13:18
has joined #pact-python

cdambo
2020-12-29 14:08
Big Sur. Is it possible the 1.2.10 wheel points macOS installations to Linux ruby binary?

elliottmurray
2020-12-29 14:10
Let me update my mac now. I'm not sure but we haven't really changed that code as far as I can tell. You can see in setup.py what it is doing

elliottmurray
2020-12-29 14:10
We did change the CI actually - to github. Hmmmm

elliottmurray
2020-12-29 14:11
Still doesn't explain why you get a difference on the repl to me. That has nothing to do with Pact

elliottmurray
2020-12-29 14:15
tbh you should have got an error with that

elliottmurray
2020-12-29 14:23
hmm I think you might be on to something. I'll have a look this evening. Maybe just fix to 1.2.09 until then?

elliottmurray
2020-12-29 14:24
There is now a wheel where before there wasnt so I think a change in how we package

cdambo
2020-12-29 14:26
Thanks! :)

chris.fullinwider
2020-12-29 18:15
has joined #pact-python

elliottmurray
2020-12-29 20:14
Let me know if 1.2.11 works for you

cdambo
2020-12-30 16:42
Works! Thanks @elliottmurray :smile:

piotr.soltysiak
2020-12-30 16:55
has joined #pact-python

adrian.przybyla
2021-01-04 13:41
has joined #pact-python

dcorrales
2021-01-04 22:06
has joined #pact-python

jokubas.lekevicius
2021-01-04 22:10
has joined #pact-python

matt195
2021-01-05 16:35
has joined #pact-python

rafael.manzoni
2021-01-05 17:56
has joined #pact-python

animesh2712
2021-01-05 19:29
has joined #pact-python

info
2021-01-06 01:55
has joined #pact-python

pascal.libenzi
2021-01-06 10:57
has joined #pact-python

brett
2021-01-06 18:55
has joined #pact-python

josh.rosenfeld
2021-01-06 19:39
has joined #pact-python

carlo
2021-01-07 13:24
has joined #pact-python

danny.porrello
2021-01-07 16:48
has joined #pact-python

dawood.abbas
2021-01-08 07:00
has joined #pact-python

victoria.kruczek
2021-01-10 16:37
@victoria.kruczek has left the channel

cksharma122
2021-01-10 17:19
has joined #pact-python

caiquedpfc
2021-01-11 04:05
has joined #pact-python

henrik.rudstrom
2021-01-11 18:30
has joined #pact-python

eric
2021-01-12 10:23
has joined #pact-python

fnguyen
2021-01-13 00:39
has joined #pact-python

pollet_22
2021-01-13 16:04
has joined #pact-python

dshattuck
2021-01-13 20:49
has joined #pact-python

thomas.rosati
2021-01-13 21:58
has joined #pact-python

rahulsmalpani
2021-01-14 07:56
has joined #pact-python

sacha.camfferman768
2021-01-14 09:42
has joined #pact-python

brandonbeard86
2021-01-14 22:10
has joined #pact-python

geetishnayak
2021-01-15 01:02
has joined #pact-python

shettyg
2021-01-15 14:18
has joined #pact-python

natarajang1
2021-01-15 15:29
has joined #pact-python

elliottmurray
2021-01-15 22:11
closed?

winfante
2021-01-18 00:56
We will have another PR very soon. We?re just adding a message handler and possibly a publish to broker implementation

winfante
2021-01-18 04:25
we?ve created a PR now that should be ready for review https://github.com/pact-foundation/pact-python/pull/194

elliottmurray
2021-01-18 08:54
This looks great William but it's going to take me a few days to process

michel.neufeglise
2021-01-18 08:55
has joined #pact-python

bart.boersma
2021-01-18 10:48
has joined #pact-python

winfante
2021-01-18 21:44
no worries

monica.wu
2021-01-19 06:25
has joined #pact-python

makobernal
2021-01-19 08:23
has joined #pact-python

jibrail.idris
2021-01-19 10:11
has joined #pact-python

jmvb.registros
2021-01-19 11:01
has joined #pact-python

tpham
2021-01-19 22:36
has joined #pact-python

vishal.grover
2021-01-20 03:12
has joined #pact-python

priya.saraf
2021-01-20 08:43
has joined #pact-python

fahad.aj.khan
2021-01-20 08:58
has joined #pact-python

nicole.jaenchen
2021-01-20 09:38
has joined #pact-python

dinakaran.ulaganathan
2021-01-20 13:59
has joined #pact-python

ptsiakos77
2021-01-20 21:55
has joined #pact-python

lbraymusso
2021-01-20 23:57
:clap: So glad to see this! My company has been eager to leverage Message Pact support for their growing library of Python services that use Kafka. @winfante thanks to you and your colleague for the efforts here, very keen to try it out once it's gone under review!

mhdtouban
2021-01-21 01:58
has joined #pact-python

veeraprathap.n
2021-01-21 04:10
has joined #pact-python

tsiakos
2021-01-21 09:24
has joined #pact-python

oleg
2021-01-21 13:05
has joined #pact-python

thomas.powell
2021-01-22 10:18
has joined #pact-python

stefan.selent
2021-01-23 01:54
has joined #pact-python

paulo
2021-01-25 11:37
has joined #pact-python

kmckeever
2021-01-25 14:38
has joined #pact-python

robert.land
2021-01-25 19:25
has joined #pact-python

aparnachaudhari
2021-01-25 21:34
has joined #pact-python

gwhill7
2021-01-25 23:23
has joined #pact-python


bibinc99
2021-01-26 14:37
has joined #pact-python

tsiakos
2021-01-26 14:56
@elliottmurray I verified the proposed change it works file - here is the json produced ```{ "consumer": { "name": "TestConsumer_message" }, "provider": { "name": "TestProvider_message" }, "messages": [ { "description": "an account mesage", "providerStates": [ { "name": "Provider state", "params": null } ], "contents": { "id": 1, "uid": "fc763eba-0905-41c5-a27f-3934ab26786c", "name": "Winterfell", "website_url": "http://winterfell.com", "subdomain": "winterfell", "domain": "http://winterfell.com", "description": "Lorem ipsum dolor sit amet.", "style": "minimal", "translations": { "en": { "description": "Lorem ipsum dolor sit amet" } } }, "matchingRules": { "body": { "$.id": { "matchers": [ { "match": "type" } ] }, "$.uid": { "matchers": [ { "match": "regex", "regex": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" } ] }, "$.name": { "matchers": [ { "match": "type" } ] }, "$.website_url": { "matchers": [ { "match": "regex", "regex": "^(http|https):\\/\\/[a-z0-9]+(-[a-z0-9]+)*\\.+[a-z]{2,}$" } ] }, "$.subdomain": { "matchers": [ { "match": "type" } ] }, "$.domain": { "matchers": [ { "match": "regex", "regex": "^([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}$" } ] }, "$.description": { "matchers": [ { "match": "type" } ] }, "$.style": { "matchers": [ { "match": "type" } ] }, "$.translations.en.description": { "matchers": [ { "match": "type" } ] } } }, "metaData": { "contentType": "application/json", "source": "legacy_api" } } ], "metadata": { "pactSpecification": { "version": "3.0.0" } } }```

elliottmurray
2021-01-26 15:52
@tsiakos I think they are working on this still. I can't take credit for this one! I am expecting a follow up PR soon

tsiakos
2021-01-26 15:54
ok thanks a lot!! maybe i will ping @winfante

winfante
2021-01-26 21:31
Thanks @tsiakos for raising this. I can verify in my local that your `from_term` suggestion is working :slightly_smiling_face: @tpham and I are still working on putting up a message provider PR soon. Whichever you prefer, you may file this as a separate PR or we can include it as part of our message provider pr. Thanks!

luisc.barretog
2021-01-27 00:42
has joined #pact-python

tsiakos
2021-01-27 06:33
@winfante †Thank you for your response! I am fine by including this as part of your message provider PR. Creat job once again!

laxmi.somni508
2021-01-27 10:27
has joined #pact-python

ryanding16
2021-01-27 20:25
has joined #pact-python

athurner
2021-01-28 13:55
has joined #pact-python

alex.mcnair
2021-01-28 18:35
has joined #pact-python

mailinglistsspammedme
2021-01-28 23:30
has joined #pact-python

steven.beaver.retail
2021-01-29 15:34
has joined #pact-python

ekberli.elbrus
2021-01-30 16:33
has joined #pact-python

george.south
2021-02-01 21:12
has joined #pact-python

twierzchowski
2021-02-03 07:05
has joined #pact-python

yassin.hajaj
2021-02-03 10:35
has joined #pact-python