示例#1
0
def test_thankyou_note():
    M_S = Donor("Morgan Stanley")
    M_S.donations = [10]
    M_S.append(7.50)

    assert M_S.thank_you(
    ) == "Thanks Morgan Stanley for your $17.50 in donations."
示例#2
0
def receiver():
    '''For processing user interface for creating a single thank you'''
    viable_ans = False

    while viable_ans == False:
        new_vs_ex = input("Donor Name, List, Quit? ")
        name = new_vs_ex
        if new_vs_ex.lower() == "quit":
            name = "quit"
            viable_ans = True
            break
        elif new_vs_ex.lower() == "list":
            don_col.print_don_list()
            don_num = int(input("Select # above: "))
            try:
                name = don_col.donors[don_num-1]
            except IndexError:
                print("Must select a value from the list!")
                name = "quit"

        if new_vs_ex.lower() != "quit":
            donation_value = input("What is the value of the donation? ")            
            if donation_value.lower() == "quit":
                name = "quit"
                viable_ans = True
            elif isinstance(donation_value, float):
                viable_ans = True
            elif float(donation_value) <= 0:
                print("All donations must be greater than 0")
                name = "quit"
                viable_ans = False
        
        if name in don_col.donors:
            try:
                name.append(float(donation_value))
                viable_ans = True
            except ValueError:
                print("Donation must be whole number or decimal value")
                name = "quit"
        elif don_col.donor_validation(name):
            confirmation = input("Confirm donor name:")
            if confirmation == name:
                name = Donor(name)
                name.append(float(donation_value))
                don_col.append(name)
                viable_ans = True
            else:
                print("Names not the same please restart")
                name = "quit"
        elif name != "quit":
            name = Donor(name)
            name.append(float(donation_value))
            don_col.append(name)
            viable_ans = True
    
    if name != "quit":
        try:
            print("\n" + name.thank_you() + "\n")
        except AttributeError:
            name = "quit"

    return name