def create_default_db(self): db = mailroom_data.DonorCapture() d1 = mailroom_data.Donor("Bill", "Gates") d1.add_donation(50) d2 = mailroom_data.Donor("Paul", "Allen") d2.add_donation(30) d2.add_donation(40) d3 = mailroom_data.Donor("Jeff", "Bezos") d3.add_donation(80) d3.add_donation(90) d3.add_donation(100) db.add_donor(d1) db.add_donor(d2) db.add_donor(d3) return db
def test_donor(self): name_tuple = ("Test", "This") donor = mailroom_data.Donor(name_tuple[0], name_tuple[1]) self.assertEqual("Test This", donor.get_name()) self.assertEqual(name_tuple, donor.get_key()) donor.add_donation(50) self.assertEqual([50], donor.get_donations()) donor.add_donation(25) self.assertEqual([50, 25], donor.get_donations())
def test_donor_collection(self): donors = mailroom_data.DonorCapture() d1 = mailroom_data.Donor("Test", "This") d1.add_donation(50) d1.add_donation(25) d2 = mailroom_data.Donor("This", "Test") d2.add_donation(150) d2.add_donation(125) donors.add_donor(d1) donors.add_donor(d2) d_names = [d.get_name() for d in donors.get_donors()] self.assertIn(d1.get_name(), d_names) self.assertIn(d2.get_name(), d_names) for d in donors.get_donors(): if d.get_name() == d1.get_name(): self.assertEqual(d1.get_donations(), d.get_donations()) elif d.get_name() == d2.get_name(): self.assertEqual(d2.get_donations(), d.get_donations()) else: self.fail("Unable to find: 'name'".format(d.get_name())) donors.add_donation("Test", "This", 10) for d in donors.get_donors(): if d.get_name() == d1.get_name(): self.assertEqual([50, 25, 10], d.get_donations())
def draw_main_menu(): """Main menu presentation""" print("\n".join(main_menu_list)) def get_main_menu_input(): """Main menu user input""" user_input = input(":") user_input = user_input.lower().strip() return user_input if __name__ == "__main__": db = mailroom_data.DonorCapture() d1 = mailroom_data.Donor("Bill", "Gates") d1.add_donation(150) d2 = mailroom_data.Donor("Paul", "Allen") d2.add_donation(90) d2.add_donation(1000) d3 = mailroom_data.Donor("Jeff", "Bezos") d3.add_donation(47) d3.add_donation(340) d3.add_donation(2001) db.add_donor(d1) db.add_donor(d2) db.add_donor(d3) running = True while running: draw_main_menu() user_input = get_main_menu_input()