♻️ Update tests

This commit is contained in:
Brian Wiborg 2023-04-03 13:47:55 +02:00
parent 94cb80c627
commit 92d78d0a23
No known key found for this signature in database
GPG Key ID: BE53FA9286B719D6

View File

@ -16,17 +16,17 @@ class TestVoter(unittest.TestCase):
Voting(title="Test", quorum=Quorum(), voters=['a'])
def test_vote_before_end(self):
self.voting.vote(voter='a', vote=Vote.YES)
self.voting.vote(voter='a', vote=Vote.JA)
def test_vote_after_end(self):
self.voting.days = 0
self.assertRaises(RuntimeError, self.voting.vote, voter='a', vote=Vote.YES)
self.assertRaises(RuntimeError, self.voting.vote, voter='a', vote=Vote.JA)
def test_unknown_voter(self):
self.assertRaises(ValueError, self.voting.vote, voter='z', vote=Vote.YES)
self.assertRaises(ValueError, self.voting.vote, voter='z', vote=Vote.JA)
def test_known_voter(self):
self.voting.vote('a', Vote.YES)
self.voting.vote('a', Vote.JA)
class TestResult(unittest.TestCase):
@ -46,23 +46,23 @@ class TestResult(unittest.TestCase):
assert res['voting']['start'] == self.timestamp
assert res['voting']['days'] == 7
assert res['voting']['votes'] == {}
assert res['votes'] == {'YES': 0, 'NO': 0, 'ABSTENTION': 0}
assert res['votes'] == {'JA': 0, 'NEIN': 0, 'ENTHALTUNG': 0}
assert res['quorum_reached'] == True
def test_result_data_with_votes(self):
self.voting.vote(voter='a', vote=Vote.YES)
self.voting.vote(voter='a', vote=Vote.JA)
res = self.result.result()
assert res['voting']['votes'] == {'a': 'YES'}
assert res['votes'] == {'YES': 1, 'NO': 0, 'ABSTENTION': 0}
assert res['voting']['votes'] == {'a': 'JA'}
assert res['votes'] == {'JA': 1, 'NEIN': 0, 'ENTHALTUNG': 0}
def test_result_data_with_outcome_accept(self):
self.voting.vote(voter='a', vote=Vote.YES)
self.voting.vote(voter='a', vote=Vote.JA)
self.voting.days = 0
res = self.result.result()
assert res['state'] == 'ANGENOMMEN'
def test_result_data_with_outcome_declined(self):
self.voting.vote(voter='a', vote=Vote.NO)
self.voting.vote(voter='a', vote=Vote.NEIN)
self.voting.days = 0
res = self.result.result()
assert res['state'] == 'ABGELEHNT'