0007-django22-fix-tests-logs-49188.patch
tests/test_mdph13.py | ||
---|---|---|
498 | 498 |
mock_http.add_response({'status_code': 401, 'content': 'wtf', 'reason': 'Authentication required'}) |
499 | 499 |
response = app.post(url, status=500) |
500 | 500 |
assert response.json['err_class'] == 'requests.exceptions.HTTPError' |
501 |
assert caplog.records[-1].levelno == logging.ERROR
|
|
502 |
assert caplog.records[-1].getMessage() == 'GET http://cd13.fr/situation/dossier/1234 (=> 401)'
|
|
503 |
assert hasattr(caplog.records[-1].request, 'META')
|
|
501 |
assert caplog.records[2].levelno == logging.ERROR
|
|
502 |
assert caplog.records[2].getMessage() == 'GET http://cd13.fr/situation/dossier/1234 (=> 401)'
|
|
503 |
assert hasattr(caplog.records[2].request, 'META')
|
|
504 | 504 | |
505 | 505 |
def raise_ssl_error(url, request): |
506 | 506 |
raise requests.exceptions.SSLError(request=request) |
507 | ||
508 |
idx = len(caplog.records) |
|
507 | 509 |
mock_http.add_response(raise_ssl_error) |
508 | 510 |
response = app.post(url, status=500) |
509 | 511 |
assert response.json['err_class'] == 'requests.exceptions.SSLError' |
510 |
assert caplog.records[-1].levelno == logging.ERROR |
|
511 |
assert caplog.records[-1].getMessage() == 'GET http://cd13.fr/situation/dossier/1234 (=> SSLError())' |
|
512 |
assert hasattr(caplog.records[-1].request, 'META') |
|
512 |
assert caplog.records[idx + 2].levelno == logging.ERROR |
|
513 |
assert caplog.records[idx + 2].getMessage() == 'GET http://cd13.fr/situation/dossier/1234 (=> SSLError())' |
|
514 |
assert hasattr(caplog.records[idx + 2].request, 'META') |
tests/test_misc.py | ||
---|---|---|
114 | 114 |
slug=dummy_csv_datasource.slug), |
115 | 115 |
status=500) |
116 | 116 | |
117 |
assert len(mailoutbox) == 1 |
|
118 | 117 |
assert mailoutbox[0].to == ['admin@example.net'] |
119 | 118 | |
119 |
idx = len(mailoutbox) |
|
120 | 120 |
logging_parameters.trace_emails = 'john.doe@example.net' |
121 | 121 |
logging_parameters.save() |
122 | 122 |
app.get(generic_endpoint_url(connector='csvdatasource', |
... | ... | |
124 | 124 |
slug=dummy_csv_datasource.slug), |
125 | 125 |
status=500) |
126 | 126 | |
127 |
assert len(mailoutbox) == 2 |
|
128 | 127 |
assert mailoutbox[0].to == ['admin@example.net'] |
129 |
assert mailoutbox[1].to == ['john.doe@example.net']
|
|
128 |
assert mailoutbox[idx].to == ['john.doe@example.net']
|
|
130 | 129 | |
131 | 130 | |
132 | 131 |
def test_jsonb_migration(transactional_db): |
133 |
- |