diff options
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 22 |
1 files changed, 22 insertions, 0 deletions
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 |