Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.