Ejemplo n.º 1
0
    def test_redistribute_votes_later_round_has_vote_for_user_that_has_already_won_and_no_others(
            self):
        e = ScottishStvElection(seats=5)
        e.excess_votes = {
            'Affordable Housing': {
                'excess': 4,
                'total': 6,
                'used': False
            },
            'Internal organizing': {
                'excess': 1,
                'total': 3,
                'used': False
            }
        }
        e.prior_winners = ['Affordable Housing', 'Internal organizing']
        e.ballots_run = 1

        e.votes = [[
            'Affordable Housing', 'Climate Change/Green New Deal',
            'Democratic Party Transformation',
            "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
            'Immigration', 'Indigenous People/Nations', 'Internal organizing',
            'Medicare for All/Single-payer Healthcare',
            'Money out of Politics', 'Municipal Elections',
            'Voting Reform - including Ranked Choice Voting & HR1'
        ],
                   [
                       'Affordable Housing', 'Good Jobs',
                       'Democratic Party Transformation',
                       'Medicare for All/Single-payer Healthcare',
                       'Indigenous People/Nations',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       None, None, None, None, None, None
                   ],
                   [
                       'Internal organizing', 'Money out of Politics',
                       'Affordable Housing', 'Good Jobs', 'Immigration',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       'Indigenous People/Nations', None, None, None, None,
                       None
                   ],
                   [
                       'Affordable Housing', 'Climate Change/Green New Deal',
                       'Democratic Party Transformation',
                       "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
                       'Immigration', 'Indigenous People/Nations',
                       'Internal organizing',
                       'Medicare for All/Single-payer Healthcare',
                       'Money out of Politics', 'Municipal Elections',
                       'Voting Reform - including Ranked Choice Voting & HR1'
                   ],
                   [
                       'Affordable Housing', 'Good Jobs',
                       'Democratic Party Transformation',
                       'Medicare for All/Single-payer Healthcare',
                       'Indigenous People/Nations',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       None, None, None, None, None, None
                   ],
                   [
                       'Internal organizing', 'Money out of Politics',
                       'Affordable Housing', 'Good Jobs', 'Immigration',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       'Indigenous People/Nations', None, None, None, None,
                       None
                   ],
                   [
                       'Affordable Housing', 'Climate Change/Green New Deal',
                       'Democratic Party Transformation',
                       "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
                       'Immigration', 'Indigenous People/Nations',
                       'Internal organizing',
                       'Medicare for All/Single-payer Healthcare',
                       'Money out of Politics', 'Municipal Elections',
                       'Voting Reform - including Ranked Choice Voting & HR1'
                   ],
                   [
                       'Affordable Housing', 'Good Jobs',
                       'Democratic Party Transformation',
                       'Medicare for All/Single-payer Healthcare',
                       'Indigenous People/Nations',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       None, None, None, None, None, None
                   ],
                   [
                       'Internal organizing', 'Affordable Housing', None, None,
                       None, None, None, None, None, None, None
                   ]]

        # in this example, 'Affordable Housing' has already won and been redistributed
        # we're now redistributing 'Internal organizing'
        # last of that choice's voters already chose 'Affordable Housing'
        # we should go down the user's list of priorities until we find one that hasn't won yet
        # but there isn't one
        e.redistribute_votes(redistribute_from='Internal organizing')
        self.assertEqual(
            e.redistributed_votes,
            [[
                'Money out of Politics', 'Affordable Housing', 'Good Jobs',
                'Immigration',
                'Voting Reform - including Ranked Choice Voting & HR1',
                'Indigenous People/Nations', None, None, None, None, None
            ],
             [
                 'Money out of Politics', 'Affordable Housing', 'Good Jobs',
                 'Immigration',
                 'Voting Reform - including Ranked Choice Voting & HR1',
                 'Indigenous People/Nations', None, None, None, None, None
             ], [None, None, None, None, None, None, None, None, None]])
