aboutsummaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2025-12-07 21:48:06 +0100
committerDaniel Schadt <kingdread@gmx.de>2025-12-07 21:48:06 +0100
commit5455a0c5216409ad5593c4b4bfd0fbfcd65b1e04 (patch)
tree05f0a2c0bde909ce9a3ad5203f849894bdd2f3b4 /tests/integration
parentaec4215e7020a4df1705e7b416a20597a30bee30 (diff)
parent019a3e9b7348a3a05e4e7d5e13d35e2362956d44 (diff)
downloadfietsboek-5455a0c5216409ad5593c4b4bfd0fbfcd65b1e04.tar.gz
fietsboek-5455a0c5216409ad5593c4b4bfd0fbfcd65b1e04.tar.bz2
fietsboek-5455a0c5216409ad5593c4b4bfd0fbfcd65b1e04.zip
Merge branch 'pdf'HEADmaster
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/test_browse.py2
-rw-r--r--tests/integration/test_pdf.py59
2 files changed, 60 insertions, 1 deletions
diff --git a/tests/integration/test_browse.py b/tests/integration/test_browse.py
index 68ead8f..1b96e2e 100644
--- a/tests/integration/test_browse.py
+++ b/tests/integration/test_browse.py
@@ -38,9 +38,9 @@ def added_tracks(tm, dbsession, owner, data_manager):
tagged_people=[],
)
track.date = datetime(2022, 3, 14, 9, 26, 54)
- track.set_path(convert.smart_convert(load_gpx_asset("MyTourbook_1.gpx.gz")).path())
dbsession.add(track)
dbsession.flush()
+ track.fast_set_path(path)
data_manager.initialize(track.id)
tracks.append(track)
track_ids.append(track.id)
diff --git a/tests/integration/test_pdf.py b/tests/integration/test_pdf.py
new file mode 100644
index 0000000..29cda02
--- /dev/null
+++ b/tests/integration/test_pdf.py
@@ -0,0 +1,59 @@
+from contextlib import contextmanager
+from datetime import datetime
+
+from testutils import load_gpx_asset
+from fietsboek import convert, models
+from fietsboek.models.track import Visibility
+
+
+@contextmanager
+def a_track(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
+ added tracks are deleted again after the test, to make a clean slate for
+ the next test.
+ """
+ # The normal transaction is "doomed", so we need to abort it, start a fresh
+ # one, and then explicitely commit it, otherwise we will not persist the
+ # objects to the database.
+ tm.abort()
+
+ with tm:
+ track = models.Track(
+ owner=owner,
+ title="Goober",
+ visibility=Visibility.PUBLIC,
+ description="A bar'd track",
+ badges=[],
+ link_secret="raboof",
+ tagged_people=[],
+ )
+ track.date = datetime(2027, 3, 14, 9, 26, 54)
+ track.set_path(convert.smart_convert(load_gpx_asset("MyTourbook_1.gpx.gz")).path())
+ dbsession.add(track)
+ dbsession.flush()
+ data_manager.initialize(track.id)
+ track_id = track.id
+
+ tm.begin()
+ tm.doom()
+
+ try:
+ yield track_id
+ finally:
+ tm.abort()
+ with tm:
+ dbsession.delete(track)
+ data_manager.purge(track_id)
+ tm.begin()
+ tm.doom()
+
+
+def test_pdf(testapp, dbsession, route_path, logged_in, tm, data_manager):
+ # pylint: disable=too-many-positional-arguments
+ # Ensure there are some tracks in the database
+ with a_track(tm, dbsession, logged_in, data_manager) as track_id:
+ pdf = testapp.get(route_path("track-pdf", track_id=track_id))
+
+ assert pdf