Check that user isn’t signed in before registering

Previously this test asserted on `current_user.is_authenticated`. That
isn’t possible now because the object imported into tests isn’t the same
one the app is using.

A different proxy for whether the user is signed in is whether they have
a user id in their session, because we set this every time they sign in:
ff32e73d9b/app/models/user.py (L162)
This commit is contained in:
Chris Hill-Scott
2021-10-13 11:31:27 +01:00
parent c2d9a56ff4
commit c3bbc427e2

View File

@@ -340,6 +340,8 @@ def test_register_from_email_auth_invite(
sample_invite['email_address'] = invite_email_address
with client.session_transaction() as session:
session['invited_user_id'] = sample_invite['id']
# Prove that the user isnt already signed in
assert 'user_id' not in session
data = {
'name': 'invited user',
@@ -382,6 +384,8 @@ def test_register_from_email_auth_invite(
)
with client.session_transaction() as session:
# The user is signed in
assert 'user_id' in session
# invited user details are still there so they can get added to the service
assert session['invited_user_id'] == sample_invite['id']