Browse Source

cannot vote in the same day

master
Julio Biason 11 years ago
parent
commit
5be65f7167
  1. 23
      tests/vote_tests.py

23
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()

Loading…
Cancel
Save