astech: don't use bytes in APIError content (#83342)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Thomas NOËL 2023-11-10 15:32:13 +01:00
parent 81f58cad59
commit 0a28034137
2 changed files with 2 additions and 2 deletions

View File

@ -161,7 +161,7 @@ class ASTech(BaseResource, HTTPResource):
try:
content = response.json()
except ValueError:
content = response.content[:1024]
content = '%r' % response.content[:1024]
raise APIError(
'AS-TECH response: %s %s' % (response.status_code, response.reason),
data={

View File

@ -136,7 +136,7 @@ def test_connections(mocked_request, app, setup):
assert response.json['err_class'].endswith('APIError')
assert response.json['err_desc'] == 'AS-TECH response: 500 Crashhhh'
assert response.json['data']['error']['status'] == 500
assert response.json['data']['error']['content'] == 'crash'
assert 'crash' in response.json['data']['error']['content']
mocked_request.return_value = tests.utils.FakedResponse(content='not json', status_code=200, reason='OK')
response = app.get(endpoint)
assert response.json['err'] == 1