def test_create_report():
    c = DonorCollection.donorDict(donor_data.donors)
    report = c.create_report()
    assert report[3].startswith('Ned Flanders')
    assert report[4].startswith('Kent Brockman')
    assert report[5].startswith('Barney Gumble')
    assert report[6].startswith('Homer Simpson')
    assert report[7].startswith('Charles Burns')
def test_letters_all():
    c = DonorCollection.donorDict(donor_data.donors)
    c.letters_all()
    date = datetime.date.today().isoformat()
    assert all([
        os.path.exists(name.replace(' ', '_') + f'_{date}' + '.txt')
        for name in c.donor_names
    ])
def test_get_donor_names():
    """Test getting donor names from DonorCollection"""
    # Discovered during calling donor_data.donors a second time that the dictionary lists were being mutated.
    # Add copy method to the lists in the values of dictionary to ensure user input lists are not modified.
    print(donor_data.donors)
    c = DonorCollection.donorDict(donor_data.donors)
    assert 'Homer Simpson' in c.donor_names
    assert 'Charles Burns' in c.donor_names
    assert 'Kent Brockman' in c.donor_names
    assert 'Ned Flanders' in c.donor_names
    assert 'Barney Gumble' in c.donor_names
def test_donorcollection_donordict():
    print(donor_data.donors)
    c = DonorCollection.donorDict(donor_data.donors)
    print(c.donors)
    assert isinstance(c.donors['Homer Simpson'], Donor)
    assert isinstance(c.donors['Charles Burns'], Donor)
Esempio n. 5
0
            #return int(response), enumerate_actions[int(response)]
            return i, a
        except (ValueError, KeyError) as e:
            response = input(
                f'Select a number between 1 and {len(main_actions)}: ')


#
# Main Action (Dictionary Switch
#
main_actions = {
    'Send thank you to single donor': send_thanks,
    'Create report': create_report,
    'Send letters to all donors': letters_all,
    'Quit': quit_program,
}

#
# Data Set
#

if __name__ == '__main__':
    #Intialize the donor data
    donors = DonorCollection.donorDict(donor_data.donors)

    # Begin the script by asking the user what they want to do
    # program will continue to loop until the user selects the Quit option
    while True:
        resp_num, resp_str = prompt_actions()
        main_actions.get(resp_str)()