def test_Charity_2(): c = Charity("Red Cross") c.AddDonor("Bill Gates", [10000, 5000.00, 42000.00]) c.AddDonor("Jeff Bezos", [1500.00]) c.AddDonor("Paul Allen", [50000, 4500.00]) DonorList = c.GetDonorList() assert DonorList == "------------------------------\n" + \ "Bill Gates\nJeff Bezos\nPaul Allen\n" + \ "------------------------------\n"
def test_Charity_3(): c = Charity("Red Cross") c.AddDonor("Bill Gates", [10000, 5000.00, 42000.00]) c.AddDonor("Jeff Bezos", [1500.00]) c.AddDonor("Paul Allen", [50000, 4500.00]) Report = "-----------------------------------------------------------\n" + \ "Red Cross\n" + \ "-----------------------------------------------------------\n" + \ "Donor Name | Total Given | Num Gifts | Average Gift\n" + \ "-----------------------------------------------------------\n" + \ "Bill Gates $ 57000.00 3 $ 19000.00\n" + \ "Paul Allen $ 54500.00 2 $ 27250.00\n" + \ "Jeff Bezos $ 1500.00 1 $ 1500.00\n" assert c.GetReport() == Report
def test_Charity_1(): c = Charity("Red Cross") c.AddDonor("Bill Gates", [10000, 5000.00, 42000.00]) c.AddDonor("Jeff Bezos", [1500.00]) c.AddDonor("Paul Allen", [50000]) assert c.CharityName == "Red Cross" assert "Bill Gates" in c.DonorList c.DonorList["Paul Allen"].AddDonation(4500.00) assert c.DonorList["Paul Allen"].Donations == [50000, 4500.00] DonorInfo = list() for donor in c.DonorList.items(): DonorInfo.append( f"{donor[1].DonorName}: {donor[1].TotalDonation():.2f}") assert ",".join(DonorInfo) == "Bill Gates: 57000.00," + \ "Jeff Bezos: 1500.00," + \ "Paul Allen: 54500.00"
def main(): input = "".join(open("mailroominput.txt", "r").readlines()) sys.stdin = io.StringIO(input) local_charity = Charity('Local Charity') local_charity.AddDonor('William Gates, III') local_charity.Donors['William Gates, III'].AddDonation(60000.00) local_charity.Donors['William Gates, III'].AddDonation(50000.00) local_charity.AddDonor('Mark Zuckerberg') local_charity.Donors['Mark Zuckerberg'].AddDonation(10000.00) local_charity.Donors['Mark Zuckerberg'].AddDonation(60000.00) local_charity.Donors['Mark Zuckerberg'].AddDonation(396.10) local_charity.AddDonor('Jeff Bezos') local_charity.Donors['Jeff Bezos'].AddDonation(877.33) user_input(local_charity)
def main(): # test Charity creation test_charity = Charity('local charity') assert (test_charity.CharityName == 'local charity') assert (test_charity.Donors == {}) # test AddDonor from Charity test_name = 'Kyle Clark' test_charity.AddDonor(test_name) assert (test_charity.Donors[test_name].Donations == []) # test functions of Donor amount = 1000.56 test_send_thank_you(test_charity, test_name, amount) # test send all thank yous of Charity test_send_all_thank_yous(test_charity)
folder = create_folder(folder_name) for name in Charity.DonorList: Charity.DonorList[name].TextFile(folder[0], folder[1]) def quit(): print("Thank you for using Mailroom.\nExiting Program\n") main_prompt = ("\nYou are in the main menu, Choose an action to perform:\n" + "1: Add a Donation.\n" + "2: Create a Report.\n" + "3: Send Thank You letter to a single donor.\n" "4: Send Thank You letters to all donors.\n" + "q: Quit\n") main_dispatch = { "1": add_donation, "2": create_report, "3": send_thank_you, "4": send_thank_you_all, "q": quit } if __name__ == '__main__': Charity = Charity("Red Cross") Charity.AddDonor("Paul Allen", [250.00, 433.49, 413.45]) Charity.AddDonor("Mark Zuckerberg", [3422.12, 5877.13, 4323.65]) Charity.AddDonor("Jeff Bezos", [877.33]) Charity.AddDonor("William Gates, III", [45523.16, 212333.12]) main_menu(main_dispatch)
brent_golden = Donor("Brent Golden", [{'12_13_2019': 750.00}, {'12_12_2019': 250.00}, {'12_11_2019': 250.00}]) regan_kirk = Donor("Regan Kirk", [{'12_10_2019': 300.00}, {'12_09_2019': 300.00}]) shiloh_gardner = Donor("Shiloh Gardner", [{'12_08_2019': 100.00}, {'12_07_2019': 100.00}, {'12_06_2019': 100.00}, {'12_05_2019': 100.00}]) alanna_newton = Donor("Alanna Newton", [{'12_04_2019': 200.00}, {'12_03_2019': 50.00}, {'12_02_2019': 100.00}, {'12_01_2019': 75.00}]) marcel_torres = Donor("Marcel Torres", [{'11_30_2019': 25.00}, {'11_29_2019': 25.00}, {'11_28_2019': 25.00}, {'11_27_2019': 25.00}, {'11_26_2019': 25.00}, {'11_25_2019': 25.00}]) help_for_students = Charity("Help for Students") help_for_students.add_donor(brent_golden) help_for_students.add_donor(regan_kirk) help_for_students.add_donor(shiloh_gardner) help_for_students.add_donor(alanna_newton) help_for_students.add_donor(marcel_torres) # ---------- Main menu with Charity object passed in ----------- # menu_selection(MAIN_PROMPT, main_switch, help_for_students)