diff options
author | Daniel Schadt <kingdread@gmx.de> | 2022-12-29 14:58:24 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2022-12-29 14:58:24 +0100 |
commit | 92199846b87f1736b9f807bfd8093bff7a67922e (patch) | |
tree | 69d108f8cd9add0c074776502b2eeb27c2ac5df1 /tests | |
parent | 2aee4fe00400ae34350ed50a05fa5c3ac30b1eac (diff) | |
download | fietsboek-92199846b87f1736b9f807bfd8093bff7a67922e.tar.gz fietsboek-92199846b87f1736b9f807bfd8093bff7a67922e.tar.bz2 fietsboek-92199846b87f1736b9f807bfd8093bff7a67922e.zip |
start to move out high-level actions
This is code that needs to be repeated in possibly several places
(website, API, tests), so it makes sense to have those "high level
actions" a bit abstracted. edit.edit_images was already doing that to a
certain degree, but the code shouldn't have stayed in the view.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/playwright/conftest.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/playwright/conftest.py b/tests/playwright/conftest.py index 21edca8..18b7ad0 100644 --- a/tests/playwright/conftest.py +++ b/tests/playwright/conftest.py @@ -8,7 +8,7 @@ from pyramid.authentication import AuthTktCookieHelper from pyramid.testing import DummyRequest from testutils import load_gpx_asset -from fietsboek import models, util +from fietsboek import models, util, actions from fietsboek.models.track import Visibility, TrackType from fietsboek.config import Config @@ -114,20 +114,23 @@ class Helper: user = self.john_doe() with self.dbaccess: user = self.dbaccess.merge(user) - track = models.Track( + track = actions.add_track( + self.dbaccess, + self.data_manager, + owner=user, title="Another awesome track", visibility=Visibility.PRIVATE, description="Another description", - type=TrackType.ORGANIC, - link_secret=util.random_link_secret(), + track_type=TrackType.ORGANIC, + date=datetime.datetime(2022, 12, 21, 17, 5, tzinfo=datetime.timezone.utc), + tags=[], + badges=[], + tagged_people=[], + gpx_data=load_gpx_asset(track_name), ) - track.date = datetime.datetime(2022, 12, 21, 17, 5, tzinfo=datetime.timezone.utc) - user.tracks.append(track) - self.dbaccess.flush() - self.dbaccess.refresh(track, ["id"]) - self.dbaccess.expunge(track) - self.data_manager.initialize(track.id).compress_gpx(load_gpx_asset(track_name)) self.dbaccess.commit() + self.dbaccess.refresh(track, ["id", "link_secret"]) + self.dbaccess.expunge(track) return track |