def test_list_donors():
    # create a clean one to make sure everything is there.
    sample_db = DonorDB(get_sample_data())
    listing = sample_db.list_donors()

    # hard to test this throughly -- better not to hard code the entire
    # thing. But check for a few aspects -- this will catch the likely
    # errors
    assert listing.startswith("Donor list:\n")
    assert "Jeff Bezos" in listing
    assert "William Gates III" in listing
    assert len(listing.split('\n')) == 5
def test_generate_donor_report():
    sample_db = DonorDB(get_sample_data())
    report = sample_db.generate_donor_report()

    print(report)  # printing so you can see it if it fails
    # this is pretty tough to test
    # these are not great, because they will fail if unimportant parts of the
    # report are changed.
    # but at least you know that code's working now.
    assert report.startswith(
        "Donor Name                | Total Given | Num Gifts | Average Gift")

    assert "Jeff Bezos                  $    877.33           1   $     877.33" in report
#!/usr/bin/env python
"""
Command line interface for mailroom
"""

import sys
import math

from donor_models import Donor, DonorDB, get_sample_data

db = DonorDB(get_sample_data())


def print_donor_report():
    print(db.generate_donor_report())


def send_thank_you():
    while True:
        name = input(
            "Enter a donor's name"
            "(or 'list' to see all donors or 'menu' to exit)> ").strip()
        if name == "list":
            print(db.list_donors())

        elif name == "menu":
            return
        else:
            break
Example #4
0
def test_generate_donor_report():
    sample_db = DonorDB(get_sample_data())
    report = sample_db.generate_donor_report()

    print(report)
Example #5
0
def test_list_donors():
    sample_db = DonorDB(get_sample_data())
    listing = sample_db.list_donors()
    assert listing.startswith("Donor list:\n")
    assert "J Bob" in listing
    assert len(listing.split('\n')) == 5