diff --git a/fittrackee/tests/fixtures/fixtures_workouts.py b/fittrackee/tests/fixtures/fixtures_workouts.py index 927f9b60..23d6c04f 100644 --- a/fittrackee/tests/fixtures/fixtures_workouts.py +++ b/fittrackee/tests/fixtures/fixtures_workouts.py @@ -591,6 +591,56 @@ def gpx_file_invalid_xml() -> str: '' '' # noqa ' ' + ' ' + ' just a workout' + ) + + +@pytest.fixture() +def gpx_file_without_time() -> str: + return ( + '' + '' # noqa + ' ' + ' ' + ' just a workout' + ' ' + ' ' + ' 998' + ' ' + ' ' + ' 998' + ' ' + ' ' + ' 994' + ' ' + ' ' + ' 994' + ' ' + ' ' + ' 994' + ' ' + ' ' + ' 993' + ' ' + ' ' + ' 992' + ' ' + ' ' + ' 992' + ' ' + ' ' + ' 987' + ' ' + ' ' + ' 987' + ' ' + ' ' + ' 987' + ' ' + ' ' + ' ' + '' ) diff --git a/fittrackee/tests/workouts/test_workouts_api_1_post.py b/fittrackee/tests/workouts/test_workouts_api_1_post.py index 304ec429..6587070b 100644 --- a/fittrackee/tests/workouts/test_workouts_api_1_post.py +++ b/fittrackee/tests/workouts/test_workouts_api_1_post.py @@ -674,7 +674,7 @@ class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin): ), ) - data = self.assert_500(response, 'error during gpx processing') + data = self.assert_500(response, 'no tracks in gpx file') assert 'data' not in data def test_it_returns_500_if_gpx_has_invalid_xml( @@ -703,7 +703,36 @@ class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin): ), ) - data = self.assert_500(response, 'error during gpx file parsing') + data = self.assert_500(response, 'gpx file is invalid') + assert 'data' not in data + + def test_it_returns_500_if_gpx_has_no_time( + self, + app: Flask, + user_1: User, + sport_1_cycling: Sport, + gpx_file_without_time: str, + ) -> None: + client, auth_token = self.get_test_client_and_auth_token( + app, user_1.email + ) + + response = client.post( + '/api/workouts', + data=dict( + file=( + BytesIO(str.encode(gpx_file_without_time)), + 'example.gpx', + ), + data='{"sport_id": 1}', + ), + headers=dict( + content_type='multipart/form-data', + Authorization=f'Bearer {auth_token}', + ), + ) + + data = self.assert_500(response, '