def test_vote_different_submit(): place = Place( name="Testplace", description="foo", ) place.save() splace = Place(name='Submit') splace.save() e = Election( name="testelect", password="******", authurl="bar", isopen=True, production=True, ispublic=True, firstpassword=True, secondpassword=True, stv=True, government=True, toelect=100, ) e.save() p = Person( personnumber="1234", electionname=e, hasvoted=True, votestyle=0, hetu='foob', organization='tukkk.fi', id=1, ) p.save() u = User(username='******', password='******') u.save() t = Ticket( voter=p, release_place=place, releaser=u, ) t.save() c = Client() fake_request = HttpRequest() fake_request.META['HTTP_MAIL'] = '*****@*****.**' fake_request.META['HTTP_DISPLAYNAME'] = '' fake_request.META['HTTP_SN'] = '' c.login(request=fake_request) response = c.post( '/tarkistus/commit/', {'number': '1234', 'organization': 'tukkk.fi', 'place': 2} ) eq(response.status_code, 200) try: c = simplejson.loads(response.content) except ValueError, e: print response.content raise
def test_vote_single_already_voted_on_paper(): place = Place( name="Testplace", description="foo", ) place.save() e = Election( name="testelect", password="******", authurl="bar", isopen=True, production=True, ispublic=True, firstpassword=True, secondpassword=True, stv=True, government=True, toelect=100, ) e.save() p = Person( personnumber="1234", electionname=e, hasvoted=True, votestyle=1, votedate=datetime(2009,1,1,18,0), hetu='foob', organization='tukkk.fi', id=1, ) p.save() u = User(username='******', password='******') u.save() ticket = Ticket( voter=p, release_place=place, releaser=u, submit_place=place, submitter=u, ) ticket.save() c = Client() fake_request = HttpRequest() fake_request.META['HTTP_MAIL'] = '*****@*****.**' fake_request.META['HTTP_DISPLAYNAME'] = '' fake_request.META['HTTP_SN'] = '' c.login(request=fake_request) response = c.post( '/tarkistus/commit/', {'number': '1234', 'organization': 'tukkk.fi', 'place': 1} ) eq(response.status_code, 200) try: c = simplejson.loads(response.content) except ValueError: print repr(response.content) raise eq( c['errors'], {'__all__': ['Person has voted in Testplace on 01.01.2009 '+ 'at 18:00']} )