def test_valid_email_change_token(mockdata): user = User(email='*****@*****.**', password='******') db.session.add(user) db.session.commit() token = user.generate_email_change_token('*****@*****.**') assert user.change_email(token) is True assert user.email == '*****@*****.**'
def test_duplicate_email_change_token(mockdata): user1 = User(email='*****@*****.**', password='******') user2 = User(email='*****@*****.**', password='******') db.session.add(user1) db.session.add(user2) db.session.commit() token = user2.generate_email_change_token('*****@*****.**') assert user2.change_email(token) is False assert user2.email == '*****@*****.**'
def test_invalid_email_change_token(mockdata): user1 = User(email='*****@*****.**', password='******') user2 = User(email='*****@*****.**', password='******') db.session.add(user1) db.session.add(user2) db.session.commit() token = user1.generate_email_change_token('*****@*****.**') assert user2.change_email(token) is False assert user2.email == '*****@*****.**'