From 4d36a047d95549932c9b63c7e17277107e791fc8 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 8 May 2018 15:08:27 +0200 Subject: [PATCH] API: tests update --- mpwo_api/mpwo_api/tests/test_activities.py | 44 ++++----- mpwo_api/mpwo_api/tests/utils_gpx.py | 110 +++++++++++++++++++++ 2 files changed, 131 insertions(+), 23 deletions(-) create mode 100644 mpwo_api/mpwo_api/tests/utils_gpx.py diff --git a/mpwo_api/mpwo_api/tests/test_activities.py b/mpwo_api/mpwo_api/tests/test_activities.py index f128885a..d464a00d 100644 --- a/mpwo_api/mpwo_api/tests/test_activities.py +++ b/mpwo_api/mpwo_api/tests/test_activities.py @@ -3,27 +3,7 @@ import json from io import BytesIO from mpwo_api.tests.utils import add_activity, add_sport, add_user - -gpx_file = ( - '' - '' # noqa - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - ' 223.28399658203125' - ' ' - ' ' - ' ' - ' ' - ' ' - ' ' - '' -) +from mpwo_api.tests.utils_gpx import gpx_file def test_get_all_activities_for_authenticated_user(app): @@ -289,6 +269,15 @@ def test_get_an_activity_without_gpx(app): assert 1 == data['data']['activities'][0]['user_id'] assert 1 == data['data']['activities'][0]['sport_id'] assert '0:17:04' == data['data']['activities'][0]['duration'] + assert data['data']['activities'][0]['ascent'] is None + assert data['data']['activities'][0]['ave_speed'] is None + assert data['data']['activities'][0]['descent'] is None + assert data['data']['activities'][0]['distance'] is None + assert data['data']['activities'][0]['max_alt'] is None + assert data['data']['activities'][0]['max_speed'] is None + assert data['data']['activities'][0]['min_alt'] is None + assert data['data']['activities'][0]['moving'] is None + assert data['data']['activities'][0]['pauses'] is None def test_get_an_activity_with_gpx(app): @@ -332,7 +321,16 @@ def test_get_an_activity_with_gpx(app): assert 'success' in data['status'] assert len(data['data']['activities']) == 1 assert 'creation_date' in data['data']['activities'][0] - assert 'Sun, 20 Sep 2015 13:48:44 GMT' == data['data']['activities'][0]['activity_date'] # noqa + assert 'Tue, 13 Mar 2018 12:44:45 GMT' == data['data']['activities'][0]['activity_date'] # noqa assert 1 == data['data']['activities'][0]['user_id'] assert 1 == data['data']['activities'][0]['sport_id'] - assert '0:00:02' == data['data']['activities'][0]['duration'] + assert '0:04:10' == data['data']['activities'][0]['duration'] + assert data['data']['activities'][0]['ascent'] == 0.4 + assert data['data']['activities'][0]['ave_speed'] == 4.6 + assert data['data']['activities'][0]['descent'] == 23.4 + assert data['data']['activities'][0]['distance'] == 0.32 + assert data['data']['activities'][0]['max_alt'] == 998.0 + assert data['data']['activities'][0]['max_speed'] == 5.09 + assert data['data']['activities'][0]['min_alt'] == 975.0 + assert data['data']['activities'][0]['moving'] == '0:04:10' + assert data['data']['activities'][0]['pauses'] is None diff --git a/mpwo_api/mpwo_api/tests/utils_gpx.py b/mpwo_api/mpwo_api/tests/utils_gpx.py new file mode 100644 index 00000000..229db78a --- /dev/null +++ b/mpwo_api/mpwo_api/tests/utils_gpx.py @@ -0,0 +1,110 @@ +gpx_file = ( + '' + '' # noqa + ' ' + ' ' + ' ' + ' ' + ' 998' + ' ' + ' ' + ' ' + ' 998' + ' ' + ' ' + ' ' + ' 994' + ' ' + ' ' + ' ' + ' 994' + ' ' + ' ' + ' ' + ' 994' + ' ' + ' ' + ' ' + ' 993' + ' ' + ' ' + ' ' + ' 992' + ' ' + ' ' + ' ' + ' 992' + ' ' + ' ' + ' ' + ' 987' + ' ' + ' ' + ' ' + ' 987' + ' ' + ' ' + ' ' + ' 987' + ' ' + ' ' + ' ' + ' 987' + ' ' + ' ' + ' ' + ' 986' + ' ' + ' ' + ' ' + ' 986' + ' ' + ' ' + ' ' + ' 986' + ' ' + ' ' + ' ' + ' 985' + ' ' + ' ' + ' ' + ' 980' + ' ' + ' ' + ' ' + ' 980' + ' ' + ' ' + ' ' + ' 980' + ' ' + ' ' + ' ' + ' 979' + ' ' + ' ' + ' ' + ' 981' + ' ' + ' ' + ' ' + ' 980' + ' ' + ' ' + ' ' + ' 979' + ' ' + ' ' + ' ' + ' 979' + ' ' + ' ' + ' ' + ' 975' + ' ' + ' ' + ' ' + ' ' + '' +)