Skip to content

Instantly share code, notes, and snippets.

@Porter97
Created February 13, 2020 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Porter97/52f7394ea5be2419d6127519ed7de5d5 to your computer and use it in GitHub Desktop.
Save Porter97/52f7394ea5be2419d6127519ed7de5d5 to your computer and use it in GitHub Desktop.
#...
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