Esempio n. 1
0
def test_setup_table():
    t = mr.Transactions()
    returnval = t.setup_table()
    assert returnval.startswith("Donor Name")
    assert "Total Given" in returnval
    assert "Num Gifts" in returnval
    assert "Average Gift" in returnval
Esempio n. 2
0
def test_create_transactions():
    name = "Ada Lovelace"
    amt = 345
    d = mr.Donor(name)
    d.add_donation(amt)
    t = mr.Transactions()
    t.add_donor(name, amt)
    assert t.get_donor(name).name == name
Esempio n. 3
0
def test_total_donations():
    name, amt, amt2, amt3 = ("Ada Lovelace", 350, 700, 100)
    d = mr.Donor(name)
    d.add_donation(amt)
    d.add_donation(amt2)
    d.add_donation(amt3)
    t = mr.Transactions()
    t.add_donor(name, amt)
    t.add_donor(name, amt2)
    t.add_donor(name, amt3)
    assert t.total_donations == 1150
Esempio n. 4
0
def test_challenge():
    name, amt = ("Ada Lovelace", 345)
    d = mr.Donor(name)
    d.add_donation(amt)
    name2, amt2, amt3 = ("Marge Simpson", 500, 1000)
    d2 = mr.Donor(name2)
    d2.add_donation(amt2)
    t = mr.Transactions()
    t.add_donor(name, amt)
    t.add_donor(name2, amt2)
    t.add_donor(name2, amt3)
    result = t.challenge(2, 400, 600)
    assert result == 500
Esempio n. 5
0
def test_generate_report_data():
    name, amt = ("Ada Lovelace", 345)
    d = mr.Donor(name)
    d.add_donation(amt)
    name2, amt2, amt3 = ("Marge Simpson", 500, 1000)
    d2 = mr.Donor(name2)
    d2.add_donation(amt2)
    t = mr.Transactions()
    t.add_donor(name, amt)
    t.add_donor(name2, amt2)
    t.add_donor(name2, amt3)
    result = [('Marge Simpson', 1500.0, 2, 750.0),
              ('Ada Lovelace', 345.0, 1, 345.0)]
    print(t.generate_report_data)
    assert t.generate_report_data() == result
Esempio n. 6
0
def test_list_names():
    name = "Ada Lovelace"
    amt = 345
    d = mr.Donor(name)
    d.add_donation(amt)
    name2 = "Marge Simpson"
    amt2 = 500
    d2 = mr.Donor(name2)
    d2.add_donation(amt2)
    t = mr.Transactions()
    t.add_donor(name, amt)
    t.add_donor(name2, amt2)
    result = 'Donor Names:\n' + name + '\n' + name2
    print(t.list_names())
    assert t.list_names() == result
Esempio n. 7
0
def test_new_donor():
    name = "Ada Lovelace"
    amt = 345
    d = mr.Donor(name)
    d.add_donation(amt)
    name2 = "Marge Simpson"
    amt2 = 500
    d2 = mr.Donor(name2)
    d2.add_donation(amt2)
    t = mr.Transactions()
    t.add_donor(name, amt)
    assert t.get_donor(name2) is None
    t.add_donor(name2, amt2)
    assert t.get_donor(name2).name == name2
    assert t.get_donor(name2).most_recent_donation == amt2
Esempio n. 8
0
def test_setup_body():
    name, amt = ("Ada Lovelace", 345)
    d = mr.Donor(name)
    d.add_donation(amt)
    name2, amt2, amt3 = ("Marge Simpson", 500, 1000)
    d2 = mr.Donor(name2)
    d2.add_donation(amt2)
    t = mr.Transactions()
    t.add_donor(name, amt)
    t.add_donor(name2, amt2)
    t.add_donor(name2, amt3)
    returnval = t.setup_body()
    nlines = returnval.count('\n')
    assert name in returnval
    assert name2 in returnval
    assert nlines == 2