Add test for parsing max_speed with raw_speed user preference setting
This commit is contained in:
parent
a98057c936
commit
7e00e79386
17
fittrackee/tests/fixtures/fixtures_users.py
vendored
17
fittrackee/tests/fixtures/fixtures_users.py
vendored
@ -59,6 +59,23 @@ def user_1_full() -> User:
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def user_1_raw_speed() -> User:
|
||||||
|
user = User(username='test', email='test@test.com', password='12345678')
|
||||||
|
user.first_name = 'John'
|
||||||
|
user.last_name = 'Doe'
|
||||||
|
user.bio = 'just a random guy'
|
||||||
|
user.location = 'somewhere'
|
||||||
|
user.language = 'en'
|
||||||
|
user.timezone = 'America/New_York'
|
||||||
|
user.birth_date = datetime.datetime.strptime('01/01/1980', '%d/%m/%Y')
|
||||||
|
user.is_active = True
|
||||||
|
user.use_raw_gpx_speed = True
|
||||||
|
user.accepted_policy = datetime.datetime.utcnow()
|
||||||
|
db.session.add(user)
|
||||||
|
db.session.commit()
|
||||||
|
return user
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def user_1_paris() -> User:
|
def user_1_paris() -> User:
|
||||||
user = User(username='test', email='test@test.com', password='12345678')
|
user = User(username='test', email='test@test.com', password='12345678')
|
||||||
|
@ -54,7 +54,8 @@ class TestStoppedSpeedThreshold:
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert gpx_track_segment_mock.call_args_list[0] == call(
|
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(
|
gpx_track_segment_mock.assert_called_with(
|
||||||
expected_threshold, # stopped_speed_threshold
|
expected_threshold, # stopped_speed_threshold
|
||||||
@ -88,7 +89,8 @@ class TestStoppedSpeedThreshold:
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert gpx_track_segment_mock.call_args_list[0] == call(
|
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(
|
gpx_track_segment_mock.assert_called_with(
|
||||||
expected_threshold, # stopped_speed_threshold
|
expected_threshold, # stopped_speed_threshold
|
||||||
|
@ -278,6 +278,33 @@ class TestPostWorkoutWithGpx(ApiTestCaseMixin, CallArgsMixin):
|
|||||||
assert 'just a workout' == data['data']['workouts'][0]['title']
|
assert 'just a workout' == data['data']['workouts'][0]['title']
|
||||||
assert_workout_data_with_gpx(data)
|
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(
|
def test_it_returns_ha_record_when_a_workout_without_gpx_exists(
|
||||||
self,
|
self,
|
||||||
app: Flask,
|
app: Flask,
|
||||||
|
Loading…
Reference in New Issue
Block a user