def test_donor_collection_create_report():
    '''
    Tests creating the report for the given donors
    :return: nothing
    '''

    expected_donor_1 = "Jinee"
    d_jinee = Donor(expected_donor_1)
    d_jinee.add_donation(100.00)

    expected_donor_2 = "Brother"
    d_brother = Donor("Brother")
    d_brother.add_donation(200.00)

    expected_donor_3 = "Mom"
    d_mom = Donor(expected_donor_3)
    d_mom.add_donation(300.00)

    dc = DonorCollection()
    dc.add_donor(d_jinee, d_brother, d_mom)

    report = dc.create_report()

    assert (expected_donor_1 in report)
    assert (expected_donor_2 in report)
    assert (expected_donor_3 in report)
def test_create_report():
    donors = DonorCollection()
    donors.add(Donor('Tester 01', [1.00, 2.00]))
    expected = ("\nDonor Name                | Total Given | Num Gifts | Average Gift\n"
                "------------------------------------------------------------------\n"
                "Tester 01                  $       3.00           2  $       1.50\n")
    actual = donors.create_report()
    print(actual)
    assert actual == expected
def test_create_report():
    charity = DonorCollection()
    charity.create_donor("Elroy Jetson")
    charity.donors_dict["Elroy Jetson"].add_donation(100)
    charity.donors_dict["Elroy Jetson"].add_donation(100)

    charity.create_donor("Astro")
    charity.donors_dict["Astro"].add_donation(300)

    assert charity.create_report() == [["Astro", 300, 1, 300],
                                       ["Elroy Jetson", 200, 2, 100]]
예제 #4
0
def test_create_report():
    d1 = Donor('Nam Vo', [100, 50.0])
    d2 = Donor('Vu Vo', [80])
    d3 = Donor('Jasmine Vo', [40, 50.0, 20.3])
    donor_dict = {
        id(d1): d1,
        id(d2): d2,
        id(d3): d3,
    }
    dl = DonorCollection(list(donor_dict.keys()))
    print(f"dl = {dl}")
    content = dl.create_report(donor_dict)
    print(f"content = {content}")
예제 #5
0
def test_create_report():
    test_data = initialize_donors()
    dc = DonorCollection()
    dc.add_donor(*test_data)
    test_string = (
        '\nDonor Name        | Total Given |  '
        'Num Gifts  | Average Gift\n'
        '--------------------------------------------------------------\n'
        'George Washington  $    3,587.00            3  $    1,195.67\n'
        'Theodore Roosevelt $    1,987.00            3  $      662.33\n'
        'Dwight Eisenhower  $    1,987.00            2  $      993.50\n'
        'Abraham Lincoln    $    1,877.00            2  $      938.50\n'
        'James Madison      $    1,813.00            2  $      906.50\n')
    assert dc.create_report() == test_string
예제 #6
0
def test_create_report():
    """ Use the default donor_list to verify the method creates a list of donors containing:
    donor name, total donation amount, number of donation, average donation """
    donors = Donors()
    report_data = donors.create_report()

    assert ['Lionel Messi', 100, 1, 100.0] in report_data
    assert ['Cristiano Ronaldo', 14475, 3, 4825.0] in report_data
    assert ['Gianluigi Buffon', 1002500.5, 2, 501250.25] in report_data
    assert ['Neymar', 405.24, 4, 101.31] in report_data
    assert ['Paolo Maldini', 24039.95, 4, 6009.9875] in report_data

    # The list is sorted by total donation amount so check the first and last items are correct
    assert "Gianluigi Buffon" in report_data[0]
    assert "Lionel Messi" in report_data[4]
예제 #7
0
def test_create_report():
    donor_collection = DC()
    donor_collection.add_donor("Jimmy Johns", 50)
    report = donor_collection.create_report()
    assert report[
        0] == 'Donor Name                | Total Given | Num Gifts | Average Gift'
    assert report[
        1] == '------------------------------------------------------------------'
    assert report[
        2] == 'Jack Ma                    $    2000.00           1  $     2000.00'
    assert report[
        3] == 'Warren Buffet              $    1100.00           2  $      550.00'
    assert report[
        4] == 'Bill Gates                 $     600.00           2  $      300.00'
    assert report[
        5] == 'Tim Cook                   $     300.00           1  $      300.00'
    assert report[
        6] == 'Jeff Bezos                 $      51.00           2  $       25.50'
    assert report[
        7] == 'Jimmy Johns                $      50.00           1  $       50.00'