From 92199846b87f1736b9f807bfd8093bff7a67922e Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 29 Dec 2022 14:58:24 +0100 Subject: 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. --- tests/playwright/conftest.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'tests/playwright') 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 -- cgit v1.2.3