def test_unsubscribe(self): db.create_all() u = User(email='*****@*****.**', username='******', password='******') t = Talk(title='t', description='d', author=u) c1 = Comment(talk=t, body='c1', author_name='n', author_email='*****@*****.**', approved=True, notify=True) c2 = Comment(talk=t, body='c2', author_name='n', author_email='*****@*****.**', approved=False, notify=True) c3 = Comment(talk=t, body='c3', author_name='n', author_email='*****@*****.**', approved=False, notify=True) db.session.add_all([u, t, c1, c2, c3]) db.session.commit() token = t.get_unsubscribe_token(u'*****@*****.**') Talk.unsubscribe_user(token) comments = t.comments.all() for comment in comments: if comment.author_email == '*****@*****.**': self.assertTrue(comment.notify == False) else: self.assertTrue(comment.notify == True)
def test_bad_unsubscribe_token(self): talk, email = Talk.unsubscribe_user('an invalid token') self.assertIsNone(talk) self.assertIsNone(email) u = User(email='*****@*****.**', username='******', password='******') t = Talk(title='t', description='d', author=u) token = t.get_unsubscribe_token('*****@*****.**') talk, email = Talk.unsubscribe_user(token) self.assertIsNone(talk) self.assertIsNone(email)
def test_bad_unsubscribe_token(self): talk, email = Talk.unsubscribe_user('an invalid token') self.assertIsNone(talk) self.assertIsNone(email) u = User(email='*****@*****.**', username='******', password='******') t = Talk(title='t', description='d', author=u) token = t.get_unsubscribe_token('*****@*****.**') talk, email = Talk.unsubscribe_user(token) self.assertIsNone(talk) self.assertIsNone(email)
def test_unsubscribe(self): db.create_all() u = User(email='*****@*****.**', username='******', password='******') t = Talk(title='t', description='d', author=u) c1 = Comment(talk=t, body='c1', author_name='n', author_email='*****@*****.**', approved=True, notify=True) c2 = Comment(talk=t, body='c2', author_name='n', author_email='*****@*****.**', approved=False, notify=True) c3 = Comment(talk=t, body='c3', author_name='n', author_email='*****@*****.**', approved=False, notify=True) db.session.add_all([u, t, c1, c2, c3]) db.session.commit() token = t.get_unsubscribe_token(u'*****@*****.**') Talk.unsubscribe_user(token) comments = t.comments.all() for comment in comments: if comment.author_email == '*****@*****.**': self.assertTrue(comment.notify == False) else: self.assertTrue(comment.notify == True)