예제 #1
0
def test_riding_winners_2_party_same_vote() -> None:
    """Test riding_winner for two party that has same vote"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 45)
    e.update_results('r1', 'np', 45)
    res1 = e.riding_winners('r1')
    assert res1.sort() == ['np', 'ndp'].sort()
예제 #2
0
def test_simple_election_riding_winners_tie() -> None:
    """Test Election.riding_winners with a tie Election."""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 1)
    e.update_results('r1', 'lib', 1)
    e.update_results('r1', 'pc', 1)
    assert e.riding_winners('r1') == ['ndp', 'lib', 'pc']
예제 #3
0
def test_riding_winners_2_party_different_vote() -> None:
    """Test riding_winner for two party that has different vote"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 45)
    e.update_results('r1', 'np', 74)
    res1 = e.riding_winners('r1')
    assert res1 == ['np']
예제 #4
0
def test_riding_winners_multiple_party_same_0_vote() -> None:
    """Test riding_winner for multiple party that same vote"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 0)
    e.update_results('r1', 'np', 0)
    e.update_results('r1', 'ncp', 0)
    e.update_results('r1', 'nap', 0)
    res1 = e.riding_winners('r1')
    assert res1.sort() == ['np', 'ndp', 'ncp', 'nap'].sort()
예제 #5
0
def test_riding_winners_multiple_party_same_vote_except_largest() -> None:
    """Test riding_winner for multiple party that same vote"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 45)
    e.update_results('r1', 'np', 45)
    e.update_results('r1', 'ncp', 45)
    e.update_results('r1', 'nap', 55)
    res1 = e.riding_winners('r1')
    assert res1 == ['nap']
예제 #6
0
def test_riding_winners_multiple_party_different_vote() -> None:
    """Test riding_winner for multiple party that has different vote"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 4)
    e.update_results('r1', 'np', 5)
    e.update_results('r1', 'ncp', 45)
    e.update_results('r1', 'nap', 59)
    res1 = e.riding_winners('r1')
    assert res1 == ['nap']
예제 #7
0
def test_riding_winners_1_party_zero_vote() -> None:
    """Test riding_winner for one party that has 0 votes"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 0)
    res1 = e.riding_winners('r1')
    assert res1 == ['ndp']