Skip to content

Instantly share code, notes, and snippets.

@thatnerdjosh
Last active August 29, 2015 14:27
Show Gist options
  • Save thatnerdjosh/32c6e7a93d26481dc7cb to your computer and use it in GitHub Desktop.
Save thatnerdjosh/32c6e7a93d26481dc7cb to your computer and use it in GitHub Desktop.
def test_vote_select_vote(self):
""" Test the vote_range function - the re-voting part. """
#First we need to vote
self.setup_db()
user = FakeUser(['voters'], username='nerdsville')
with user_set(fedora_elections.APP, user):
retrieve_csrf = self.app.post('/vote/test_election6')
csrf_token = retrieve_csrf.data.split(
'name="csrf_token" type="hidden" value="')[1].split('">')[0]
# Valid input
data = {
'Toshio': True,
'action': 'submit',
'csrf_token': csrf_token,
}
self.app.post('/vote/test_election6', data=data, follow_redirects=True)
vote = fedora_elections.models.Vote
votes = vote.of_user_on_election(self.session, "nerdsville", '6')
self.assertEqual(votes[0].value, 1)
def test_vote_select_vote_fail(self):
#First we need to vote
self.setup_db()
user = FakeUser(['voters'], username='nerdsville')
with user_set(fedora_elections.APP, user):
# Valid input
data = {
'Toshio': False,
'action': 'submit',
'csrf_token': csrf_token,
}
self.app.post('/vote/test_election6', data=data, follow_redirects=True)
vote = fedora_elections.models.Vote
votes = vote.of_user_on_election(self.session, "nerdsville", '6')
#Should FAIL!
self.assertEqual(votes[0].value, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment