Exemple #1
0
def test_donor_initialization():

    proper_donations_list = [Donation(100), Donation(200), Donation(300)]

    d1 = Donor("Bob", proper_donations_list)
    assert d1.donor_name == "Bob"
    assert d1.donations_list == proper_donations_list

    # Check Non proper list is proved
    d2 = Donor("Ted", [Donation(100), 2, "Red"])
    assert d2.donor_name == "Ted"
    assert d2.donations_list == []

    # Check No list is provided
    d3 = Donor("Sam")
    assert d3.donor_name == "Sam"
    assert d3.donations_list == []
Exemple #2
0
def test_donor_add_donation():
    d1 = Donor("Bob", [Donation(100)])

    d1.add_donation(200)
    curr_time = datetime.datetime.now()

    # Check length of list, and attributes of the added donation object
    assert len(d1.donations_list) == 2
    assert d1.donations_list[1].amount == 200
    assert d1.donations_list[1].date == curr_time
Exemple #3
0
def test_donation_attributes():
    donation_1 = Donation(100)
    curr_date = datetime.datetime.now()
    assert donation_1.amount == 100
    assert donation_1.date == curr_date
    assert donation_1.formatted_date() == curr_date.strftime("%m-%d-%y")
Exemple #4
0
def test_donor_print_donations_list():
    d1 = Donor("Bob", [Donation(100), Donation(200), Donation(300)])
    curr_time = datetime.datetime.now()

    assert d1.print_donations_list() == "{} on {} | {} on {} | {} on {} | "\
        .format(100, curr_time, 200, curr_time, 300, curr_time)
Exemple #5
0
def test_donor_average_donation_amount():
    d1 = Donor("Bob", [Donation(100), Donation(200), Donation(300)])
    assert d1.average_donation_amount() == 200
Exemple #6
0
def test_donor_number_of_gifts():
    d1 = Donor("Bob", [Donation(100), Donation(200), Donation(300)])
    assert d1.number_of_gifts() == 3
Exemple #7
0
def test_donor_total_donation():
    d1 = Donor("Bob", [Donation(100), Donation(200), Donation(300)])
    assert d1.total_donation() == 600
Exemple #8
0
def test_donor_send_mail_latest():
    d1 = Donor("Bob", [Donation(100), Donation(200)])
    assert d1.send_mail_latest() == 'dear donor Bob the last donation is 200'