django22: fix tests (logs) (#49188)

This commit is contained in:
Lauréline Guérin 2020-12-11 08:27:47 +01:00
parent 2110557290
commit 9ab90f4b06
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 10 additions and 9 deletions

View File

@ -498,15 +498,17 @@ def test_dossier_http_error(app, mdph13, mock_http, caplog):
mock_http.add_response({'status_code': 401, 'content': 'wtf', 'reason': 'Authentication required'})
response = app.post(url, status=500)
assert response.json['err_class'] == 'requests.exceptions.HTTPError'
assert caplog.records[-1].levelno == logging.ERROR
assert caplog.records[-1].getMessage() == 'GET http://cd13.fr/situation/dossier/1234 (=> 401)'
assert hasattr(caplog.records[-1].request, 'META')
assert caplog.records[2].levelno == logging.ERROR
assert caplog.records[2].getMessage() == 'GET http://cd13.fr/situation/dossier/1234 (=> 401)'
assert hasattr(caplog.records[2].request, 'META')
def raise_ssl_error(url, request):
raise requests.exceptions.SSLError(request=request)
idx = len(caplog.records)
mock_http.add_response(raise_ssl_error)
response = app.post(url, status=500)
assert response.json['err_class'] == 'requests.exceptions.SSLError'
assert caplog.records[-1].levelno == logging.ERROR
assert caplog.records[-1].getMessage() == 'GET http://cd13.fr/situation/dossier/1234 (=> SSLError())'
assert hasattr(caplog.records[-1].request, 'META')
assert caplog.records[idx + 2].levelno == logging.ERROR
assert caplog.records[idx + 2].getMessage() == 'GET http://cd13.fr/situation/dossier/1234 (=> SSLError())'
assert hasattr(caplog.records[idx + 2].request, 'META')

View File

@ -114,9 +114,9 @@ def test_trace_emails(app, settings, dummy_csv_datasource, email_handler, mailou
slug=dummy_csv_datasource.slug),
status=500)
assert len(mailoutbox) == 1
assert mailoutbox[0].to == ['admin@example.net']
idx = len(mailoutbox)
logging_parameters.trace_emails = 'john.doe@example.net'
logging_parameters.save()
app.get(generic_endpoint_url(connector='csvdatasource',
@ -124,9 +124,8 @@ def test_trace_emails(app, settings, dummy_csv_datasource, email_handler, mailou
slug=dummy_csv_datasource.slug),
status=500)
assert len(mailoutbox) == 2
assert mailoutbox[0].to == ['admin@example.net']
assert mailoutbox[1].to == ['john.doe@example.net']
assert mailoutbox[idx].to == ['john.doe@example.net']
def test_jsonb_migration(transactional_db):