コード例 #1
0
ファイル: test_election.py プロジェクト: bbengfort/cloudscope
    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())
コード例 #2
0
ファイル: test_election.py プロジェクト: bbengfort/cloudscope
    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())
コード例 #3
0
ファイル: test_election.py プロジェクト: bbengfort/cloudscope
    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())
コード例 #4
0
ファイル: test_election.py プロジェクト: bbengfort/cloudscope
    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())