0001-api_particulier-do-not-log-404-for-family-endpoint-4.patch
passerelle/apps/api_particulier/models.py | ||
---|---|---|
108 | 108 |
}) |
109 | 109 |
if response.status_code != 200: |
110 | 110 |
# avoid logging 404 errors indicating no matching data was found |
111 |
if data.get('error') == 'not_found' and 'incorrects ou ne correspondent' in data['message']: |
|
111 |
if data.get('error') == 'not_found' and \ |
|
112 |
('incorrects ou ne correspondent' in data['message'] or |
|
113 |
'Dossier allocataire inexistant' in data['message']): |
|
112 | 114 |
raise APIError( |
113 | 115 |
'No matching tax notice was found.', |
114 | 116 |
data={ |
tests/test_api_particulier.py | ||
---|---|---|
127 | 127 |
}, request=request) |
128 | 128 | |
129 | 129 | |
130 |
@urlmatch(netloc=r'^particulier.*\.api\.gouv\.fr$') |
|
131 |
def api_particulier_error_not_found_caf(url, request): |
|
132 |
return response(404, { |
|
133 |
'error': 'not_found', |
|
134 |
'message': 'Dossier allocataire inexistant. Le document ne peut être édité.' |
|
135 |
}, request=request) |
|
136 | ||
137 | ||
130 | 138 |
@pytest.yield_fixture |
131 | 139 |
def mock_api_particulier(): |
132 | 140 |
with HTTMock(api_particulier_v2_avis_imposition, api_particulier_v2_situation_familiale): |
... | ... | |
257 | 265 |
@pytest.mark.parametrize( |
258 | 266 |
'mock,should_log', [ |
259 | 267 |
(api_particulier_error_not_found, False), (api_particulier_error_500, True), |
260 |
(api_particulier_error_not_json, True) |
|
268 |
(api_particulier_error_not_json, True), (api_particulier_error_not_found_caf, False)
|
|
261 | 269 |
] |
262 | 270 |
) |
263 | 271 |
def test_api_particulier_dont_log_not_found(app, resource, mock, should_log): |
264 |
- |