From 3f7feced8779dc78d903d3463f176042598ec24c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 18:28:51 +0200 Subject: Merging upstream version 8.2404.0. Signed-off-by: Daniel Baumann --- tests/omhttp-validate-response.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/omhttp-validate-response.py (limited to 'tests/omhttp-validate-response.py') diff --git a/tests/omhttp-validate-response.py b/tests/omhttp-validate-response.py new file mode 100644 index 0000000..ef9f09e --- /dev/null +++ b/tests/omhttp-validate-response.py @@ -0,0 +1,34 @@ +import json +import argparse +from collections import defaultdict + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Archive and delete core app log files') + parser.add_argument('--error', action='store', type=str, help='error') + parser.add_argument('--response', action='store', type=str, help='response') + args = parser.parse_args() + + messages = defaultdict(dict) + with open(args.error, "r") as error_f, open(args.response, "r") as response_f: + for line in error_f: + json_obj = json.loads(line) + # postdata contains a json string of records array + records = json.loads(json_obj['request']['postdata']) + if records: + for i, val in enumerate(records['records']): + messages[val['value']['msgnum']]['response'] = json_obj['response'] + messages[val['value']['msgnum']]['index'] = i + #print (len(messages), "messages:", messages) + + # validate with responses + for line in response_f: + json_obj = json.loads(line) + msgnum = json_obj['message']['msgnum'] + code = json_obj['response']['code'] + body = json_obj['response']['body'] + batch_index = json_obj['response']['batch_index'] + #print('msgnum:', msgnum, 'code:', code, 'body:', body, 'batch_index:', batch_index) + assert(msgnum in messages) + assert(messages[msgnum]['response']['status'] == code) + assert(messages[msgnum]['response']['message'] == body) + assert(messages[msgnum]['index'] == batch_index) -- cgit v1.2.3