Yumi
04/01/2022, 8:21 AMdef test_get_metadata(self):
expected = {
"body": [
{
"name": "可用区1",
"status": "ONLINE",
"visible": True
}
],
"requestId": Like("abc"),
"state": "OK"
}
# 定义响应头
headers = {
"Content-Type": "application/json"
}
query = {"name":"可用区1","signature":"asdf"}
(self.pact
.upon_receiving('查询有效可用区信息')
.with_request(
method='GET',
path=self.PATH,
query=query,
headers=headers
).will_respond_with(200, headers, expected))
with self.pact:
resp = requests.get("<http://localhost>:{}{}".format(MOCK_SERVER_PORT,self.PATH),
params=query,headers = headers)
print('*******************************')
print(resp.json())
self.assertEqual(resp.json(), get_generated_values(expected))
when using pact-verifier command to verify the json file. It shows that the value of "name" in query parameters is urlencoded as "%E5%8F%AF%E7%94%A8%E5%8C%BA1". however when I change the query from list to string like this :
query = "name=可用区1&signature=asdf"
when using pact-varifier command,it shows:
URI::InvalidURIError:
URI must be ascii only "/api/change?name=\u{53ef}\u{7528}\u{533a}1&signature=asdf"
# D:/python/Lib/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/uri/rfc3986_parser.rb:20:in `split'
# D:/python/Lib/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/uri/rfc3986_parser.rb:72:in `parse'
# D:/python/Lib/site-packages/pact/bin/pact/lib/ruby/lib/ruby/2.2.0/uri/common.rb:226:in `parse'
Is there a way to deal with this kind of situation?I've found a issue https://github.com/pact-foundation/pact-provider-proxy/issues/6 but it seems different from @Beth (pactflow.io/Pact Broker/pact-ruby) said.I thought hash form will not be encoded🥲Beth (pactflow.io/Pact Broker/pact-ruby)
Beth (pactflow.io/Pact Broker/pact-ruby)