From 4f75d37af9836bac46d06d0927ec02bd557b7e2f Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 23 Mar 2022 06:21:19 +0100 Subject: [PATCH 03/11] wip: add more test around jsonify --- tests/test_soap.py | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/tests/test_soap.py b/tests/test_soap.py index 28fe1c9f..b50063f3 100644 --- a/tests/test_soap.py +++ b/tests/test_soap.py @@ -53,6 +53,7 @@ class SOAP11: + @@ -99,7 +100,8 @@ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> - Hello John! + Hello + John! ''' @@ -117,12 +119,23 @@ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 'required': ['firstName', 'lastName'], 'type': 'object', } - OUTPUT_SCHEMA = {'type': 'string'} + OUTPUT_SCHEMA = { + 'properties': { + 'greeting': {'type': 'string'}, + 'who': {'type': 'string'}, + }, + 'required': ['greeting', 'who'], + 'type': 'object', + } INPUT_DATA = { 'firstName/string/0': 'John', 'firstName/string/1': 'Bill', 'lastName': 'Doe', } + OUTPUT_DATA = { + 'greeting': 'Hello', + 'who': 'John!', + } class SOAP12(SOAP11): @@ -151,6 +164,7 @@ class SOAP12(SOAP11): + @@ -202,7 +216,8 @@ class SOAP12(SOAP11): - Hello John! + Hello + John! ''' @@ -214,11 +229,26 @@ class SOAP12(SOAP11): }, 'required': ['firstName', 'lastName'], } + OUTPUT_SCHEMA = { + 'properties': { + 'greeting': {'type': 'string'}, + 'who': { + 'type': 'array', + 'items': {'type': 'string'}, + }, + }, + 'required': ['greeting', 'who'], + 'type': 'object', + } INPUT_DATA = { 'firstName/0': 'John', 'firstName/1': 'Bill', 'lastName': 'Doe', } + OUTPUT_DATA = { + 'greeting': 'Hello', + 'who': ['John!'], + } @pytest.fixture(params=[SOAP11, SOAP12]) @@ -272,7 +302,7 @@ def test_say_hello_method_ok_get(connector, app, caplog, soap): assert '>Bill<' in soap.endpoint_mock.handlers[0].call['requests'][-1].body.decode() assert '>Doe<' in soap.endpoint_mock.handlers[0].call['requests'][-1].body.decode() - assert resp.json == {'data': 'Hello John!', 'err': 0} + assert resp.json == {'data': soap.OUTPUT_DATA, 'err': 0} def test_say_hello_method_ok_post_json(connector, app, caplog, soap): @@ -280,4 +310,4 @@ def test_say_hello_method_ok_post_json(connector, app, caplog, soap): assert '>John<' in soap.endpoint_mock.handlers[0].call['requests'][-1].body.decode() assert '>Bill<' in soap.endpoint_mock.handlers[0].call['requests'][-1].body.decode() assert '>Doe<' in soap.endpoint_mock.handlers[0].call['requests'][-1].body.decode() - assert resp.json == {'data': 'Hello John!', 'err': 0} + assert resp.json == {'data': soap.OUTPUT_DATA, 'err': 0} -- 2.35.1