Ejemplo n.º 1
0
    def test_get_number_of_votes(self, app):
        with app.app_context():
            now = datetime.now()
            p = Poll(id=None, name="Nom", date=now)
            p.save()

            assert p.number_of_votes() == 0

            c1 = Choice(id=None, choice="Premier choix", poll=p)
            c1.save()

            c2 = Choice(id=None, choice="Deuxième choix", poll=p)
            c2.save()

            assert p.number_of_votes() == 0

            c1.cast_vote()
            c1.cast_vote()
            c2.cast_vote()

            assert p.number_of_votes() == 3