2018-05-13 18:36:31 +02:00
|
|
|
import datetime
|
2018-05-01 11:52:38 +02:00
|
|
|
import os
|
|
|
|
|
2018-04-09 22:09:58 +02:00
|
|
|
import pytest
|
2020-09-16 15:41:02 +02:00
|
|
|
from fittrackee import create_app, db
|
|
|
|
from fittrackee.activities.models import Activity, ActivitySegment, Sport
|
|
|
|
from fittrackee.application.models import AppConfig
|
|
|
|
from fittrackee.application.utils import update_app_config_from_database
|
|
|
|
from fittrackee.users.models import User
|
2018-04-09 22:09:58 +02:00
|
|
|
|
2020-07-14 22:03:56 +02:00
|
|
|
os.environ['FLASK_ENV'] = 'testing'
|
2020-09-16 15:41:02 +02:00
|
|
|
os.environ['APP_SETTINGS'] = 'fittrackee.config.TestingConfig'
|
2020-05-02 10:39:43 +02:00
|
|
|
# to avoid resetting dev database during tests
|
2020-07-14 22:03:56 +02:00
|
|
|
os.environ['DATABASE_URL'] = os.getenv('DATABASE_TEST_URL')
|
2018-05-01 11:52:38 +02:00
|
|
|
|
2018-04-09 22:09:58 +02:00
|
|
|
|
2019-11-13 21:46:24 +01:00
|
|
|
def get_app_config(with_config=False):
|
|
|
|
if with_config:
|
|
|
|
config = AppConfig()
|
|
|
|
config.gpx_limit_import = 10
|
|
|
|
config.max_single_file_size = 1 * 1024 * 1024
|
|
|
|
config.max_zip_file_size = 1 * 1024 * 1024 * 10
|
|
|
|
config.max_users = 100
|
|
|
|
db.session.add(config)
|
|
|
|
db.session.commit()
|
|
|
|
return config
|
2019-11-13 19:14:13 +01:00
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
2019-11-13 21:46:24 +01:00
|
|
|
def get_app(with_config=False):
|
2018-04-09 22:09:58 +02:00
|
|
|
app = create_app()
|
2019-11-13 18:40:01 +01:00
|
|
|
with app.app_context():
|
|
|
|
db.create_all()
|
2019-11-13 21:46:24 +01:00
|
|
|
app_db_config = get_app_config(with_config)
|
2019-11-13 19:14:13 +01:00
|
|
|
if app_db_config:
|
|
|
|
update_app_config_from_database(app, app_db_config)
|
2019-11-13 18:40:01 +01:00
|
|
|
yield app
|
|
|
|
db.session.remove()
|
|
|
|
db.drop_all()
|
|
|
|
# close unused idle connections => avoid the following error:
|
|
|
|
# FATAL: remaining connection slots are reserved for non-replication
|
|
|
|
# superuser connections
|
|
|
|
db.engine.dispose()
|
|
|
|
return app
|
|
|
|
|
|
|
|
|
2019-11-13 19:14:13 +01:00
|
|
|
@pytest.fixture
|
2020-05-17 16:42:44 +02:00
|
|
|
def app(monkeypatch):
|
|
|
|
monkeypatch.setenv('EMAIL_URL', 'smtp://none:none@0.0.0.0:1025')
|
2020-09-16 13:15:41 +02:00
|
|
|
if os.getenv('TILE_SERVER_URL'):
|
|
|
|
monkeypatch.delenv('TILE_SERVER_URL')
|
|
|
|
if os.getenv('MAP_ATTRIBUTION'):
|
|
|
|
monkeypatch.delenv('MAP_ATTRIBUTION')
|
2019-11-13 21:46:24 +01:00
|
|
|
yield from get_app(with_config=True)
|
2019-11-13 19:14:13 +01:00
|
|
|
|
|
|
|
|
2019-11-13 18:40:01 +01:00
|
|
|
@pytest.fixture
|
|
|
|
def app_no_config():
|
2019-11-13 21:46:24 +01:00
|
|
|
yield from get_app(with_config=False)
|
2018-05-13 18:36:31 +02:00
|
|
|
|
|
|
|
|
2020-05-17 16:42:44 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def app_ssl(monkeypatch):
|
|
|
|
monkeypatch.setenv('EMAIL_URL', 'smtp://none:none@0.0.0.0:1025?ssl=True')
|
|
|
|
yield from get_app(with_config=True)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def app_tls(monkeypatch):
|
|
|
|
monkeypatch.setenv('EMAIL_URL', 'smtp://none:none@0.0.0.0:1025?tls=True')
|
|
|
|
yield from get_app(with_config=True)
|
|
|
|
|
|
|
|
|
2019-11-13 18:40:01 +01:00
|
|
|
@pytest.fixture()
|
|
|
|
def app_config():
|
|
|
|
config = AppConfig()
|
|
|
|
config.gpx_limit_import = 10
|
|
|
|
config.max_single_file_size = 1048576
|
|
|
|
config.max_zip_file_size = 10485760
|
|
|
|
config.max_users = 0
|
|
|
|
db.session.add(config)
|
|
|
|
db.session.commit()
|
|
|
|
return config
|
|
|
|
|
|
|
|
|
2018-05-13 18:36:31 +02:00
|
|
|
@pytest.fixture()
|
|
|
|
def user_1():
|
|
|
|
user = User(username='test', email='test@test.com', password='12345678')
|
|
|
|
db.session.add(user)
|
|
|
|
db.session.commit()
|
|
|
|
return user
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def user_1_admin():
|
|
|
|
admin = User(
|
2019-08-28 13:25:39 +02:00
|
|
|
username='admin', email='admin@example.com', password='12345678'
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
|
|
|
admin.admin = True
|
|
|
|
db.session.add(admin)
|
|
|
|
db.session.commit()
|
|
|
|
return admin
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def user_1_full():
|
|
|
|
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'
|
2019-09-16 14:19:21 +02:00
|
|
|
user.language = 'en'
|
2018-06-11 15:10:18 +02:00
|
|
|
user.timezone = 'America/New_York'
|
2018-05-13 18:36:31 +02:00
|
|
|
user.birth_date = datetime.datetime.strptime('01/01/1980', '%d/%m/%Y')
|
|
|
|
db.session.add(user)
|
|
|
|
db.session.commit()
|
|
|
|
return user
|
2018-06-11 18:11:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def user_1_paris():
|
|
|
|
user = User(username='test', email='test@test.com', password='12345678')
|
|
|
|
user.timezone = 'Europe/Paris'
|
|
|
|
db.session.add(user)
|
|
|
|
db.session.commit()
|
|
|
|
return user
|
2018-05-13 18:36:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def user_2():
|
|
|
|
user = User(username='toto', email='toto@toto.com', password='87654321')
|
|
|
|
db.session.add(user)
|
|
|
|
db.session.commit()
|
|
|
|
return user
|
|
|
|
|
|
|
|
|
2020-05-01 16:18:59 +02:00
|
|
|
@pytest.fixture()
|
|
|
|
def user_2_admin():
|
|
|
|
user = User(username='toto', email='toto@toto.com', password='87654321')
|
|
|
|
user.admin = True
|
|
|
|
db.session.add(user)
|
|
|
|
db.session.commit()
|
|
|
|
return user
|
|
|
|
|
|
|
|
|
2019-08-31 16:33:46 +02:00
|
|
|
@pytest.fixture()
|
|
|
|
def user_3():
|
|
|
|
user = User(username='sam', email='sam@test.com', password='12345678')
|
|
|
|
user.weekm = True
|
|
|
|
db.session.add(user)
|
|
|
|
db.session.commit()
|
|
|
|
return user
|
|
|
|
|
|
|
|
|
2018-05-13 18:36:31 +02:00
|
|
|
@pytest.fixture()
|
|
|
|
def sport_1_cycling():
|
|
|
|
sport = Sport(label='Cycling')
|
|
|
|
db.session.add(sport)
|
|
|
|
db.session.commit()
|
|
|
|
return sport
|
|
|
|
|
|
|
|
|
2019-09-23 14:09:26 +02:00
|
|
|
@pytest.fixture()
|
|
|
|
def sport_1_cycling_inactive():
|
|
|
|
sport = Sport(label='Cycling')
|
|
|
|
sport.is_active = False
|
|
|
|
db.session.add(sport)
|
|
|
|
db.session.commit()
|
|
|
|
return sport
|
|
|
|
|
|
|
|
|
2018-05-13 18:36:31 +02:00
|
|
|
@pytest.fixture()
|
|
|
|
def sport_2_running():
|
|
|
|
sport = Sport(label='Running')
|
|
|
|
db.session.add(sport)
|
|
|
|
db.session.commit()
|
|
|
|
return sport
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def activity_cycling_user_1():
|
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=1,
|
|
|
|
activity_date=datetime.datetime.strptime('01/01/2018', '%d/%m/%Y'),
|
|
|
|
distance=10,
|
2020-05-10 15:55:56 +02:00
|
|
|
duration=datetime.timedelta(seconds=3600),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2018-05-15 16:00:13 +02:00
|
|
|
activity.max_speed = 10
|
|
|
|
activity.ave_speed = 10
|
2018-05-29 20:43:44 +02:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
|
|
|
db.session.commit()
|
|
|
|
return activity
|
|
|
|
|
|
|
|
|
2018-05-14 13:25:00 +02:00
|
|
|
@pytest.fixture()
|
|
|
|
def activity_cycling_user_1_segment():
|
2019-08-28 13:25:39 +02:00
|
|
|
activity_segment = ActivitySegment(activity_id=1, segment_id=0)
|
2018-05-14 13:25:00 +02:00
|
|
|
activity_segment.duration = datetime.timedelta(seconds=6000)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity_segment.moving = activity_segment.duration
|
2018-05-14 13:25:00 +02:00
|
|
|
activity_segment.distance = 5
|
|
|
|
db.session.add(activity_segment)
|
|
|
|
db.session.commit()
|
|
|
|
return activity_segment
|
|
|
|
|
|
|
|
|
2018-05-13 18:36:31 +02:00
|
|
|
@pytest.fixture()
|
|
|
|
def activity_running_user_1():
|
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=2,
|
|
|
|
activity_date=datetime.datetime.strptime('01/04/2018', '%d/%m/%Y'),
|
|
|
|
distance=12,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=6000),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
|
|
|
db.session.commit()
|
|
|
|
return activity
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def seven_activities_user_1():
|
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=1,
|
2018-06-06 12:09:09 +02:00
|
|
|
activity_date=datetime.datetime.strptime('20/03/2017', '%d/%m/%Y'),
|
|
|
|
distance=5,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=1024),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2018-06-07 19:28:06 +02:00
|
|
|
activity.ave_speed = float(activity.distance) / (1024 / 3600)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
2018-05-15 16:00:13 +02:00
|
|
|
db.session.flush()
|
2018-05-13 18:36:31 +02:00
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=1,
|
2018-06-06 12:09:09 +02:00
|
|
|
activity_date=datetime.datetime.strptime('01/06/2017', '%d/%m/%Y'),
|
|
|
|
distance=10,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=3456),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2018-06-07 19:28:06 +02:00
|
|
|
activity.ave_speed = float(activity.distance) / (3456 / 3600)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
2018-05-15 16:00:13 +02:00
|
|
|
db.session.flush()
|
2018-05-13 18:36:31 +02:00
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=1,
|
2018-06-06 12:09:09 +02:00
|
|
|
activity_date=datetime.datetime.strptime('01/01/2018', '%d/%m/%Y'),
|
|
|
|
distance=10,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=1024),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2018-06-07 19:28:06 +02:00
|
|
|
activity.ave_speed = float(activity.distance) / (1024 / 3600)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
2018-05-15 16:00:13 +02:00
|
|
|
db.session.flush()
|
2018-05-13 18:36:31 +02:00
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=1,
|
2018-06-06 12:09:09 +02:00
|
|
|
activity_date=datetime.datetime.strptime('23/02/2018', '%d/%m/%Y'),
|
|
|
|
distance=1,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=600),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2018-06-07 19:28:06 +02:00
|
|
|
activity.ave_speed = float(activity.distance) / (600 / 3600)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
2018-05-15 16:00:13 +02:00
|
|
|
db.session.flush()
|
2018-05-13 18:36:31 +02:00
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=1,
|
2018-06-06 12:09:09 +02:00
|
|
|
activity_date=datetime.datetime.strptime('23/02/2018', '%d/%m/%Y'),
|
2018-05-13 18:36:31 +02:00
|
|
|
distance=10,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=1000),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2018-06-07 19:28:06 +02:00
|
|
|
activity.ave_speed = float(activity.distance) / (1000 / 3600)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
2018-05-15 16:00:13 +02:00
|
|
|
db.session.flush()
|
2018-05-13 18:36:31 +02:00
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=1,
|
2018-06-06 12:09:09 +02:00
|
|
|
activity_date=datetime.datetime.strptime('01/04/2018', '%d/%m/%Y'),
|
|
|
|
distance=8,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=6000),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2018-06-07 19:28:06 +02:00
|
|
|
activity.ave_speed = float(activity.distance) / (6000 / 3600)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
2018-05-15 16:00:13 +02:00
|
|
|
db.session.flush()
|
2018-05-13 18:36:31 +02:00
|
|
|
activity = Activity(
|
|
|
|
user_id=1,
|
|
|
|
sport_id=1,
|
2018-06-06 12:09:09 +02:00
|
|
|
activity_date=datetime.datetime.strptime('09/05/2018', '%d/%m/%Y'),
|
2018-05-13 18:36:31 +02:00
|
|
|
distance=10,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=3000),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2018-06-07 19:28:06 +02:00
|
|
|
activity.ave_speed = float(activity.distance) / (3000 / 3600)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
|
|
|
db.session.commit()
|
|
|
|
return activity
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def activity_cycling_user_2():
|
|
|
|
activity = Activity(
|
|
|
|
user_id=2,
|
|
|
|
sport_id=1,
|
|
|
|
activity_date=datetime.datetime.strptime('23/01/2018', '%d/%m/%Y'),
|
|
|
|
distance=15,
|
2019-08-28 13:25:39 +02:00
|
|
|
duration=datetime.timedelta(seconds=3600),
|
2018-05-13 18:36:31 +02:00
|
|
|
)
|
2019-01-13 11:21:14 +01:00
|
|
|
activity.moving = activity.duration
|
2018-05-13 18:36:31 +02:00
|
|
|
db.session.add(activity)
|
|
|
|
db.session.commit()
|
|
|
|
return activity
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def gpx_file():
|
2019-07-07 14:18:29 +02:00
|
|
|
return (
|
2018-05-13 18:36:31 +02:00
|
|
|
'<?xml version=\'1.0\' encoding=\'UTF-8\'?>'
|
|
|
|
'<gpx xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxext="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns="http://www.topografix.com/GPX/1/1">' # noqa
|
|
|
|
' <metadata/>'
|
|
|
|
' <trk>'
|
|
|
|
' <name>just an activity</name>'
|
|
|
|
' <trkseg>'
|
|
|
|
' <trkpt lat="44.68095" lon="6.07367">'
|
|
|
|
' <ele>998</ele>'
|
|
|
|
' <time>2018-03-13T12:44:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68091" lon="6.07367">'
|
|
|
|
' <ele>998</ele>'
|
|
|
|
' <time>2018-03-13T12:44:50Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.6808" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:00Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68075" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:05Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68071" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:10Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68049" lon="6.07361">'
|
|
|
|
' <ele>993</ele>'
|
|
|
|
' <time>2018-03-13T12:45:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68019" lon="6.07356">'
|
|
|
|
' <ele>992</ele>'
|
|
|
|
' <time>2018-03-13T12:45:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68014" lon="6.07355">'
|
|
|
|
' <ele>992</ele>'
|
|
|
|
' <time>2018-03-13T12:46:00Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67995" lon="6.07358">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:15Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67977" lon="6.07364">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67972" lon="6.07367">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:35Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67966" lon="6.07368">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67961" lon="6.0737">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:46:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67938" lon="6.07377">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:47:05Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67933" lon="6.07381">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:47:10Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67922" lon="6.07385">'
|
|
|
|
' <ele>985</ele>'
|
|
|
|
' <time>2018-03-13T12:47:20Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67911" lon="6.0739">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.679" lon="6.07399">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67896" lon="6.07402">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67884" lon="6.07408">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:47:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67863" lon="6.07423">'
|
|
|
|
' <ele>981</ele>'
|
|
|
|
' <time>2018-03-13T12:48:15Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67858" lon="6.07425">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:48:20Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67842" lon="6.07434">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:48:35Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67837" lon="6.07435">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:48:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67822" lon="6.07442">'
|
|
|
|
' <ele>975</ele>'
|
|
|
|
' <time>2018-03-13T12:48:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' </trkseg>'
|
|
|
|
' </trk>'
|
|
|
|
'</gpx>'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def gpx_file_wo_name():
|
|
|
|
return (
|
|
|
|
'<?xml version=\'1.0\' encoding=\'UTF-8\'?>'
|
|
|
|
'<gpx xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxext="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns="http://www.topografix.com/GPX/1/1">' # noqa
|
|
|
|
' <metadata/>'
|
|
|
|
' <trk>'
|
|
|
|
' <trkseg>'
|
|
|
|
' <trkpt lat="44.68095" lon="6.07367">'
|
|
|
|
' <ele>998</ele>'
|
|
|
|
' <time>2018-03-13T12:44:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68091" lon="6.07367">'
|
|
|
|
' <ele>998</ele>'
|
|
|
|
' <time>2018-03-13T12:44:50Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.6808" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:00Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68075" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:05Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68071" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:10Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68049" lon="6.07361">'
|
|
|
|
' <ele>993</ele>'
|
|
|
|
' <time>2018-03-13T12:45:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68019" lon="6.07356">'
|
|
|
|
' <ele>992</ele>'
|
|
|
|
' <time>2018-03-13T12:45:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68014" lon="6.07355">'
|
|
|
|
' <ele>992</ele>'
|
|
|
|
' <time>2018-03-13T12:46:00Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67995" lon="6.07358">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:15Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67977" lon="6.07364">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67972" lon="6.07367">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:35Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67966" lon="6.07368">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67961" lon="6.0737">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:46:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67938" lon="6.07377">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:47:05Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67933" lon="6.07381">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:47:10Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67922" lon="6.07385">'
|
|
|
|
' <ele>985</ele>'
|
|
|
|
' <time>2018-03-13T12:47:20Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67911" lon="6.0739">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.679" lon="6.07399">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67896" lon="6.07402">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67884" lon="6.07408">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:47:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67863" lon="6.07423">'
|
|
|
|
' <ele>981</ele>'
|
|
|
|
' <time>2018-03-13T12:48:15Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67858" lon="6.07425">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:48:20Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67842" lon="6.07434">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:48:35Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67837" lon="6.07435">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:48:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67822" lon="6.07442">'
|
|
|
|
' <ele>975</ele>'
|
|
|
|
' <time>2018-03-13T12:48:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' </trkseg>'
|
|
|
|
' </trk>'
|
|
|
|
'</gpx>'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def gpx_file_wo_track():
|
|
|
|
return (
|
|
|
|
'<?xml version=\'1.0\' encoding=\'UTF-8\'?>'
|
|
|
|
'<gpx xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxext="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns="http://www.topografix.com/GPX/1/1">' # noqa
|
|
|
|
' <metadata/>'
|
|
|
|
'</gpx>'
|
|
|
|
)
|
2018-05-28 11:44:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def gpx_file_invalid_xml():
|
|
|
|
return (
|
|
|
|
'<?xml version=\'1.0\' encoding=\'UTF-8\'?>'
|
|
|
|
'<gpx xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxext="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns="http://www.topografix.com/GPX/1/1">' # noqa
|
|
|
|
' <metadata/>'
|
|
|
|
)
|
2019-01-05 21:44:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def gpx_file_with_segments():
|
2019-07-07 14:18:29 +02:00
|
|
|
return (
|
2019-01-05 21:44:52 +01:00
|
|
|
'<?xml version=\'1.0\' encoding=\'UTF-8\'?>'
|
|
|
|
'<gpx xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxext="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns="http://www.topografix.com/GPX/1/1">' # noqa
|
|
|
|
' <metadata/>'
|
|
|
|
' <trk>'
|
|
|
|
' <name>just an activity</name>'
|
|
|
|
' <trkseg>'
|
|
|
|
' <trkpt lat="44.68095" lon="6.07367">'
|
|
|
|
' <ele>998</ele>'
|
|
|
|
' <time>2018-03-13T12:44:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68091" lon="6.07367">'
|
|
|
|
' <ele>998</ele>'
|
|
|
|
' <time>2018-03-13T12:44:50Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.6808" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:00Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68075" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:05Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68071" lon="6.07364">'
|
|
|
|
' <ele>994</ele>'
|
|
|
|
' <time>2018-03-13T12:45:10Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68049" lon="6.07361">'
|
|
|
|
' <ele>993</ele>'
|
|
|
|
' <time>2018-03-13T12:45:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68019" lon="6.07356">'
|
|
|
|
' <ele>992</ele>'
|
|
|
|
' <time>2018-03-13T12:45:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.68014" lon="6.07355">'
|
|
|
|
' <ele>992</ele>'
|
|
|
|
' <time>2018-03-13T12:46:00Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67995" lon="6.07358">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:15Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' </trkseg>'
|
|
|
|
' <trkseg>'
|
|
|
|
' <trkpt lat="44.67977" lon="6.07364">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67972" lon="6.07367">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:35Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67966" lon="6.07368">'
|
|
|
|
' <ele>987</ele>'
|
|
|
|
' <time>2018-03-13T12:46:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67961" lon="6.0737">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:46:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67938" lon="6.07377">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:47:05Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67933" lon="6.07381">'
|
|
|
|
' <ele>986</ele>'
|
|
|
|
' <time>2018-03-13T12:47:10Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67922" lon="6.07385">'
|
|
|
|
' <ele>985</ele>'
|
|
|
|
' <time>2018-03-13T12:47:20Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67911" lon="6.0739">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:30Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.679" lon="6.07399">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67896" lon="6.07402">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:47:45Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67884" lon="6.07408">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:47:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67863" lon="6.07423">'
|
|
|
|
' <ele>981</ele>'
|
|
|
|
' <time>2018-03-13T12:48:15Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67858" lon="6.07425">'
|
|
|
|
' <ele>980</ele>'
|
|
|
|
' <time>2018-03-13T12:48:20Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67842" lon="6.07434">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:48:35Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67837" lon="6.07435">'
|
|
|
|
' <ele>979</ele>'
|
|
|
|
' <time>2018-03-13T12:48:40Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' <trkpt lat="44.67822" lon="6.07442">'
|
|
|
|
' <ele>975</ele>'
|
|
|
|
' <time>2018-03-13T12:48:55Z</time>'
|
|
|
|
' </trkpt>'
|
|
|
|
' </trkseg>'
|
|
|
|
' </trk>'
|
|
|
|
'</gpx>'
|
|
|
|
)
|