def test_update_donor(): db = DB(DONORS) db.update_donor('Margare Atwood', 400) assert db.donors == { 'Margare Atwood': [300, 555, 400], 'Fred Armisen': [240, 422, 1000], 'Heinz the Baron Krauss von Espy': [1500, 2300] }
#1/usr/bin/env python3 import sys from donor_models import DB, Donor donors_db = DB() def menu_selection(prompt, dispatch_dict): while True: response = input(prompt) if dispatch_dict[response]() == 'exit menu': break def quit(): print('Quitting this menu now') return'exit menu' #------------------------------------------------------ def thank_you(): menu_selection(sub_prompt, sub_dispatch) def find_donor(): name = input('Enter a donor fullname or add a new one:')
def test_list_donors(): db = DB(DONORS) list = db.list_donors assert list == 'Margare Atwood\nFred Armisen\nHeinz the Baron Krauss von Espy\nPaul Allen'
def test_add_donor(): d = DB(DONORS) donor = d.add_donor('Paul Allen', 5000) assert 'Paul Allen' in DONORS assert DONORS['Paul Allen'] == 5000
def test_find_donor(): db = DB(DONORS) assert db.find_donor('Margare Atwood') == 'Margare Atwood' assert db.find_donor('Paul Allen') == None
def test_empty_donors(): db = DB() assert db.donors == {}
def test_donors(): db = DB(DONORS) assert db.donors == DONORS