Esempio n. 1
0
def test_party_history_1_election_all_vote() -> None:
    """Test party_wins for 1 election and all vote."""
    e1 = Election(date(2000, 2, 8))
    e1.update_results('r1', 'ndp', 0)
    e1.update_results('r1', 'lib', 0)
    e1.update_results('r1', 'pc', 10)
    e1.update_results('r2', 'lib', 0)
    e1.update_results('r2', 'pc', 200)
    e1.update_results('r3', 'ndp', 0)
    e1.update_results('r3', 'pc', 50)
    j = Jurisdiction('Canada')
    j._history[date(2000, 2, 8)] = e1
    res1 = j.party_history('pc')
    assert res1 == {date(2000, 2, 8): 1.0}
Esempio n. 2
0
def test_party_history_1_election_random_vote() -> None:
    """Test party_wins for 1 election and random vote."""
    e1 = Election(date(2000, 2, 8))
    e1.update_results('r1', 'ndp', 14)
    e1.update_results('r1', 'lib', 22)
    e1.update_results('r1', 'pc', 35)
    e1.update_results('r2', 'lib', 10)
    e1.update_results('r2', 'pc', 20)
    e1.update_results('r3', 'ndp', 199)
    e1.update_results('r3', 'pc', 100)
    j = Jurisdiction('Canada')
    j._history[date(2000, 2, 8)] = e1
    res1 = j.party_history('pc')
    assert res1 == {date(2000, 2, 8): 0.3875}