def test_generate_thankyou_letter():
    donor = Donor('Zhen', 'Yang', 230)
    donor.add_donation_amount(100)
    my_str = donor.generate_thankyou_letter().strip()
    assert my_str.startswith('Dear')
    assert my_str.endswith('Zhen')
    assert 'Yang' in my_str # test last name
    assert '100' in my_str # test total donation
Пример #2
0
def send_thankyou_text():
    while True:
        d_name = input(donor_name_prompt).strip()
        valid_name = valid_input(d_name, 2)  # validate the donor name
        if valid_name != -1:  # valid donor name
            amount = input(donoation_amount_prompt).strip()
            valid_amount = valid_input(amount, 3)  # validate the donation
            while valid_amount == -1:  # invalid donation amount
                amount = input(donoation_amount_prompt).strip()
                valid_amount = valid_input(amount, 3)
            # get a new donor object
            donor = Donor(valid_name[0], valid_name[1], valid_amount)
            # update the donor database
            donor = donors_db.update_donors_db(donor)
            # print the thank you letter for current donor
            print(donor.generate_thankyou_letter())
            break