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
Esempio n. 2
0
def challenge_project(db, above=0, below=0, multiplier=1):
    """Donation multiplier"""
    new_db = mailroom_data.DonorCapture()
    for donor in db.get_donors():
        if above > 0:
            donations_list = filter(lambda d: d > above, donor.get_donations())
        elif below > 0:
            donations_list = filter(lambda d: d < below, donor.get_donations())
        else:
            donations_list = donor.get_donations()
        for donation in map(lambda d: d * multiplier, donations_list):
            name = donor.get_key()
            new_db.add_donation(name[0], name[1], donation)
    return_list = list()
    return_list.append("\nPrevious donor list:")
    return_list.append(create_report(db))
    return_list.append("\nProjected donor list:")
    return_list.append(create_report(new_db))
    return_list.append('\n')
    return '\n'.join(return_list)
 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()