From 69c9167911a8449fef20951abe924a1c4528545c Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sun, 17 Jul 2022 20:56:38 +0200 Subject: add tests for archive download --- tests/conftest.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/conftest.py') diff --git a/tests/conftest.py b/tests/conftest.py index b8e3090..79f0245 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -141,3 +141,25 @@ def route_path(app_request): def get_route_path(*args, **kwargs): return app_request.route_path(*args, **kwargs) return get_route_path + + +@pytest.fixture() +def logged_in(dbsession, testapp, route_path): + """ + A fixture that represents a logged in state. + + This automatically creates a user and returns the created user. + + Returns the user that was logged in. + """ + user = models.User(email='foo@bar.com', is_verified=True) + user.set_password("foobar") + dbsession.add(user) + + login = testapp.get(route_path('login')) + form = login.form + form['email'] = 'foo@bar.com' + form['password'] = 'foobar' + response = form.submit() + assert response.status_code == 302 + return user -- cgit v1.2.3