Example #1
0
def test_fill_participant_dictionary():
    """Make sure the output formatted dictionary has the right info."""
    my_participant = Participant(fake_participant_conf)
    my_participant._total_raised = 400
    my_participant._average_donation = 100
    my_participant._goal = 1000
    my_participant._fill_participant_dictionary()
    assert my_participant._participant_formatted_output[
        "totalRaised"] == "$400.00"
    assert my_participant._participant_formatted_output[
        "averageDonation"] == "$100.00"
    assert my_participant._participant_formatted_output["goal"] == "$1,000.00"
Example #2
0
def test_format_participant_info_for_output():
    """Make sure the right values are grabbed from the participant properties."""
    my_participant = Participant(fake_participant_conf)
    my_participant._total_raised = 400
    my_participant._average_donation = 100
    my_participant._goal = 1000
    assert my_participant._format_participant_info_for_output(
        my_participant.total_raised) == "$400.00"
    assert my_participant._format_participant_info_for_output(
        my_participant.average_donation) == "$100.00"
    assert my_participant._format_participant_info_for_output(
        my_participant.goal) == "$1,000.00"
Example #3
0
def test_run():
    my_participant = Participant(fake_participant_conf)
    assert my_participant.number_of_donations == 0
    assert my_participant._first_run
    my_participant._goal = 500  # needed to make below run - will probably be fixed with better tests in future
    my_participant.run()
    fake_participant_for_run.update_participant_attributes.assert_called_once()
    fake_participant_for_run.output_participant_data.assert_called_once()
    fake_participant_for_run.update_donation_data.assert_called_once()
    fake_participant_for_run.output_donation_data.assert_called_once()
    fake_participant_for_run.update_donor_data.assert_called_once()
    fake_participant_for_run.my_team.team_run.assert_called_once()
    assert my_participant._first_run is False
    my_participant.run()
    assert fake_participant_for_run.update_participant_attributes.call_count == 2
    assert fake_participant_for_run.output_participant_data.call_count == 2
    fake_participant_for_run.update_donation_data.assert_called_once()
    fake_participant_for_run.output_donation_data.assert_called_once()
    fake_participant_for_run.update_donor_data.assert_called_once()
    assert fake_participant_for_run.my_team.team_run.call_count == 2