From 5be65f7167df0d0256fbe8124dcdcad475b906d8 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Mon, 14 Apr 2014 20:52:22 -0300 Subject: [PATCH] cannot vote in the same day --- tests/vote_tests.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/vote_tests.py b/tests/vote_tests.py index 89a73d8..a569767 100644 --- a/tests/vote_tests.py +++ b/tests/vote_tests.py @@ -70,5 +70,28 @@ class TestVote(LunchoTests): self.assertJsonError(rv, 406, 'The vote must register 2 places') return + def test_already_voted(self): + """Try to vote when the user already voted.""" + group = self._group() + place = self._place() + group.places.append(place) + self.user.groups.append(group) + server.db.session.commit() + + group_id = group.id + token = self.user.token + + request = {'choices': [place.id]} + rv = self.post('/vote/{group_id}/'.format(group_id=group_id), + request, + token=token) + self.assertJsonOk(rv) # vote in the day + + rv = self.post('/vote/{group_id}/'.format(group_id=group_id), + request, + token=token) + self.assertJsonError(rv, 406, 'User already voted today') + return + if __name__ == '__main__': unittest.main()