From 89534f3ef4148c005e59ba8349e1f560e518d3c0 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 25 May 2022 14:13:28 +0200 Subject: [PATCH] utils/soap: disable zeep.transports logger (#64940) --- passerelle/utils/soap.py | 4 +++- tests/test_utils_soap.py | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/passerelle/utils/soap.py b/passerelle/utils/soap.py index 338fe860..f0985ca9 100644 --- a/passerelle/utils/soap.py +++ b/passerelle/utils/soap.py @@ -22,6 +22,7 @@ from zeep.cache import InMemoryCache from zeep.transports import Transport from passerelle.utils.jsonresponse import APIError +from passerelle.utils.logging import ignore_loggers class SOAPError(APIError): @@ -90,7 +91,8 @@ class SOAPTransport(Transport): ) def post_xml(self, *args, **kwargs): - response = super().post_xml(*args, **kwargs) + with ignore_loggers('zeep', 'zeep.transports'): + response = super().post_xml(*args, **kwargs) if self.remove_first_bytes_for_xml: return ResponseFixContentWrapper(response) diff --git a/tests/test_utils_soap.py b/tests/test_utils_soap.py index 35fc9472..2e186489 100644 --- a/tests/test_utils_soap.py +++ b/tests/test_utils_soap.py @@ -13,6 +13,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import logging + import mock import pytest import requests @@ -80,10 +82,10 @@ def test_disable_strict_mode(mocked_post): @mock.patch('requests.sessions.Session.post') -def test_remove_first_bytes_for_xml(mocked_post): +def test_remove_first_bytes_for_xml(mocked_post, caplog): response = requests.Response() response.status_code = 200 - response._content = force_bytes( + response._content = b'\x8b' + force_bytes( '''blabla \n @@ -107,3 +109,6 @@ def test_remove_first_bytes_for_xml(mocked_post): assert len(result) == 2 assert result['skipMe'] == 1.2 assert result['price'] == 4.2 + + caplog.set_level(logging.DEBUG) + result = client.service.GetLastTradePrice(tickerSymbol='banana') -- 2.35.1