Example #1
0
 def test_failover_multiple(self):
     vote1 = 'Obama'
     vote2 = 'Romney'
     candidates = [vote1, vote2]
     good_ballot = ballot.Ballot(candidates)
     good_ballot.failover()
     self.assertEqual(good_ballot.candidate(), vote2)
Example #2
0
 def test_register_ballot_good(self):
     candidate = 'cat'
     good_ballot = ballot.Ballot([candidate])
     self.elect.register_ballot(good_ballot)
     num_votes = self.elect.votes[candidate]
     self.assertEqual(num_votes, 1)
     self.assertEqual(self.elect.ballots[candidate], [good_ballot])
Example #3
0
 def test_isexhausted_no(self):
     good_ballot = ballot.Ballot(['blah'])
     self.assertEqual(good_ballot.isexhausted(), False)
Example #4
0
 def test_failover_single(self):
     bare_ballot = ballot.Ballot(['cat'])
     bare_ballot.failover()
     self.assertEqual(bare_ballot.candidate(), None)
Example #5
0
 def test_candidate_bad(self):
     bad_ballot = ballot.Ballot()
     self.assertEqual(bad_ballot.candidate(), None)
Example #6
0
 def test_candidate_ok(self):
     vote1 = 'Obama'
     vote2 = 'Romney'
     candidates = [vote1, vote2]
     good_ballot = ballot.Ballot(candidates)
     self.assertEqual(good_ballot.candidate(), vote1)
Example #7
0
 def test_isexhausted_yes(self):
     bad_ballot = ballot.Ballot()
     self.assertEqual(bad_ballot.isexhausted(), True)
Example #8
0
 def test_register_ballot_bad(self):
     bad_ballot = ballot.Ballot()
     self.elect.register_ballot(bad_ballot)
     self.assertEqual(sum(self.elect.votes.values()), 0)
     self.assertEqual(len(self.elect.ballots), 0)