api_particulier: do not log 404 for family endpoint (#44043)

This commit is contained in:
Valentin Deniaud 2020-06-16 10:53:26 +02:00
parent 8e1fa84c97
commit aaba26e6ee
2 changed files with 12 additions and 2 deletions

View File

@ -108,7 +108,9 @@ class APIParticulier(BaseResource):
})
if response.status_code != 200:
# avoid logging 404 errors indicating no matching data was found
if data.get('error') == 'not_found' and 'incorrects ou ne correspondent' in data['message']:
if data.get('error') == 'not_found' and \
('incorrects ou ne correspondent' in data['message'] or
'Dossier allocataire inexistant' in data['message']):
raise APIError(
'No matching tax notice was found.',
data={

View File

@ -127,6 +127,14 @@ def api_particulier_error_not_found(url, request):
}, request=request)
@urlmatch(netloc=r'^particulier.*\.api\.gouv\.fr$')
def api_particulier_error_not_found_caf(url, request):
return response(404, {
'error': 'not_found',
'message': 'Dossier allocataire inexistant. Le document ne peut être édité.'
}, request=request)
@pytest.yield_fixture
def mock_api_particulier():
with HTTMock(api_particulier_v2_avis_imposition, api_particulier_v2_situation_familiale):
@ -257,7 +265,7 @@ def test_detail_page(app, resource):
@pytest.mark.parametrize(
'mock,should_log', [
(api_particulier_error_not_found, False), (api_particulier_error_500, True),
(api_particulier_error_not_json, True)
(api_particulier_error_not_json, True), (api_particulier_error_not_found_caf, False)
]
)
def test_api_particulier_dont_log_not_found(app, resource, mock, should_log):