Exemplo n.º 1
0
    def test_ballot_result1(self):
        ballot = self.create_ballot(1)
        ops = self.create_options(ballot, 5)

        # 0 0 0 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 1 0 0 0 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[1], 1)
        # 1 1 0 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[2], 1)
        # 1 1 1 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 2 1 1 0 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[1], 1)
        # 2 2 1 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 3 2 1 0 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))
Exemplo n.º 2
0
    def test_ballot_result1(self):
        ballot = self.create_ballot(1)
        ops = self.create_options(ballot, 5)

        # 0 0 0 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 1 0 0 0 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[1], 1)
        # 1 1 0 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[2], 1)
        # 1 1 1 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 2 1 1 0 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[1], 1)
        # 2 2 1 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 3 2 1 0 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))
Exemplo n.º 3
0
    def test_ballot_result2_yn2(self):
        ballot = self.create_ballot(2)
        ops = self.create_options(ballot, 2)

        # 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 1 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1, -1)
        # 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1, -1)
        # -1 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        self.add_votes(ops[0], 1)
        self.add_votes(ops[0], 1)
        # 2 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[1], 1)
        # 2 1
        self.assertEqual(2, self.elected_count(ballot_result(ballot)))
Exemplo n.º 4
0
    def test_ballot_result2_yn2(self):
        ballot = self.create_ballot(2)
        ops = self.create_options(ballot, 2)

        # 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 1 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1, -1)
        # 0 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1, -1)
        # -1 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        self.add_votes(ops[0], 1)
        self.add_votes(ops[0], 1)
        # 2 0
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[1], 1)
        # 2 1
        self.assertEqual(2, self.elected_count(ballot_result(ballot)))
Exemplo n.º 5
0
    def test_ballot_result1_yn(self):
        ballot = self.create_ballot(1)
        ops = self.create_options(ballot, 1)

        # 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 1
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1, -1)
        # 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1, -1)
        # -1
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        self.add_votes(ops[0], 1)
        self.add_votes(ops[0], 1)
        # 2
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))
Exemplo n.º 6
0
    def test_ballot_result1_yn(self):
        ballot = self.create_ballot(1)
        ops = self.create_options(ballot, 1)

        # 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        # 1
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1, -1)
        # 0
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1, -1)
        # -1
        self.assertEqual(0, self.elected_count(ballot_result(ballot)))

        self.add_votes(ops[0], 1)
        self.add_votes(ops[0], 1)
        self.add_votes(ops[0], 1)
        # 2
        self.assertEqual(1, self.elected_count(ballot_result(ballot)))