From 90703859f627e4cba45aacbe0ae6815dde396851 Mon Sep 17 00:00:00 2001 From: Ben Adida <ben@adida.net> Date: Wed, 29 Dec 2010 15:02:44 -0800 Subject: [PATCH] updated tests and updated django requirement to 1.2.4 --- README.txt | 4 +++- helios/tests.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index bc91a8d..593ab2b 100644 --- a/README.txt +++ b/README.txt @@ -4,6 +4,8 @@ The Helios Election Server LICENSE: this code is released under the GPL v3 or later. NEEDS: +- as of Helios v3.1, requires Django 1.2.4+ + - http://github.com/openid/python-openid - rabbitmq 1.8 -- http://www.rabbitmq.com/debian.html @@ -31,6 +33,6 @@ to get the south db models set up, and then: python manage.py migrate --list -- if there are some unchecked migrations, and you are SURE that your database is up to date with the models (which should be the case if you're between v3.0.0 and v3.0.4 inclusive), then do +- if there are some unchecked migrations, and you are SURE that your database is up to date with the models (which should be the case if you're on a v3.0.x version), then do python manage.py migrate --fake diff --git a/helios/tests.py b/helios/tests.py index 60014e6..aae0e46 100644 --- a/helios/tests.py +++ b/helios/tests.py @@ -177,6 +177,7 @@ class ElectionModelTests(TestCase): self.assertEquals(voter.user, self.user) + class VoterModelTests(TestCase): fixtures = ['users.json', 'election.json'] @@ -207,7 +208,8 @@ class ElectionBlackboxTests(TestCase): fixtures = ['users.json', 'election.json'] def setUp(self): - self.election = models.Election.objects.all()[0] + self.election = models.Election.objects.all()[0] + self.user = auth_models.User.objects.get(user_id='ben@adida.net', user_type='google') def test_get_election_shortcut(self): response = self.client.get("/helios/e/%s" % self.election.short_name, follow=True) @@ -243,4 +245,53 @@ class ElectionBlackboxTests(TestCase): response = self.client.get("/helios/elections/%s/voters/" % self.election.uuid, follow=False) self.assertEquals(len(utils.from_json(response.content)), self.election.num_voters) + def test_election_creation_not_logged_in(self): + response = self.client.post("/helios/elections/new", { + "short_name" : "test-complete", + "name" : "Test Complete", + "description" : "A complete election test", + "election_type" : "referendum", + "use_voter_aliases": "0", + "use_advanced_audit_features": "1", + "private_p" : "0"}) + + self.assertRedirects(response, "/auth/?return_url=/helios/elections/new") + + def test_do_complete_election(self): + # set up the session + session = self.client.session + session['user'] = self.user + session.save() + + # create the election + response = self.client.post("/helios/elections/new", { + "short_name" : "test-complete", + "name" : "Test Complete", + "description" : "A complete election test", + "election_type" : "referendum", + "use_voter_aliases": "0", + "use_advanced_audit_features": "1", + "private_p" : "0"}) + + import pdb; pdb.set_trace() + # add helios as trustee + + # add a few voters + # add questions + + # freeze election + + # vote by preparing a ballot via the server-side encryption + + # cast the ballot + + # confirm it + + # encrypted tally + + # should trigger helios decryption automatically + + # combine decryptions + + # check that tally matches -- GitLab