UMS: User Registration 19
# tests/test_auth.py
# ...
class AuthenticationTestCase(unittest.TestCase):
# ...
def test_logged_in_unconfirmed_route(self):
# Unconfirmed logged in user
u = User(email='john@example.com', username='john', password='cat', confirmed=False)
db.session.add(u)
response = self.login(u.email, 'cat')
self.assertIn('You have not confirmed your account yet.', response.get_data(as_text=True))
# Confirmed logged in user
u.confirmed = True
db.session.add(u)
response = self.client.get('/auth/unconfirmed', follow_redirects=True)
self.assertIn('You are confirmed!', response.get_data(as_text=True))
def test_logged_out_unconfirmed_route(self):
response = self.client.get('/auth/unconfirmed', follow_redirects=True)
self.assertIn('Please log in to access this page.', response.get_data(as_text=True))