Ejemplo n.º 1
0
def print_thank_you():
    """ Prompts user for donor name and amount and prints thank
    you note to the console. Donation amount must be numerical."""
    name = get_donor()
    donation = get_donation()
    donor = Donor(name, donation)
    DONORS.update(donor)
    print()
    try:
        print(donor.thank())
    except ValueError:
        print(
            'Cannot write thank you for ' +
            '{0} because {0} has not given a donation'.format(donor.name))
Ejemplo n.º 2
0
def test_donor_thank_you():
    d1 = Donor('Benedict Cumberbatch', 200000.0)
    assert (
        d1.thank(all_donations=True) ==
        'Dear Benedict Cumberbatch,\nThank you for your generous gift of ' +
        '$200,000.00. Your donation will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')
    assert (
        d1.thank() ==
        'Dear Benedict Cumberbatch,\nThank you for your generous gift of ' +
        '$200,000.00. Your donation will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')

    d2 = Donor('Elon Musk', 10000.0, 150000.0, 100000.0)
    assert (
        d2.thank(all_donations=True) ==
        'Dear Elon Musk,\nThank you for your generous gifts of ' +
        '$10,000.00, $150,000.00 and $100,000.00. Your donations, totalling an '
        + 'incredible $260,000.00, will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')
    assert (
        d2.thank() == 'Dear Elon Musk,\nThank you for your generous gift of ' +
        '$100,000.00. Your donation will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')

    d3 = Donor('Dad', 20.0, 5.0)
    assert (
        d3.thank(all_donations=True) ==
        'Dear Dad,\nThank you for your generous gifts of ' +
        '$20.00 and $5.00. Your donations, totalling $25.00, will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')
    assert (
        d3.thank() == 'Dear Dad,\nThank you for your generous gift of ' +
        '$5.00. Your donation will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')

    d4 = Donor('Donald Trump', 2.81)
    assert (
        d4.thank(all_donations=True) ==
        'Dear Donald Trump,\nThank you for your generous gift of ' +
        '$2.81. Your donation will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')
    assert (
        d4.thank() ==
        'Dear Donald Trump,\nThank you for your generous gift of ' +
        '$2.81. Your donation will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')

    d5 = Donor('Billy Neighbor', .54, .01, .25)
    assert (
        d5.thank(all_donations=True) ==
        'Dear Billy Neighbor,\nThank you for your generous gifts of ' +
        '$0.54, $0.01 and $0.25. Your donations, totalling $0.80, will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')
    assert (
        d5.thank() ==
        'Dear Billy Neighbor,\nThank you for your generous gift of ' +
        '$0.25. Your donation will ' +
        'go towards feeding homeless kittens in Seattle. ' +
        'From the bottom of our hearts, we at Miuvenile Care thank you.\n\n' +
        'Regards,\nBungelina Bigglesnorf\nChairwoman, Miuvenile Care')