def test_index(self, app, client): with app.app_context(): now = datetime.now() p = Poll(id=None, name="Mon premier sondage", date=now) p.save() response = client.get("/") assert Poll.select().count() == 1 assert response.status_code == 200 assert b"Aucuns sondages actifs" not in response.data assert b"Mon premier sondage" in response.data
def index(): polls = Poll.select() if polls: return views.index(polls) else: return views.index_empty()
def test_empty_index(self, app, client): with app.app_context(): response = client.get("/") assert response.status_code == 200 assert Poll.select().count() == 0 assert b"Aucuns sondages actifs" in response.data