예제 #1
0
def test_create_report(capsys):
    # Test the content from the report as a table using readouterr
    mailroom.create_report()
    captured = capsys.readouterr()
    assert captured.out.startswith(
        "Donor Name          | Total Given |  Num Gifts | Average Gift")
    assert "Warren Buffett        $16217.34        4          $4054.34" in captured.out
def test_create_report(capsys):
    create_report()
    out, err = capsys.readouterr()
    test_string = (
        '-------List of Donors-------\n'
        'Donor Name          Total Donated       # of donations      Average donation    \n'
        '-----------------   -----------------   -----------------   -----------------   \n'
        'Frank Reynolds      $80.00               3                   $26.67               \n'
        'Dee Reynolds        $125.00              2                   $62.50               \n'
        'Dennis Reynolds     $60.00               2                   $30.00               \n'
        'Mac McDonald        $80.00               3                   $26.67               \n'
        'Charlie Kelly       $0.25                1                   $0.25                \n'
    )
    assert out == test_string
예제 #3
0
def test_report_creation():
    mr.donors = get_sample_donors()
    report = mr.create_report()

    assert report.startswith("Donor Name")
    report = report.split("\n")
    assert report[1].startswith("---")
    assert len(report) == 7
예제 #4
0
def test_create_report():
    database = ml.initialize_database()
    lines = ml.create_report(database)
    assert lines[0] == '-----Donation Report-----'
    assert lines[1] == '\n{:<15} | {:>14} | {:>11} | {:>16}'.format('Donor Name', 'Total Donation', '# donations', 'Average Donation')
    assert lines[2] == '-'*66
    assert lines[3] == '{:<15} | ${:>13.2f} | {:^11} | ${:>15.2f}'.format('Jane Adams', 121300.00, 4, 30325.00)
    assert lines[5] == '{:<15} | ${:>13.2f} | {:^11} | ${:>15.2f}'.format('John Smith', 57068.00, 3, 19022.67)
    assert lines[7] == '{:<15} | ${:>13.2f} | {:^11} | ${:>15.2f}'.format('Brett Johnson', 21991.00, 6, 3665.17)
예제 #5
0
def test_create_report():
    donors = {
        'Victor': [100, 20, 30],
        'John': [12],
        'Kevin': [91, 32],
        'Kelly': [5, 21],
        'Matt': [75, 20],
        'Josh': [31, 3],
        'Micah': [120]}

    assert create_report(donors) == 'Donor Name      | Total Given |   Num Gifts  | Average Gift\n'\
                                    '------------------------------------------------------------\n'\
                                    'Victor          $          150              3 $        50.00\n'\
                                    'John            $           12              1 $        12.00\n'\
                                    'Kevin           $          123              2 $        61.50\n'\
                                    'Kelly           $           26              2 $        13.00\n'\
                                    'Matt            $           95              2 $        47.50\n'\
                                    'Josh            $           34              2 $        17.00\n'\
                                    'Micah           $          120              1 $       120.00\n'\
예제 #6
0
def test_create_report():
    assert create_report(donor_table) == donor_table_output
예제 #7
0
def test_create_report():
    report = mailroom.create_report(donors)
    assert report.startswith(
        'Donor                |Total           |Num Gifts  |Average Gift')
예제 #8
0
def test_create_report():
    tb = create_report()
    assert tb.field_names == [
        'Donor Name', 'Total Given', 'Num Gifts', 'Average Gift'
    ]
    assert type(create_report()) is prettytable.PrettyTable