コード例 #1
0
def test_dbdonor_list_donors():
    dbdonor = DonorCollection(get_donordb())
    results = dbdonor.list_donors()

    assert "LeBron James" in results
    assert "Dwyane Wade" in results
    assert "Carmelo Anthony" in results
コード例 #2
0
def test_dbdonor_send_all_donors():
    dbdonor = DonorCollection(get_donordb())
    results = dbdonor.send_all_donors()

    assert results.count("Have a great day!") == 3
    assert "Hi LeBron James" in results
    assert "Hi Dwyane Wade" in results
    assert "Hi Carmelo Anthony" in results
コード例 #3
0
def test_dbdonor_make_report():
    dbdonor = DonorCollection(get_donordb())
    results = dbdonor.make_report()

    assert results.count("\n") == 4
    assert results.startswith("Donor Name") is True
    assert "LeBron James" in results
    assert "Dwyane Wade" in results
    assert "Carmelo Anthony" in results
コード例 #4
0
import tempfile
from donor_models import Donor, DonorCollection, get_donordb
from textwrap import dedent

donor_collection = DonorCollection(get_donordb())


def safe_input(message=""):
    try:
        get_input = input ("=> " + message)
    except KeyboardInterrupt:
        return None
    except EOFError:
        return None
    return get_input

def send_thank_you():
    print("Enter a name:")
    name = safe_input()

    if donor_collection.find_donor(name) is True:
        print(donor_collection.thank_you(name))
    else:
        print("Add a donation amount for {}:".format(name))
        donation_amt = int(input())
        new_donor = Donor(name, [donation_amt])
        donor_collection.add_donor(new_donor)

        print(donor_collection.thank_you(name))

コード例 #5
0
def test_dbdonor_add_donor():
    dbdonor = DonorCollection(get_donordb())
    dbdonor.add_donor(Donor("Jae Kim"))
    find_donor = dbdonor.find_donor("Jae Kim")

    assert find_donor is True
コード例 #6
0
def test_dbdonor_find_donor_false():
    dbdonor = DonorCollection(get_donordb())
    find_donor = dbdonor.find_donor("Jae Kim")

    assert find_donor is False
コード例 #7
0
def test_dbdonor_find_donor_invalid():
    dbdonor = DonorCollection(get_donordb())
    results = dbdonor.find_donor("Invalid Donor")

    assert results is False
コード例 #8
0
def test_dbdonor_find_donor():
    dbdonor = DonorCollection(get_donordb())
    results = dbdonor.find_donor("Dwyane Wade")

    assert results is True