Esempio n. 1
0
    def test_election_quorum(self):
        """
        Test that an election stays incomplete until a majority of votes
        """
        votes = Election('abcdef')
        for idx, char in enumerate('abc'):
            votes.vote(char, idx % 2 == 0)
            self.assertFalse(votes.has_quorum())

        for idx, char in enumerate('def'):
            votes.vote(char, idx % 2 == 0)
            self.assertTrue(votes.has_quorum())
Esempio n. 2
0
    def test_election_failed(self):
        """
        Test that an election fails after quorum
        """
        votes = Election('abcdef')
        for idx, char in enumerate('abc'):
            votes.vote(char, idx % 2 != 0)
            self.assertFalse(votes.has_failed())

        for idx, char in enumerate('def'):
            votes.vote(char, idx % 2 != 0)

        self.assertTrue(votes.has_failed())