FitTrackee/fittrackee/tests/activities/test_activities_model.py

67 lines
2.7 KiB
Python
Raw Normal View History

from .utils import is_valid_uuid
2020-05-10 15:55:56 +02:00
class TestActivityModel:
def test_activity_model(
self, app, sport_1_cycling, user_1, activity_cycling_user_1
):
activity_cycling_user_1.title = 'Test'
2018-05-12 19:13:59 +02:00
2020-05-10 15:55:56 +02:00
assert 1 == activity_cycling_user_1.id
assert activity_cycling_user_1.uuid is not None
2020-05-10 15:55:56 +02:00
assert 1 == activity_cycling_user_1.user_id
assert 1 == activity_cycling_user_1.sport_id
assert '2018-01-01 00:00:00' == str(
activity_cycling_user_1.activity_date
)
assert 10.0 == float(activity_cycling_user_1.distance)
assert '1:00:00' == str(activity_cycling_user_1.duration)
assert 'Test' == activity_cycling_user_1.title
assert '<Activity \'Cycling\' - 2018-01-01 00:00:00>' == str(
activity_cycling_user_1
)
2018-05-14 13:25:00 +02:00
2020-05-10 15:55:56 +02:00
serialized_activity = activity_cycling_user_1.serialize()
assert is_valid_uuid(serialized_activity['id'])
2020-05-10 15:55:56 +02:00
assert 'test' == serialized_activity['user']
assert 1 == serialized_activity['sport_id']
assert serialized_activity['title'] == 'Test'
assert 'creation_date' in serialized_activity
assert serialized_activity['modification_date'] is not None
assert (
str(serialized_activity['activity_date']) == '2018-01-01 00:00:00'
)
assert serialized_activity['duration'] == '1:00:00'
assert serialized_activity['pauses'] is None
assert serialized_activity['moving'] == '1:00:00'
assert serialized_activity['distance'] == 10.0
assert serialized_activity['max_alt'] is None
assert serialized_activity['descent'] is None
assert serialized_activity['ascent'] is None
assert serialized_activity['max_speed'] == 10.0
assert serialized_activity['ave_speed'] == 10.0
assert serialized_activity['with_gpx'] is False
assert serialized_activity['bounds'] == []
assert serialized_activity['previous_activity'] is None
assert serialized_activity['next_activity'] is None
assert serialized_activity['segments'] == []
assert serialized_activity['records'] != []
assert serialized_activity['map'] is None
assert serialized_activity['weather_start'] is None
assert serialized_activity['weather_end'] is None
assert serialized_activity['notes'] is None
2020-05-10 15:55:56 +02:00
def test_activity_segment_model(
self,
app,
sport_1_cycling,
user_1,
activity_cycling_user_1,
activity_cycling_user_1_segment,
):
assert (
f'<Segment \'{activity_cycling_user_1_segment.segment_id}\' '
f'for activity \'{activity_cycling_user_1.uuid.hex}\'>'
== str(activity_cycling_user_1_segment)
2020-05-10 15:55:56 +02:00
)