API - fix total ascent when user has workous without gpx
This commit is contained in:
@ -38,6 +38,7 @@ class UserModelAssertMixin:
|
||||
assert 'nb_workouts' in serialized_user
|
||||
assert 'records' in serialized_user
|
||||
assert 'sports_list' in serialized_user
|
||||
assert 'total_ascent' in serialized_user
|
||||
assert 'total_distance' in serialized_user
|
||||
assert 'total_duration' in serialized_user
|
||||
|
||||
@ -168,6 +169,46 @@ class TestUserRecords(UserModelAssertMixin):
|
||||
)
|
||||
assert serialized_user['records'][0]['workout_date']
|
||||
|
||||
def test_it_returns_totals_when_user_has_workout_without_ascent(
|
||||
self,
|
||||
app: Flask,
|
||||
user_1: User,
|
||||
sport_1_cycling: Sport,
|
||||
workout_cycling_user_1: Workout,
|
||||
) -> None:
|
||||
serialized_user = user_1.serialize(user_1)
|
||||
assert serialized_user['total_ascent'] == 0
|
||||
assert serialized_user['total_distance'] == 10
|
||||
assert serialized_user['total_duration'] == '1:00:00'
|
||||
|
||||
def test_it_returns_totals_when_user_has_workout_with_ascent(
|
||||
self,
|
||||
app: Flask,
|
||||
user_1: User,
|
||||
sport_1_cycling: Sport,
|
||||
workout_cycling_user_1: Workout,
|
||||
) -> None:
|
||||
workout_cycling_user_1.ascent = 100
|
||||
serialized_user = user_1.serialize(user_1)
|
||||
assert serialized_user['total_ascent'] == 100
|
||||
assert serialized_user['total_distance'] == 10
|
||||
assert serialized_user['total_duration'] == '1:00:00'
|
||||
|
||||
def test_it_returns_totals_when_user_has_mutiple_workouts(
|
||||
self,
|
||||
app: Flask,
|
||||
user_1: User,
|
||||
sport_1_cycling: Sport,
|
||||
sport_2_running: Sport,
|
||||
workout_cycling_user_1: Workout,
|
||||
workout_running_user_1: Workout,
|
||||
) -> None:
|
||||
workout_cycling_user_1.ascent = 100
|
||||
serialized_user = user_1.serialize(user_1)
|
||||
assert serialized_user['total_ascent'] == 100
|
||||
assert serialized_user['total_distance'] == 22
|
||||
assert serialized_user['total_duration'] == '2:40:00'
|
||||
|
||||
|
||||
class TestUserWorkouts(UserModelAssertMixin):
|
||||
def test_it_returns_infos_when_no_workouts(
|
||||
|
Reference in New Issue
Block a user