Exemplo 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
Exemplo 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
Exemplo n.º 3
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)]
    assert t.generate_report_data() == result
Exemplo n.º 4
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
Exemplo n.º 5
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
Exemplo n.º 6
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