예제 #1
0
def test_election_winners_1_riding_2_party_tie() -> None:
    """Test election_winners for two tied party in 1 riding"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 20)
    e.update_results('r1', 'np', 20)
    res1 = e.election_winners()
    assert res1.sort() == ['ndp', 'np'].sort()
예제 #2
0
def test_election_winners_0_votes() -> None:
    """Test election_winners for each party has 0 votes"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 0)
    e.update_results('r2', 'np', 0)
    res1 = e.election_winners()
    assert res1.sort() == ['ndp', 'np'].sort()
예제 #3
0
def test_election_winners_2_riding_2_party() -> None:
    """Test election_winners for 2 riding and 2 party"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 19)
    e.update_results('r2', 'np', 69)
    res1 = e.election_winners()
    assert res1.sort() == ['ndp', 'np'].sort()
예제 #4
0
def test_simple_election_win_tie() -> None:
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 1)
    e.update_results('r1', 'lib', 1)
    e.update_results('r1', 'pc', 1)
    e.update_results('r2', 'ndp', 1)
    e.update_results('r2', 'lib', 1)
    assert e.election_winners() == ['ndp', 'lib', 'pc']
예제 #5
0
def test_election_winners_empty() -> None:
    """Test election_winners for a election with no vote"""
    e = Election(date(2000, 2, 8))
    res1 = e.election_winners()
    assert res1.sort() == ['ndp', 'np'].sort()
예제 #6
0
def test_election_winners_1_riding_1_party() -> None:
    """Test election_winners for 1 riding and 1 party"""
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 20)
    res1 = e.election_winners()
    assert res1 == ['ndp']
예제 #7
0
def test_simple_election_win_single_party() -> None:
    e = Election(date(2000, 2, 8))
    e.update_results('r1', 'ndp', 100)
    e.update_results('r2', 'ndp', 100)
    assert e.election_winners() == ['ndp']