API & Client - update API error messages to remove i18n workarounds
This commit is contained in:
@ -296,7 +296,7 @@ class TestUpdateSport(ApiTestCaseMixin):
|
||||
assert response.status_code == 403
|
||||
assert 'success' not in data['status']
|
||||
assert 'error' in data['status']
|
||||
assert 'You do not have permissions.' in data['message']
|
||||
assert 'you do not have permissions' in data['message']
|
||||
|
||||
def test_returns_error_if_payload_is_invalid(
|
||||
self, app: Flask, user_1_admin: User
|
||||
@ -315,7 +315,7 @@ class TestUpdateSport(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert 'Invalid payload.' in data['message']
|
||||
assert 'invalid payload' in data['message']
|
||||
|
||||
def test_it_returns_error_if_sport_does_not_exist(
|
||||
self, app: Flask, user_1_admin: User
|
||||
|
@ -37,7 +37,7 @@ class TestGetStatsByTime(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 404
|
||||
assert 'not found' in data['status']
|
||||
assert 'User does not exist.' in data['message']
|
||||
assert 'user does not exist' in data['message']
|
||||
|
||||
def test_it_returns_error_if_date_format_is_invalid(
|
||||
self,
|
||||
@ -62,7 +62,7 @@ class TestGetStatsByTime(ApiTestCaseMixin):
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
'error, please try again or contact the administrator'
|
||||
in data['message']
|
||||
)
|
||||
|
||||
@ -867,7 +867,7 @@ class TestGetStatsBySport(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 404
|
||||
assert 'not found' in data['status']
|
||||
assert 'User does not exist.' in data['message']
|
||||
assert 'user does not exist' in data['message']
|
||||
|
||||
def test_it_returns_error_if_sport_does_not_exist(
|
||||
self,
|
||||
@ -888,7 +888,7 @@ class TestGetStatsBySport(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 404
|
||||
assert 'not found' in data['status']
|
||||
assert 'Sport does not exist.' in data['message']
|
||||
assert 'sport does not exist' in data['message']
|
||||
|
||||
def test_it_returns_error_if_sport_id_is_invalid(
|
||||
self,
|
||||
@ -910,7 +910,7 @@ class TestGetStatsBySport(ApiTestCaseMixin):
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
'error, please try again or contact the administrator'
|
||||
in data['message']
|
||||
)
|
||||
|
||||
@ -988,4 +988,4 @@ class TestGetAllStats(ApiTestCaseMixin):
|
||||
assert response.status_code == 403
|
||||
assert 'success' not in data['status']
|
||||
assert 'error' in data['status']
|
||||
assert 'You do not have permissions.' in data['message']
|
||||
assert 'you do not have permissions' in data['message']
|
||||
|
@ -94,7 +94,7 @@ class TestGetWorkouts(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 401
|
||||
assert 'error' in data['status']
|
||||
assert 'Provide a valid auth token.' in data['message']
|
||||
assert 'provide a valid auth token' in data['message']
|
||||
|
||||
|
||||
class TestGetWorkoutsWithPagination(ApiTestCaseMixin):
|
||||
@ -228,7 +228,7 @@ class TestGetWorkoutsWithPagination(ApiTestCaseMixin):
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
'error, please try again or contact the administrator'
|
||||
in data['message']
|
||||
)
|
||||
|
||||
@ -707,7 +707,7 @@ class TestGetWorkout(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 403
|
||||
assert 'error' in data['status']
|
||||
assert 'You do not have permissions.' in data['message']
|
||||
assert 'you do not have permissions' in data['message']
|
||||
|
||||
def test_it_returns_404_if_workout_does_not_exist(
|
||||
self, app: Flask, user_1: User
|
||||
@ -738,7 +738,7 @@ class TestGetWorkout(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 404
|
||||
assert 'not found' in data['status']
|
||||
assert f'Workout not found (id: {random_short_id})' in data['message']
|
||||
assert f'workout not found (id: {random_short_id})' in data['message']
|
||||
assert data['data']['gpx'] == ''
|
||||
|
||||
def test_it_returns_404_on_getting_chart_data_if_workout_does_not_exist(
|
||||
@ -755,7 +755,7 @@ class TestGetWorkout(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 404
|
||||
assert 'not found' in data['status']
|
||||
assert f'Workout not found (id: {random_short_id})' in data['message']
|
||||
assert f'workout not found (id: {random_short_id})' in data['message']
|
||||
assert data['data']['chart_data'] == ''
|
||||
|
||||
def test_it_returns_404_on_getting_gpx_if_workout_have_no_gpx(
|
||||
@ -777,7 +777,7 @@ class TestGetWorkout(ApiTestCaseMixin):
|
||||
assert response.status_code == 404
|
||||
assert 'not found' in data['status']
|
||||
assert (
|
||||
f'No gpx file for this workout (id: {workout_short_id})'
|
||||
f'no gpx file for this workout (id: {workout_short_id})'
|
||||
in data['message']
|
||||
)
|
||||
|
||||
@ -800,7 +800,7 @@ class TestGetWorkout(ApiTestCaseMixin):
|
||||
assert response.status_code == 404
|
||||
assert 'not found' in data['status']
|
||||
assert (
|
||||
f'No gpx file for this workout (id: {workout_short_id})'
|
||||
f'no gpx file for this workout (id: {workout_short_id})'
|
||||
in data['message']
|
||||
)
|
||||
|
||||
@ -823,7 +823,7 @@ class TestGetWorkout(ApiTestCaseMixin):
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
'error, please try again or contact the administrator'
|
||||
in data['message']
|
||||
)
|
||||
assert 'data' not in data
|
||||
@ -847,7 +847,7 @@ class TestGetWorkout(ApiTestCaseMixin):
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
'error, please try again or contact the administrator'
|
||||
in data['message']
|
||||
)
|
||||
assert 'data' not in data
|
||||
|
@ -468,7 +468,7 @@ class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert data['status'] == 'fail'
|
||||
assert data['message'] == 'File extension not allowed.'
|
||||
assert data['message'] == 'file extension not allowed'
|
||||
|
||||
def test_it_returns_400_if_sport_id_is_not_provided(
|
||||
self, app: Flask, user_1: User, sport_1_cycling: Sport, gpx_file: str
|
||||
@ -489,7 +489,7 @@ class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert data['status'] == 'error'
|
||||
assert data['message'] == 'Invalid payload.'
|
||||
assert data['message'] == 'invalid payload'
|
||||
|
||||
def test_it_returns_500_if_sport_id_does_not_exists(
|
||||
self, app: Flask, user_1: User, sport_1_cycling: Sport, gpx_file: str
|
||||
@ -530,7 +530,7 @@ class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert data['status'] == 'fail'
|
||||
assert data['message'] == 'No file part.'
|
||||
assert data['message'] == 'no file part'
|
||||
|
||||
def test_it_returns_error_if_file_size_exceeds_limit(
|
||||
self,
|
||||
@ -605,7 +605,7 @@ class TestPostWorkoutWithoutGpx(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert 'Invalid payload.' in data['message']
|
||||
assert 'invalid payload' in data['message']
|
||||
|
||||
def test_it_returns_500_if_workout_format_is_invalid(
|
||||
self, app: Flask, user_1: User, sport_1_cycling: Sport
|
||||
@ -911,7 +911,7 @@ class TestPostAndGetWorkoutWithGpx(ApiTestCaseMixin):
|
||||
assert data['status'] == 'error'
|
||||
assert (
|
||||
data['message']
|
||||
== 'Error. Please try again or contact the administrator.'
|
||||
== 'error, please try again or contact the administrator'
|
||||
)
|
||||
|
||||
def test_it_gets_an_workout_created_with_gpx(
|
||||
@ -1025,7 +1025,7 @@ class TestPostAndGetWorkoutWithGpx(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 403
|
||||
assert 'error' in data['status']
|
||||
assert data['message'] == 'You do not have permissions.'
|
||||
assert data['message'] == 'you do not have permissions'
|
||||
|
||||
def test_it_returns_500_on_invalid_segment_id(
|
||||
self, app: Flask, user_1: User, sport_1_cycling: Sport, gpx_file: str
|
||||
|
@ -173,7 +173,7 @@ class TestEditWorkoutWithGpx(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 403
|
||||
assert 'error' in data['status']
|
||||
assert 'You do not have permissions.' in data['message']
|
||||
assert 'you do not have permissions' in data['message']
|
||||
|
||||
def test_it_updates_sport(
|
||||
self,
|
||||
@ -217,7 +217,7 @@ class TestEditWorkoutWithGpx(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert 'Invalid payload.' in data['message']
|
||||
assert 'invalid payload' in data['message']
|
||||
|
||||
def test_it_raises_500_if_sport_does_not_exists(
|
||||
self, app: Flask, user_1: User, sport_1_cycling: Sport, gpx_file: str
|
||||
@ -236,7 +236,7 @@ class TestEditWorkoutWithGpx(ApiTestCaseMixin):
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
'error, please try again or contact the administrator'
|
||||
in data['message']
|
||||
)
|
||||
|
||||
@ -405,7 +405,7 @@ class TestEditWorkoutWithoutGpx(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 403
|
||||
assert 'error' in data['status']
|
||||
assert 'You do not have permissions.' in data['message']
|
||||
assert 'you do not have permissions' in data['message']
|
||||
|
||||
def test_it_updates_an_workout_wo_gpx_with_timezone(
|
||||
self,
|
||||
@ -564,7 +564,7 @@ class TestEditWorkoutWithoutGpx(ApiTestCaseMixin):
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 400
|
||||
assert 'error' in data['status']
|
||||
assert 'Invalid payload.' in data['message']
|
||||
assert 'invalid payload' in data['message']
|
||||
|
||||
def test_it_returns_500_if_date_format_is_invalid(
|
||||
self,
|
||||
@ -593,7 +593,7 @@ class TestEditWorkoutWithoutGpx(ApiTestCaseMixin):
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
'error, please try again or contact the administrator'
|
||||
in data['message']
|
||||
)
|
||||
|
||||
|
@ -58,7 +58,7 @@ class TestDeleteWorkoutWithGpx(ApiTestCaseMixin):
|
||||
|
||||
assert response.status_code == 403
|
||||
assert 'error' in data['status']
|
||||
assert 'You do not have permissions.' in data['message']
|
||||
assert 'you do not have permissions' in data['message']
|
||||
|
||||
def test_it_returns_404_if_workout_does_not_exist(
|
||||
self, app: Flask, user_1: User
|
||||
@ -91,7 +91,7 @@ class TestDeleteWorkoutWithGpx(ApiTestCaseMixin):
|
||||
assert response.status_code == 500
|
||||
assert 'error' in data['status']
|
||||
assert (
|
||||
'Error. Please try again or contact the administrator.'
|
||||
'error, please try again or contact the administrator'
|
||||
in data['message']
|
||||
)
|
||||
|
||||
@ -137,4 +137,4 @@ class TestDeleteWorkoutWithoutGpx(ApiTestCaseMixin):
|
||||
|
||||
assert response.status_code == 403
|
||||
assert 'error' in data['status']
|
||||
assert 'You do not have permissions.' in data['message']
|
||||
assert 'you do not have permissions' in data['message']
|
||||
|
Reference in New Issue
Block a user