0001-utils-soap-disable-zeep.transports-logger-64940.patch
passerelle/utils/soap.py | ||
---|---|---|
22 | 22 |
from zeep.transports import Transport |
23 | 23 | |
24 | 24 |
from passerelle.utils.jsonresponse import APIError |
25 |
from passerelle.utils.logging import ignore_loggers |
|
25 | 26 | |
26 | 27 | |
27 | 28 |
class SOAPError(APIError): |
... | ... | |
90 | 91 |
) |
91 | 92 | |
92 | 93 |
def post_xml(self, *args, **kwargs): |
93 |
response = super().post_xml(*args, **kwargs) |
|
94 |
with ignore_loggers('zeep', 'zeep.transports'): |
|
95 |
response = super().post_xml(*args, **kwargs) |
|
94 | 96 | |
95 | 97 |
if self.remove_first_bytes_for_xml: |
96 | 98 |
return ResponseFixContentWrapper(response) |
tests/test_utils_soap.py | ||
---|---|---|
13 | 13 |
# You should have received a copy of the GNU Affero General Public License |
14 | 14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 | |
16 |
import logging |
|
17 | ||
16 | 18 |
import mock |
17 | 19 |
import pytest |
18 | 20 |
import requests |
... | ... | |
80 | 82 | |
81 | 83 | |
82 | 84 |
@mock.patch('requests.sessions.Session.post') |
83 |
def test_remove_first_bytes_for_xml(mocked_post): |
|
85 |
def test_remove_first_bytes_for_xml(mocked_post, caplog):
|
|
84 | 86 |
response = requests.Response() |
85 | 87 |
response.status_code = 200 |
86 |
response._content = force_bytes( |
|
88 |
response._content = b'\x8b' + force_bytes(
|
|
87 | 89 |
'''blabla \n<?xml version='1.0' encoding='utf-8'?> |
88 | 90 |
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> |
89 | 91 |
<soap-env:Body> |
... | ... | |
107 | 109 |
assert len(result) == 2 |
108 | 110 |
assert result['skipMe'] == 1.2 |
109 | 111 |
assert result['price'] == 4.2 |
112 | ||
113 |
caplog.set_level(logging.DEBUG) |
|
114 |
result = client.service.GetLastTradePrice(tickerSymbol='banana') |
|
110 |
- |