jasminefiner
9/22/2018 - 2:42 PM

22: Test Resend Confirmation Route

UMS: User Registration 22

# tests/test_auth.py
# ...
class AuthenticationTestCase(unittest.TestCase):
    # ...
    def test_logged_in_resend_confirmation_route(self):
        u = User(email='john@example.com', username='john', password='cat', confirmed=False)
        db.session.add(u)
        self.login(u.email, 'cat')
        response = self.client.get('/auth/confirm', follow_redirects=True)
        self.assertIn('A new confirmation token email has been send to you.', response.get_data(as_text=True))

        u.confirmed=True
        db.session.add(u)
        response = self.client.get('/auth/confirm', follow_redirects=True)
        self.assertIn('You are already confirmed. No need to send new link.', response.get_data(as_text=True))

    def test_logged_out_resend_confirmation_route(self):
        response = self.client.get('/auth/confirm', follow_redirects=True)
        self.assertIn('Please log in to access this page', response.get_data(as_text=True))