0001-iparapheur-correct-message-on-transport-error-31058.patch
passerelle/contrib/iparapheur/soap.py | ||
---|---|---|
76 | 76 |
resp = self.model.requests.post(request.url, data=request.message, |
77 | 77 |
headers=request.headers, **self.get_requests_kwargs()) |
78 | 78 |
except(RequestException,) as e: |
79 |
raise TransportError(e.message.message, None)
|
|
79 |
raise TransportError(e.message, None, StringIO.StringIO(e.message))
|
|
80 | 80 | |
81 | 81 |
if resp.status_code in (202, 204): |
82 | 82 |
return None |
tests/test_iparapheur.py | ||
---|---|---|
422 | 422 |
f.write('some text') |
423 | 423 |
with text_path.open() as f: |
424 | 424 |
assert 'text/plain' == get_magic_mime(f.read()) |
425 | ||
426 |
@mock.patch('passerelle.utils.Request.get') |
|
427 |
@mock.patch('passerelle.utils.Request.post', side_effect=ConnectionError('mocked error')) |
|
428 |
@mock.patch('passerelle.contrib.iparapheur.soap.HttpAuthenticated.open') |
|
429 |
def test_send_transporterror(http_open, mocked_post, mocked_get, app, conn, xmlmime, wsdl_file): |
|
430 |
http_open.return_value = open(xmlmime) |
|
431 |
mocked_get.return_value = mock.Mock(content=open(wsdl_file).read(), status_code=200) |
|
432 |
url = reverse('generic-endpoint', kwargs={'connector': 'iparapheur', |
|
433 |
'endpoint': 'ping', 'slug': conn.slug}) |
|
434 |
url += '?apikey=%s' % API_KEY |
|
435 |
resp = app.get(url) |
|
436 |
assert resp.json['err'] == 1 |
|
437 |
assert resp.json['data'] is None |
|
438 |
assert 'mocked error' in resp.json['err_desc'] |
|
425 |
- |