Skip to content

Instantly share code, notes, and snippets.

@Porter97
Created March 2, 2020 15:45
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/1e5b4e908df50047705366910b7fe36e to your computer and use it in GitHub Desktop.
Save Porter97/1e5b4e908df50047705366910b7fe36e to your computer and use it in GitHub Desktop.
#...
class UserModelTestCase(unittest.TestCase):
#...
def test_collection_follow(self):
client = stream.connect(current_app.config['STREAM_API_KEY'], current_app.config['STREAM_SECRET'])
u1 = User(id=9999999999, username='john', email='john@example.com', password='test')
u2 = User(id=9999999998, username='mary', email='mary@example.org', password='test1')
db.session.add(u1)
db.session.add(u2)
db.session.commit()
token1 = u1.generate_confirmation_token()
token2 = u2.generate_confirmation_token()
self.assertTrue(u1.confirm(token1))
self.assertTrue(u2.confirm(token2))
c = Collection(id=9999999999, name='test', description='test description', author=u1)
db.session.add(c)
db.session.commit()
self.assertTrue(c.add_to_stream())
self.assertFalse(u2.is_following_collection(c))
u2.follow_collection(c)
db.session.commit()
self.assertTrue(u2.is_following_collection(c))
self.assertTrue(u2.unfollow_collection(c))
self.assertFalse(u2.is_following_collection(c))
self.assertTrue(c.delete_from_stream())
client.users.delete(str(u1.id))
client.users.delete(str(u2.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