def test_save(): file = "test_profiles.dat" a = Donor("Sting", 300.00) x = Donors(a) x.new_donor("Cher", 400.00) x.new_donor("James Bond", 500.00) x.save(file) assert os.path.isfile(file) == True
def test_thank_you_files1(): a = Donor("Sting", 300.00) x = Donors(a) x.new_donor("Cher", 400.00) x.new_donor("James Bond", 500.00) x.thank_yous() assert os.path.isfile("sting.txt") == True assert os.path.isfile("cher.txt") == True assert os.path.isfile("james_bond.txt") == True
def test_load1(): file = "test_no_profiles.dat" file2 = "does_not_exist.txt" x = Donors() x.save(file) x.load(file) assert x.profiles == [] x.load(file2) assert x.profiles == []
def test_edit_a_donor1(): a = Donor("Sting", 300.00) x = Donors(a) x.new_donor("Cher", 400.00) x.new_donor("Bond James", 500.00) p = x.find_donor("Bond James") p.person = "James Bond" assert str(x) =="\
def test_edit_a_donation2(): a = Donor("Sting", 300.00) x = Donors(a) x.new_donor("Cher", 400.00) x.new_donor("Bond James", 500.00) p = x.find_donor("Bond James") p.change_donation(1, 200) assert str(x) =="\
def test_thank_you_files2(): a = Donor("test1", 300.00) x = Donors(a) x.new_donor("test2", 400.00) x.thank_yous("test1") assert os.path.isfile("test1.txt") == True assert os.path.isfile("test2.txt") == False
def test_str_donors(): a = Donor("Sting", 100.00) x = Donors(a) x.new_donor("Cher", 200.00) x.new_donor("James Bond", 300.00) print(str(x)) assert str(x) =="\
#Change Log: (Who, When, What) #Brent Kieszling, 2021-Jan-25, created file #-------------------------------------------# from donor_modles import Donor, Donors #DATA--------------------------------------- main_menu = "Main Menu\n\n[1] Write a thank you letter.\n[2] Display current donor rankings.\ \n[3] Write thank you letters for all donors.\n[4] Exit program.\n" ty_menu = "Thank You Menu\n\n[1] Create thank you for existing donor.\n[2] Create thank you for new donor.\n\ [3] View and edit donor information.\n[4] Return to main menu.\n" save_file = "donor_profiles.dat" #PROCESS------------------------------------ donor_history = Donors() donor_history.load(save_file) def menu_selection(menu, dispatch): """Navigate a menu. Args: menu(str): Display menu dispatch(dict): Dictionary controlling menu options """ while True: response = input(menu) try: response = int(response) except ValueError:
def test_load3(): file = "test_profiles_3.dat" a = Donor("Sting", 300.00) x = Donors(a) x.new_donor("Cher", 400.00) x.new_donor("James Bond", 500.00) x.save(file) b = Donor("Michael Bolton", 5000.00) z = Donors(b) z.load(file) print(x.profiles) print(z.profiles) assert str(x.profiles) == str(z.profiles)
def test_load2(): file = "test_profiles_2.dat" a = Donor("Sting", 300.00) x = Donors(a) x.new_donor("Cher", 400.00) x.new_donor("James Bond", 500.00) x.save(file) z = Donors() z.load(file) print(x.profiles) print(z.profiles) assert str(x.profiles) == str(z.profiles)
def test_new_donor(): x = Donors() a = Donor("Sting", 500.00) x.new_donor("Sting", 500.00) assert repr(x.find_donor("Sting")) == repr(a)
def test_find_donor2(): a = Donor("Scrooge McDuck", 100.11) z = Donors(a) with pytest.raises(IndexError): z.find_donor("Scrooge")
def test_find_donor1(): a = Donor("Scrooge McDuck", 100.11) z = Donors(a) assert z.find_donor("Scrooge McDuck") == a
def test_donors_init(): a = Donor("Scrooge McDuck", 100.11) x = Donors() z = Donors(a)