API & Client - add API error messages translation
This commit is contained in:
@ -341,7 +341,7 @@ def get_activity(auth_user_id, activity_id):
|
||||
- Provide a valid auth token.
|
||||
- Signature expired. Please log in again.
|
||||
- Invalid token. Please log in again.
|
||||
:statuscode 403: You do not have permissions
|
||||
:statuscode 403: You do not have permissions.
|
||||
:statuscode 404: activity not found
|
||||
|
||||
"""
|
||||
|
@ -63,8 +63,8 @@ def test_user_registration_invalid_short_username(app):
|
||||
data = json.loads(response.data.decode())
|
||||
assert data['status'] == 'error'
|
||||
assert (
|
||||
data['message'] == "Errors: Username: 3 to 12 characters required.\n"
|
||||
) # noqa
|
||||
data['message'] == "Username: 3 to 12 characters required.\n"
|
||||
)
|
||||
assert response.content_type == 'application/json'
|
||||
assert response.status_code == 400
|
||||
|
||||
@ -86,8 +86,8 @@ def test_user_registration_invalid_long_username(app):
|
||||
data = json.loads(response.data.decode())
|
||||
assert data['status'] == 'error'
|
||||
assert (
|
||||
data['message'] == "Errors: Username: 3 to 12 characters required.\n"
|
||||
) # noqa
|
||||
data['message'] == "Username: 3 to 12 characters required.\n"
|
||||
)
|
||||
assert response.content_type == 'application/json'
|
||||
assert response.status_code == 400
|
||||
|
||||
@ -108,7 +108,7 @@ def test_user_registration_invalid_email(app):
|
||||
)
|
||||
data = json.loads(response.data.decode())
|
||||
assert data['status'] == 'error'
|
||||
assert data['message'] == "Errors: Valid email must be provided.\n" # noqa
|
||||
assert data['message'] == "Valid email must be provided.\n"
|
||||
assert response.content_type == 'application/json'
|
||||
assert response.status_code == 400
|
||||
|
||||
@ -130,8 +130,8 @@ def test_user_registration_invalid_short_password(app):
|
||||
data = json.loads(response.data.decode())
|
||||
assert data['status'] == 'error'
|
||||
assert (
|
||||
data['message'] == "Errors: Password: 8 characters required.\n"
|
||||
) # noqa
|
||||
data['message'] == "Password: 8 characters required.\n"
|
||||
)
|
||||
assert response.content_type == 'application/json'
|
||||
assert response.status_code == 400
|
||||
|
||||
@ -154,8 +154,8 @@ def test_user_registration_mismatched_password(app):
|
||||
assert data['status'] == 'error'
|
||||
assert (
|
||||
data['message']
|
||||
== "Errors: Password and password confirmation don\'t match.\n"
|
||||
) # noqa
|
||||
== "Password and password confirmation don\'t match.\n"
|
||||
)
|
||||
assert response.content_type == 'application/json'
|
||||
assert response.status_code == 400
|
||||
|
||||
@ -262,7 +262,7 @@ def test_user_registration_invalid_data(app):
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
in data['message']
|
||||
) # noqa
|
||||
)
|
||||
assert 'error' in data['status']
|
||||
|
||||
|
||||
@ -700,7 +700,7 @@ def test_user_profile_invalid_password(app, user_1):
|
||||
assert data['status'] == 'error'
|
||||
assert (
|
||||
data['message'] == 'Password and password confirmation don\'t match.\n'
|
||||
) # noqa
|
||||
)
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
@ -736,7 +736,7 @@ def test_user_profile_missing_password_conf(app, user_1):
|
||||
assert data['status'] == 'error'
|
||||
assert (
|
||||
data['message'] == 'Password and password confirmation don\'t match.\n'
|
||||
) # noqa
|
||||
)
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
|
@ -68,10 +68,10 @@ def register_user():
|
||||
- Invalid payload.
|
||||
- Sorry. That user already exists.
|
||||
- Errors:
|
||||
- Username: 3 to 12 characters required.
|
||||
- 3 to 12 characters required for usernanme.
|
||||
- Valid email must be provided.
|
||||
- Password and password confirmation don't match.
|
||||
- Password: 8 characters required.
|
||||
- 8 characters required for password.
|
||||
:statuscode 403:
|
||||
Error. Registration is disabled.
|
||||
:statuscode 500:
|
||||
@ -112,7 +112,7 @@ def register_user():
|
||||
}
|
||||
return jsonify(response_object), 500
|
||||
if ret != '':
|
||||
response_object = {'status': 'error', 'message': 'Errors: ' + ret}
|
||||
response_object = {'status': 'error', 'message': ret}
|
||||
return jsonify(response_object), 400
|
||||
|
||||
try:
|
||||
@ -553,7 +553,7 @@ def edit_picture(user_id):
|
||||
max_file_size = current_app.config['MAX_CONTENT_LENGTH']
|
||||
response_object = {
|
||||
'status': 'fail',
|
||||
'message': 'Error during picture update: file size exceeds '
|
||||
'message': 'Error during picture update, file size exceeds '
|
||||
f'{display_readable_file_size(max_file_size)}.',
|
||||
}
|
||||
return jsonify(response_object), 413
|
||||
|
@ -143,7 +143,7 @@ def get_single_user(auth_user_id, user_id):
|
||||
- Signature expired. Please log in again.
|
||||
- Invalid token. Please log in again.
|
||||
:statuscode 404:
|
||||
- User does not exist
|
||||
- User does not exist.
|
||||
"""
|
||||
|
||||
response_object = {'status': 'fail', 'message': 'User does not exist.'}
|
||||
@ -180,7 +180,7 @@ def get_picture(user_id):
|
||||
|
||||
:statuscode 200: success
|
||||
:statuscode 404:
|
||||
- User does not exist
|
||||
- User does not exist.
|
||||
- No picture.
|
||||
|
||||
"""
|
||||
|
@ -66,7 +66,7 @@ def verify_extension_and_size(file_type, req):
|
||||
elif file_extension != 'zip' and req.content_length > max_file_size:
|
||||
response_object = {
|
||||
'status': 'fail',
|
||||
'message': 'Error during picture update: file size exceeds '
|
||||
'message': 'Error during picture update, file size exceeds '
|
||||
f'{display_readable_file_size(max_file_size)}.',
|
||||
}
|
||||
code = 413
|
||||
|
Reference in New Issue
Block a user