Pact verifier is throwing Error (Failure/Error: expect(response_body).to match_term expected_response_body, diff_options Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8)
See original GitHub issueHi, can you please help me on below scenario ?
-
i am able to create Jason mock properly but at the time json file generation below error is coming but Json file is created successfully
Error: "AssertionError: [{'class': ['HealthCheck'], 'properties':[863 chars]'}]}] != <pact.matchers.EachLike object at 0x06C66AD0>"
-
using pact verifier to verify the json file but getting below error .
Failure/Error: expect(response_status).to eql expected_response_status expected: 200 got: 403 (compared using eql?) Failure/Error: expect(response_body).to match_term expected_response_body, diff_options Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8
i am doing poc and just want to mock only some part of the response to pass the test case. can you please help me what i am doing wrong ?
Consumer.py:
import requests
def callAPI (url):
return requests.get ( url ).json()
Test_consumer.py :
import atexit
import unittest
from consumer import callAPI
from pact import Consumer, Provider
from pact import EachLike, SomethingLike, Term, Like
pact = Consumer ( 'consumer' ).has_pact_with ( Provider ( 'provider' ) )
pact.start_service ()
atexit.register ( pact.stop_service )
class MakeItContractTestingWork ( unittest.TestCase ):
# maxDiff = None
def test_callAPI_HealthCheck (self):
url = 'http://localhost:1234'
expected =EachLike({'class': Like(['HealthCheck']),
'properties': {
'timestamp': Term('\d+-\d+-\d+T\d+:\d+:\d+', '2018-07-31T01:38:08+0000'),
'systemName': Like("minimal-rx"),
"buildInfo": {
"buildDate": Term('\d+-\d+-\d+T\d+:\d+:\d+', '2018-07-31T01:38:08+0000'),
"appVersion": Like("CS-MRA_develop.25"),
"revision": Like("291a6553f509edc68074d31cd7d5a077a98c5add"),
"branch": Like("develop")
},
"health": Like("OK"),
"checks": [
{"check": Like("DB connection via Instance of class com.zaxxer.hikari.HikariDataSource"),
"status": Like("OK"),
"assertion": Like("available"),
"target": Like("Instance of class com.zaxxer.hikari.HikariDataSource")
},
{
"check": Like("Connection to https://alignapi.alta-sqa1.aligntech.com/protocol/v1/userinfo"),
"status": Like("OK"),
"config_id": Like("alignapi\\.alta-sqa1\\.aligntech\\.com"),
"secure_key": Like("alignapi.alta-sqa1.aligntech.com"),
"assertion": Like("access"),
"config_type": Like("OAUTH"),
"target": Like("https://alignapi.alta-sqa1.aligntech.com/protocol/v1/userinfo")
}
]
},
"links": [
{
"rel": Like(["self"]), "href": Like("/minimal-rx/v1/admin/healthcheck")
}
]
}, minimum=1
)
pact.given (
'the health of the system is OK'
).upon_receiving (
'a request for the health check'
).with_request (
'get',
'/'
).will_respond_with ( 200, headers={'Content-Type': 'application/json;charset=utf-8'}, body= expected)
with pact:
result = callAPI ( url )
self.assertEqual ( result, expected )
mockobject = MakeItContractTestingWork ( 'test_callAPI_HealthCheck' )
mockobject.test_callAPI_HealthCheck ()
# Pact verfier syntax : i am running below command from terminal and getting error
# pact-verifier --provider-base-url=https://alignapi.alta-sqa1.aligntech.com/minimal-rx/v1/admin/healthcheck .\consumer-provider.json
can you please help me what i am doing wrong ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
pact verifier is failing with Encoding::UndefinedConversionError
Error when i running against real provider : 1) Verifying a pact between consumer and provider Given the ... "\xE2" from ASCII-8BIT to...
Read more >UndefinedConversionError: "\xEF" from ASCII-8BIT to UTF-8 ...
I am having the above error when trying to save as new PDF file (read from another file) using Pathname object (in Rails)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi Matt, issue is resolved . in pact verifier, i am giving url like below which is causing the issue https://alignapi.alta-sqa1.aligntech.com/minimal-rx/v1/rx-forms/3964d0f1-52cd-476e-90f2-07b60888747e
instead if i give like below it is working
https://alignapi.alta-sqa1.aligntech.com
Thank you for your time
Sorry for my delay I’ve been on leave for a few days. Glad to hear it’s all working! 👍