diff options
Diffstat (limited to 'tests/integration/test_browse.py')
-rw-r--r-- | tests/integration/test_browse.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/integration/test_browse.py b/tests/integration/test_browse.py index 493239f..603f301 100644 --- a/tests/integration/test_browse.py +++ b/tests/integration/test_browse.py @@ -2,14 +2,16 @@ import io import zipfile from contextlib import contextmanager from datetime import datetime +from pathlib import Path from testutils import load_gpx_asset from fietsboek import models from fietsboek.models.track import Visibility +from fietsboek.data import DataManager @contextmanager -def added_tracks(tm, dbsession, owner): +def added_tracks(tm, dbsession, owner, data_manager): """Adds some tracks to the database session. This function should be used as a context manager and it ensures that the @@ -33,8 +35,9 @@ def added_tracks(tm, dbsession, owner): tagged_people=[], ) track.date = datetime(2022, 3, 14, 9, 26, 54) - track.gpx_data = load_gpx_asset("MyTourbook_1.gpx.gz") dbsession.add(track) + dbsession.flush() + data_manager.initialize(track.id).compress_gpx(load_gpx_asset("MyTourbook_1.gpx.gz")) tracks.append(track) track = models.Track( @@ -47,8 +50,9 @@ def added_tracks(tm, dbsession, owner): tagged_people=[], ) track.date = datetime(2022, 10, 29, 13, 37, 11) - track.gpx_data = load_gpx_asset("Teasi_1.gpx.gz") dbsession.add(track) + dbsession.flush() + data_manager.initialize(track.id).compress_gpx(load_gpx_asset("Teasi_1.gpx.gz")) tracks.append(track) tm.begin() @@ -65,9 +69,9 @@ def added_tracks(tm, dbsession, owner): tm.doom() -def test_browse(testapp, dbsession, route_path, logged_in, tm): +def test_browse(testapp, dbsession, route_path, logged_in, tm, data_manager): # Ensure there are some tracks in the database - with added_tracks(tm, dbsession, logged_in): + with added_tracks(tm, dbsession, logged_in, data_manager): # Now go to the browse page browse = testapp.get(route_path('browse')) @@ -75,8 +79,8 @@ def test_browse(testapp, dbsession, route_path, logged_in, tm): assert "Barfoo" in browse.text -def test_archive(testapp, dbsession, route_path, logged_in, tm): - with added_tracks(tm, dbsession, logged_in): +def test_archive(testapp, dbsession, route_path, logged_in, tm, data_manager): + with added_tracks(tm, dbsession, logged_in, data_manager): archive = testapp.get( route_path('track-archive', _query=[("track_id[]", "1"), ("track_id[]", "2")]) ) |