0001-solis_apa-raise-APIError-instead-of-ValueError-40822.patch
passerelle/contrib/solis_apa/models.py | ||
---|---|---|
28 | 28 |
from passerelle.base.models import BaseResource |
29 | 29 |
from passerelle.compat import json_loads |
30 | 30 |
from passerelle.contrib.solis_apa import conciliation, suivi, integration |
31 |
from passerelle.utils.jsonresponse import APIError |
|
31 | 32 | |
32 | 33 |
HEADERS = { |
33 | 34 |
'Accept': 'application/json', |
... | ... | |
313 | 314 |
return output |
314 | 315 | |
315 | 316 |
def import_flow(self, data): |
316 |
uri = 'importFlow?flow=ImportIntegrationDemande&application=%s' %APPLICATION |
|
317 |
uri = 'importFlow?flow=ImportIntegrationDemande&application=%s' % APPLICATION
|
|
317 | 318 |
url = self.get_resource_url(uri) |
318 | 319 | |
319 | 320 |
data = {'ImportInputWSDemandeApa': integration.build_message(json_loads(data))} |
... | ... | |
321 | 322 |
self.logger.debug('Demande APA: %s' % data, extra={'solis_apa_demande': data}) |
322 | 323 |
response = self.requests.post(url, data=data, headers=HEADERS) |
323 | 324 |
if response.status_code != 200: |
324 |
raise ValueError('integration ws: error code %d' %(response.status_code))
|
|
325 |
raise APIError('integration ws: error code %d' % response.status_code)
|
|
325 | 326 | |
326 | 327 |
response = self._check_requests_response(response) |
327 | 328 |
tests/test_solis_apa.py | ||
---|---|---|
76 | 76 |
resp.json['data']['indexDemande'] == 221155 |
77 | 77 | |
78 | 78 | |
79 |
@mock.patch('passerelle.utils.Request.post') |
|
80 |
def test_integration_error(mocked_post, setup, app, url): |
|
81 |
mocked_post.return_value = mock.Mock(status_code=500) |
|
82 |
resp = app.post_json(url('integration'), params=json_get_data('premiere_demande_apa_etablissement.json')) |
|
83 |
assert resp.json['err_desc'] == "integration ws: error code 500" |
|
84 |
assert resp.json['err'] == 1 |
|
85 | ||
86 | ||
79 | 87 |
def test_get_conjoint(setup, url, formdata): |
80 | 88 |
data = integration.build_message(formdata) |
81 | 89 |
if formdata['display_id'] == '25-3': |
82 |
- |