API - do not return elevation in chart data when no elevation in file
This commit is contained in:
@ -1721,7 +1721,65 @@ class TestPostAndGetWorkoutWithGpx(ApiTestCaseMixin):
|
||||
assert response.status_code == 200
|
||||
assert 'success' in data['status']
|
||||
assert data['message'] == ''
|
||||
assert data['data']['chart_data'] != ''
|
||||
assert len(data['data']['chart_data']) == gpx_file.count("</trkpt>")
|
||||
assert data['data']['chart_data'][0] == {
|
||||
'distance': 0.0,
|
||||
'duration': 0,
|
||||
'elevation': 998.0,
|
||||
'latitude': 44.68095,
|
||||
'longitude': 6.07367,
|
||||
'speed': 3.21,
|
||||
'time': 'Tue, 13 Mar 2018 12:44:45 GMT',
|
||||
}
|
||||
|
||||
def test_it_gets_chart_data_for_a_workout_created_with_gpx_without_elevation( # noqa
|
||||
self,
|
||||
app: Flask,
|
||||
user_1: User,
|
||||
sport_1_cycling: Sport,
|
||||
gpx_file_without_elevation: 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_elevation)),
|
||||
'example.gpx',
|
||||
),
|
||||
data='{"sport_id": 1}',
|
||||
),
|
||||
headers=dict(
|
||||
content_type='multipart/form-data',
|
||||
Authorization=f'Bearer {auth_token}',
|
||||
),
|
||||
)
|
||||
data = json.loads(response.data.decode())
|
||||
workout_short_id = data['data']['workouts'][0]['id']
|
||||
response = client.get(
|
||||
f'/api/workouts/{workout_short_id}/chart_data',
|
||||
headers=dict(Authorization=f'Bearer {auth_token}'),
|
||||
)
|
||||
|
||||
data = json.loads(response.data.decode())
|
||||
assert response.status_code == 200
|
||||
assert 'success' in data['status']
|
||||
assert data['message'] == ''
|
||||
assert len(
|
||||
data['data']['chart_data']
|
||||
) == gpx_file_without_elevation.count("</trkpt>")
|
||||
# no 'elevation' key in data
|
||||
assert data['data']['chart_data'][0] == {
|
||||
'distance': 0.0,
|
||||
'duration': 0,
|
||||
'latitude': 44.68095,
|
||||
'longitude': 6.07367,
|
||||
'speed': 3.21,
|
||||
'time': 'Tue, 13 Mar 2018 12:44:45 GMT',
|
||||
}
|
||||
|
||||
def test_it_gets_segment_chart_data_for_a_workout_created_with_gpx(
|
||||
self, app: Flask, user_1: User, sport_1_cycling: Sport, gpx_file: str
|
||||
@ -1753,6 +1811,16 @@ class TestPostAndGetWorkoutWithGpx(ApiTestCaseMixin):
|
||||
assert 'success' in data['status']
|
||||
assert data['message'] == ''
|
||||
assert data['data']['chart_data'] != ''
|
||||
assert len(data['data']['chart_data']) == gpx_file.count("</trkpt>")
|
||||
assert data['data']['chart_data'][0] == {
|
||||
'distance': 0.0,
|
||||
'duration': 0,
|
||||
'elevation': 998.0,
|
||||
'latitude': 44.68095,
|
||||
'longitude': 6.07367,
|
||||
'speed': 3.21,
|
||||
'time': 'Tue, 13 Mar 2018 12:44:45 GMT',
|
||||
}
|
||||
|
||||
def test_it_returns_403_on_getting_chart_data_if_workout_belongs_to_another_user( # noqa
|
||||
self,
|
||||
|
Reference in New Issue
Block a user