Add test for parsing max_speed with raw_speed user preference setting

This commit is contained in:
Joshua Taillon
2023-05-19 23:08:12 -06:00
parent a98057c936
commit 7e00e79386
3 changed files with 48 additions and 2 deletions

View File

@ -54,7 +54,8 @@ class TestStoppedSpeedThreshold:
)
assert gpx_track_segment_mock.call_args_list[0] == call(
stopped_speed_threshold=expected_threshold
stopped_speed_threshold=expected_threshold,
raw=False
)
gpx_track_segment_mock.assert_called_with(
expected_threshold, # stopped_speed_threshold
@ -88,7 +89,8 @@ class TestStoppedSpeedThreshold:
)
assert gpx_track_segment_mock.call_args_list[0] == call(
stopped_speed_threshold=expected_threshold
stopped_speed_threshold=expected_threshold,
raw=False
)
gpx_track_segment_mock.assert_called_with(
expected_threshold, # stopped_speed_threshold

View File

@ -278,6 +278,33 @@ class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin):
assert 'just a workout' == data['data']['workouts'][0]['title']
assert_workout_data_with_gpx(data)
def test_it_adds_a_workout_with_gpx_file_raw_speed(
self, app: Flask, user_1_raw_speed: User, sport_1_cycling: Sport, gpx_file: str
) -> None:
client, auth_token = self.get_test_client_and_auth_token(
app, user_1_raw_speed.email
)
response = client.post(
'/api/workouts',
data=dict(
file=(BytesIO(str.encode(gpx_file)), 'example.gpx'),
data='{"sport_id": 1}',
),
headers=dict(
content_type='multipart/form-data',
Authorization=f'Bearer {auth_token}',
),
)
data = json.loads(response.data.decode())
assert response.status_code == 201
assert 'created' in data['status']
assert len(data['data']['workouts']) == 1
# max speed should be slightly higher than that tested in
# assert_workout_data_with_gpx
assert data['data']['workouts'][0]['max_speed'] == pytest.approx(5.25)
def test_it_returns_ha_record_when_a_workout_without_gpx_exists(
self,
app: Flask,