Skip to content

Instantly share code, notes, and snippets.

@Porter97
Created February 13, 2020 20:09
Show Gist options
  • Save Porter97/acd95d9fc8642d4f6e1801ca9c1d5062 to your computer and use it in GitHub Desktop.
Save Porter97/acd95d9fc8642d4f6e1801ca9c1d5062 to your computer and use it in GitHub Desktop.
import unittest
import stream
from flask import current_app
from app import create_app, db
from app.models import User, Role, Collection
class UserModelTestCase(unittest.TestCase):
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
Role.insert_roles()
def tearDown(self):
db.session.remove()
db.drop_all()
self.app_context.pop()
def test_collections(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()
self.assertTrue(u.confirm(confirm_token))
c = Collection(name='test', description='test description', author=u)
db.session.add(c)
db.session.commit()
self.assertTrue(c.add_to_stream())
c.name = 'test2'
c.description = 'test description 2'
db.session.commit()
self.assertTrue(c.update_stream())
self.assertTrue(c.delete_from_stream())
client.users.delete(u.id)
db.session.delete(c)
db.session.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment