def test_names_only_list():
    d = mailroom.Donor("Angela", [245])
    c = mailroom.Donor("Bob", [34, 22])
    e = mailroom.Donor("Adam", [34, 22])
    ab = mailroom.DonorList([d, c, e])
    names_only_list = ab.names_only_list()
    assert names_only_list == ['Angela', 'Bob', 'Adam']
def test_donor_list_add_donor():
    d = mailroom.Donor("Angela", [245])
    c = mailroom.Donor("Bob", [34, 22])
    ab = mailroom.DonorList([d, c])
    e = mailroom.Donor("Adam", [34, 22])
    ab.add_donor_list(e)
    assert ab.donors == [d, c, e]
def test_find_donor():
    d = mailroom.Donor("Angela", [245])
    c = mailroom.Donor("Bob", [34, 22])
    e = mailroom.Donor("Adam", [34, 22])
    ab = mailroom.DonorList([d, c, e])
    b = ab.find_donor_history("Bob")
    assert b.name == c.name
    assert b.donation == c.donation
def test_match_by_donation_factor():

    a = mailroom.Donor('Toni Orlando', [150.00, 200.00, 100.00])
    b = mailroom.Donor('Amanda Clark', [1800.00])
    c = mailroom.Donor('Robin Hood', [1234.56, 4500.34, 765.28])
    d = mailroom.Donor('Gina Travis', [523.10, 75.00])
    e = mailroom.Donor('Mark Johnson', [850.00, 20.14])
    ab = mailroom.DonorList([a, b, c, d, e])
    cd = ab.match_by_donation_factor(3, 50, 900)
    assert cd[0].donation == list(map(lambda x: x * 3, a.donation))
    assert cd[1].donation == []
    assert cd[2].donation == [765.28 * 3]
    assert cd[3].donation == list(map(lambda x: x * 3, d.donation))
    assert cd[4].donation == [850.00 * 3]
def test_donation_stats():
    donation_list = [75, 22, 34]
    d = mailroom.Donor("Angela", donation_list)
    assert d.total_donation_amount() == 75 + 22 + 34
    assert d.donation_occurrences() == 3
    assert d.average_total_donor_amount() == (75 + 22 + 34) / 3
    assert d.stats() == [75 + 22 + 34, 3, (75 + 22 + 34) / 3]
def test_Donor_init():
    d = mailroom.Donor("Angela", [245])
    assert d.name == "Angela"
    assert d.donation == [245]
def test_donation_addition_negative():
    d = mailroom.Donor("Angela", 55)
    with pytest.raises(ValueError):
        d.add_donation(-77)
def test_set_name():
    d = mailroom.Donor("Angela", 55)
    d.name = "Bob"
    assert d.name == "Bob"
    d.name = 34
    assert d.name == "34"
def test_donation_addition_int():
    d = mailroom.Donor("Angela", 55)
    d.add_donation(77)
    assert d.donation == [55, 77]
def test_donation_addition():
    d = mailroom.Donor("Angela", [245])
    d.add_donation(77)
    assert d.donation == [245, 77]
def test_donor_init_donation_null():
    d = mailroom.Donor('', [44])
    assert d.name == 'Anonymous'
def test_Donor_init_int():
    d = mailroom.Donor("Angela", 33)
    assert d.donation == [33]
 def setUp(self):
     mail.DonorInfo.donor_list = [
         mail.Donor("Test", "Subject", [1, 2, 3, 4, 5])
     ]