def test_add_donation_existing():
    '''Tests the add_donor function with existing name in DonorCollections class'''
    data = dm.DonorCollections()
    ty_output = data.add_donor('Silas Skinflint', 500.00)
    assert ty_output == thanks_silas
    assert data.donors == add_donations_db
    data.donors['Silas Skinflint'].pop(3)
def test_add_donor():
    '''Tests the add_donor function with novel name in DonorCollections class'''
    data = dm.DonorCollections()
    ty_output = data.add_donor('John Newberry', 5.00)
    assert ty_output == thanks_newberry
    assert data.donors == newberry_db
    del data.donors['John Newberry']
def test_send_letter():
    '''Tests the send_letter function in the DonorCollections class'''
    data = dm.DonorCollections()
    data.send_letter()
    testpth = pathlib.Path('./')
    for filesel in filelist:
        testdest = testpth.absolute() / filesel
        assert os.path.isfile(testdest) is True
def test_add_donation_existing_lower_case_input():
    '''Tests the add_donor function with existing name in DonorCollections class
    when the user does not capitalize either of the names'''
    data = dm.DonorCollections()
    ty_output = data.add_donor('silas skinflint', 500.00)
    assert ty_output == thanks_silas
    assert data.donors == add_donations_db
    data.donors['Silas Skinflint'].pop(3)
Пример #5
0
def main_switch(response):
    '''Main code logic - Handling input response'''
    try:
        switch_func_dict.get(int(response))()
    except (ValueError, TypeError):
        print('\n----> Invalid Selection: Please input a number 1-4')


switch_func_dict = {
    1: thank_you,
    2: report,
    3: send_letter,
    4: exit_program,
}


def main():
    '''Main code logic'''
    while True:
        response = input(main_prompt)
        main_switch(response)


# Main Code Block --------------------------------------------------------------

if __name__ == '__main__':
    # Guards against running automatically if this script is imported
    data = dm.DonorCollections()
    main()
Пример #6
0
import donor_models as dm
import sys

main_prompt = "\n".join(
    ("", "Welcome to the donors list", "Please choose from below options:",
     "1 - Send a thank you", "2 - Create a report",
     "3 - Send a letter to all the donors", "4 - Quit",
     "Type a number to select >>> "))

ty_prompt = "\n".join(
    ("", "Please type the full name of the donor OR",
     "type 'list' to see a list of donors", "Type input here >>>"))

data = dm.DonorCollections(
    dm.Donor('Scrooge McDuck', [8000.00, 70000.00]),
    dm.Donor('Montgomery Burns', [49.53]),
    dm.Donor('Richie Rich', [1000000.00, 500000.00]),
    dm.Donor('Chet Worthington', [200.00, 44387.63, 10200.00]),
    dm.Donor('Silas Skinflint', [0.25, 1.00, 0.43]))

# Functions
# 1 - Thank you


def thank_you():
    ''' Main thank_you logic'''
    tyname = input(ty_prompt)
    list_invoked(tyname)
    amt = input("Please enter the donation amount >>>")
    amt_logic(tyname, amt)

def test_report2():
    '''Validates that report still functions from previous tests'''
    data = dm.DonorCollections()
    report = data.make_report()
    assert report == expected_report
def test_report():
    '''Tests the report function in DonorCollections class'''
    data = dm.DonorCollections()
    report = data.make_report()
    assert report == expected_report