def test_index_(self): from board.views import index_ # Make sure that index_() does not add empty posts postCount = db.query(Post).count() info = index_(testing.DummyRequest(params={'text': u''}, post=True)) self.assertEqual(len(info['posts']), postCount) # Make sure that index_() increments the number of posts postCount = db.query(Post).count() info = index_(testing.DummyRequest(params={'text': u'four'}, post=True)) self.assertEqual(len(info['posts']), postCount + 1)
def test_index(self): from board.views import index # Make sure that index() returns as many posts as exist in the database info = index(testing.DummyRequest()) self.assertEqual(len(info['posts']), db.query(Post).count())
def get_posts(): return db.query(Post).order_by(Post.id.desc()).all()