Ejemplo n.º 2
0
    def test_redistribute_votes_results(self):
        e = ScottishStvElection(seats=5)
        e.excess_votes = {
            'Affordable Housing': {
                'excess': 4,
                'total': 6,
                'used': False
            }
        }

        e.votes = [[
            'Affordable Housing', 'Climate Change/Green New Deal',
            'Democratic Party Transformation',
            "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
            'Immigration', 'Indigenous People/Nations', 'Internal organizing',
            'Medicare for All/Single-payer Healthcare',
            'Money out of Politics', 'Municipal Elections',
            'Voting Reform - including Ranked Choice Voting & HR1'
        ],
                   [
                       'Affordable Housing', 'Good Jobs',
                       'Democratic Party Transformation',
                       'Medicare for All/Single-payer Healthcare',
                       'Indigenous People/Nations',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       None, None, None, None, None, None
                   ],
                   [
                       'Internal organizing', 'Money out of Politics',
                       'Affordable Housing', 'Good Jobs', 'Immigration',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       'Indigenous People/Nations', None, None, None, None,
                       None
                   ],
                   [
                       'Affordable Housing', 'Climate Change/Green New Deal',
                       'Democratic Party Transformation',
                       "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
                       'Immigration', 'Indigenous People/Nations',
                       'Internal organizing',
                       'Medicare for All/Single-payer Healthcare',
                       'Money out of Politics', 'Municipal Elections',
                       'Voting Reform - including Ranked Choice Voting & HR1'
                   ],
                   [
                       'Affordable Housing', 'Good Jobs',
                       'Democratic Party Transformation',
                       'Medicare for All/Single-payer Healthcare',
                       'Indigenous People/Nations',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       None, None, None, None, None, None
                   ],
                   [
                       'Internal organizing', 'Money out of Politics',
                       'Affordable Housing', 'Good Jobs', 'Immigration',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       'Indigenous People/Nations', None, None, None, None,
                       None
                   ],
                   [
                       'Affordable Housing', 'Climate Change/Green New Deal',
                       'Democratic Party Transformation',
                       "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
                       'Immigration', 'Indigenous People/Nations',
                       'Internal organizing',
                       'Medicare for All/Single-payer Healthcare',
                       'Money out of Politics', 'Municipal Elections',
                       'Voting Reform - including Ranked Choice Voting & HR1'
                   ],
                   [
                       'Affordable Housing', 'Good Jobs',
                       'Democratic Party Transformation',
                       'Medicare for All/Single-payer Healthcare',
                       'Indigenous People/Nations',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       None, None, None, None, None, None
                   ],
                   [
                       'Internal organizing', 'Money out of Politics',
                       'Affordable Housing', 'Good Jobs', 'Immigration',
                       'Voting Reform - including Ranked Choice Voting & HR1',
                       'Indigenous People/Nations', None, None, None, None,
                       None
                   ]]

        # after redistributing, should have a new multiplier set, and votes with 'Affordable Housing' as first option
        # should now be on their second choice in e.redistributed votes
        e.redistribute_votes(redistribute_from='Affordable Housing')
        self.assertEqual(e.multiplier, 0.66667)
        self.assertEqual(
            e.redistributed_votes,
            [[
                'Climate Change/Green New Deal',
                'Democratic Party Transformation',
                "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
                'Immigration', 'Indigenous People/Nations',
                'Internal organizing',
                'Medicare for All/Single-payer Healthcare',
                'Money out of Politics', 'Municipal Elections',
                'Voting Reform - including Ranked Choice Voting & HR1'
            ],
             [
                 'Good Jobs', 'Democratic Party Transformation',
                 'Medicare for All/Single-payer Healthcare',
                 'Indigenous People/Nations',
                 'Voting Reform - including Ranked Choice Voting & HR1', None,
                 None, None, None, None, None
             ],
             [
                 'Climate Change/Green New Deal',
                 'Democratic Party Transformation',
                 "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
                 'Immigration', 'Indigenous People/Nations',
                 'Internal organizing',
                 'Medicare for All/Single-payer Healthcare',
                 'Money out of Politics', 'Municipal Elections',
                 'Voting Reform - including Ranked Choice Voting & HR1'
             ],
             [
                 'Good Jobs', 'Democratic Party Transformation',
                 'Medicare for All/Single-payer Healthcare',
                 'Indigenous People/Nations',
                 'Voting Reform - including Ranked Choice Voting & HR1', None,
                 None, None, None, None, None
             ],
             [
                 'Climate Change/Green New Deal',
                 'Democratic Party Transformation',
                 "Fair Share Amendment/Millionaire's Tax", 'Good Jobs',
                 'Immigration', 'Indigenous People/Nations',
                 'Internal organizing',
                 'Medicare for All/Single-payer Healthcare',
                 'Money out of Politics', 'Municipal Elections',
                 'Voting Reform - including Ranked Choice Voting & HR1'
             ],
             [
                 'Good Jobs', 'Democratic Party Transformation',
                 'Medicare for All/Single-payer Healthcare',
                 'Indigenous People/Nations',
                 'Voting Reform - including Ranked Choice Voting & HR1', None,
                 None, None, None, None, None
             ]])