Compare commits

..

1 Commits

Author SHA1 Message Date
Serghei Mihai 6db003b1c8 wscalls: unflatten payload when calling webservice (#66916)
gitea/wcs/pipeline/head There was a failure building this commit Details
2024-03-24 22:42:58 +01:00
2 changed files with 9 additions and 3 deletions

View File

@ -297,7 +297,7 @@ def test_webservice_with_unflattened_payload_keys(http_requests, pub):
wscall.request = {
'method': 'POST',
'url': 'http://remote.example.net/json',
'post_data': {'foo/0': 'first', 'foo/1': 'second', 'bar': 'example'},
'post_data': {'foo/0': 'first', 'foo/1': 'second', 'name': 'example'},
}
wscall.store()

View File

@ -591,12 +591,18 @@ def test_webservice_with_unflattened_payload_keys(http_requests, pub):
item = WebserviceCallStatusItem()
item.url = 'http://remote.example.net'
item.post_data = {'foo/0': 'first', 'foo/1': 'second', 'bar': 'example', 'random//field': 'value'}
item.post_data = {
'foo/0': 'first',
'foo/1': 'second',
'bar': 'example',
'form//name': '{{ form_name }}',
}
pub.substitutions.feed(formdata)
item.perform(formdata)
assert http_requests.get_last('url') == 'http://remote.example.net/'
assert http_requests.get_last('method') == 'POST'
payload = json.loads(http_requests.get_last('body'))
assert payload == {'foo': ['first', 'second'], 'bar': 'example', 'random/field': 'value'}
assert payload == {'foo': ['first', 'second'], 'bar': 'example', 'form/name': 'baz'}
assert http_requests.count() == 1
http_requests.empty()