Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#...
import stream
from flask import current_app
#...
class UserModelTestCase(unittest.TestCase):
#...
def test_valid_confirmation_token(self):
client = stream.connect(current_app.config['STREAM_API_KEY'], current_app.config['STREAM_SECRET'])
u = User(id=9999999999, username='john', email='john@example.com', password='test')
db.session.add(u)
db.session.commit()
token = u.generate_confirmation_token()
self.assertTrue(u.confirm(token))
client.users.delete(str(u.id))
#...
def test_valid_email_change_token(self):
client = stream.connect(current_app.config['STREAM_API_KEY'], current_app.config['STREAM_SECRET'])
u = User(id=9999999999, username='john', email='john@example.com', password='test')
db.session.add(u)
db.session.commit()
confirm_token = u.generate_confirmation_token()
email_token = u.generate_email_change_token('john@example.org')
self.assertTrue(u.confirm(confirm_token))
self.assertTrue(u.change_email(email_token))
self.assertTrue(u.email == 'john@example.org')
client.users.delete(str(u.id))
#...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.