Skip to content
Snippets Groups Projects
Commit 578f8cdd authored by Ben Adida's avatar Ben Adida
Browse files

fixed data for voter_id_hash legacy compatibility

parent 74b36d53
No related branches found
No related tags found
No related merge requests found
...@@ -480,6 +480,11 @@ class Voter(HeliosObject): ...@@ -480,6 +480,11 @@ class Voter(HeliosObject):
@property @property
def voter_id_hash(self): def voter_id_hash(self):
if self.voter_login_id:
# for backwards compatibility with v3.0, and since it doesn't matter
# too much if we hash the email or the unique login ID here.
return utils.hash_b64(self.voter_login_id)
else:
return utils.hash_b64(self.voter_id) return utils.hash_b64(self.voter_id)
class Trustee(HeliosObject): class Trustee(HeliosObject):
......
This diff is collapsed.
...@@ -219,17 +219,24 @@ class CastVoteModelTests(TestCase): ...@@ -219,17 +219,24 @@ class CastVoteModelTests(TestCase):
class LegacyElectionBlackboxTests(TestCase): class LegacyElectionBlackboxTests(TestCase):
fixtures = ['legacy-data.json'] fixtures = ['legacy-data.json']
EXPECTED_OUTPUT_FILE = 'helios/fixtures/legacy-election-expected.json' EXPECTED_ELECTION_FILE = 'helios/fixtures/legacy-election-expected.json'
EXPECTED_VOTERS_FILE = 'helios/fixtures/legacy-election-voters-expected.json'
def setUp(self): def setUp(self):
self.election = models.Election.objects.all()[0] self.election = models.Election.objects.all()[0]
def test_legacy_format(self): def assertEqualsToFile(self, response, file_path):
response = self.client.get("/helios/elections/%s" % self.election.uuid, follow=False) expected = open(file_path)
expected = open(self.EXPECTED_OUTPUT_FILE)
self.assertEquals(response.content, expected.read()) self.assertEquals(response.content, expected.read())
expected.close() expected.close()
def test_election(self):
response = self.client.get("/helios/elections/%s" % self.election.uuid, follow=False)
self.assertEqualsToFile(response, self.EXPECTED_ELECTION_FILE)
def test_voters_list(self):
response = self.client.get("/helios/elections/%s/voters/" % self.election.uuid, follow=False)
self.assertEqualsToFile(response, self.EXPECTED_VOTERS_FILE)
class ElectionBlackboxTests(TestCase): class ElectionBlackboxTests(TestCase):
fixtures = ['users.json', 'election.json'] fixtures = ['users.json', 'election.json']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment