Esempio n. 1
0
def test_donor_init():
    d = Donor('Dave Grohl')
    assert d.name == 'Dave Grohl'
    assert d.donations == []
    d.add_donation(10000)
    d.add_donation(20000)
    assert d.total_donations == 30000
def test_donor_init():
    d = Donor('William Gates III')
    assert d.name == 'William Gates III'
    assert d.donations == []
    d.add_donation(10000)
    d.add_donation(20000)
    assert d.total_donations == 30000
Esempio n. 3
0
def thank_you(d):
    """
    This method was created to utilize the dictionary (options) in the program
    main flow
    """
    name = name_prompt()
    while name.lower() == "list":
        display_list(d)
        name = name_prompt()
    donation = donation_prompt(name)
    donor = Donor(name, donation)
    print(donor.thank_you())
    d.add_donation(name, donation)
def test_Mailroom():
    donor1 = Donor('Ghassan', [100, 200, 300])
    donor2 = Donor('Miles', [52, 241, 736])
    donor3 = Donor('Jack', [425, 100, 245])
    mr = Mailroom([donor1, donor2, donor3])
    assert mr.donors == [donor1, donor2, donor3]
    donor4 = Donor('Tony', [55, 342, 765])
    mr.add_donor(donor4)
    assert mr.donors == [donor1, donor2, donor3, donor4]
    assert mr.get_donor('Miles') == donor2
    assert mr.send_thankyou(
        'Ghassan') == 'Thank you {} for your generous donation of {}'.format(
            mr.get_donor('Ghassan').name,
            mr.get_donor('Ghassan').total_donations)
    assert mr.all_donors() == ['Ghassan', 'Miles', 'Jack', 'Tony']
    assert mr.list_donors() == '\n'.join(['Ghassan', 'Miles', 'Jack', 'Tony'])
Esempio n. 5
0
def thankyou_procedure():
    donor_name = set_donor_name()
    if donor_name.lower() == 'list':
        all_donors = mr.list_donors()
        print(all_donors)
    elif donor_name in mr.all_donors():
        thx = mr.send_thankyou(donor_name)
        print(thx)
    else:
        mr.add_donor(Donor(donor_name, []))
Esempio n. 6
0
def test_donors():
    d = Donor('Steve Dave')
    d.add_donation(30000)

    DonorData.add_donor(d)
    assert testdb.get_total_from_donor('Steve Dave') == 30000

    e = Donor('Steve Dave')
    e.add_donation(40000)
    e.add_donation(50000)

    db.num_donors == 2
def test_donorDB():
    d = Donor('Paul Allen')
    d.add_donations(6000)
    d2 = Donor('Shigeru Miamoto')
    d2.add_donations(9000)
    db = DonorDB()
    db.add_donor(d)
    db.add_donor(d2)
    assert db.database_dict == {
        'Paul Allen': [6000],
        'Shigeru Miamoto': [9000]
    }
Esempio n. 8
0
 def test_add_donation(self):
     test_obj = Donor("test")
     self.assertEqual(test_obj.latest_donation, None)
     with self.assertRaises(ValueError):
         test_obj.add_donation(-10)
     test_obj.add_donation(10)
     self.assertEqual(test_obj.latest_donation, 10)
Esempio n. 9
0
def check_thankyou(
        name, amount):  # Check to see if name is on the current donor list
    check = 0
    if name in donors.keys(
    ):  # If donor name is on the 'list', add donation amount to value
        donors.get(name).append(float(amount))
        check = 1  # Update to 'remember' there was a donor name in the list
    if check == 0:  # Run when a donor name was not on the list, add donor name and amount
        donor = Donor(name, amount)
        name.add_donation(float(amount))
        # donors[name] = [float(amount)]
    pair = [name, amount]
    return pair
def test_donors():
    d = Donor('Paul Allen')
    d.add_donation(30000)

    db = DonorDB()
    db.add_donor(d)
    assert db.get_total_from_donor('Paul Allen') == 30000

    e = Donor('Jeff Bezos')
    e.add_donation(40000)
    e.add_donation(50000)

    db.add_donor(e)

    assert db.get_total_from_donor('Jeff Bezos') == 90000
    assert db.num_donors == 2

    assert print(db) and False
def test_donors():
    d = Donor('Paul Allen')
    d.add_donation(600)
    db = DonorDB()
    db.add_donor(d)
    assert db.get_total_from_donor('Paul Allen') == 600
    e = Donor('Jeff Bezos')
    e.add_donation(100)
    e.add_donation(200)
    db.add_donor(e)
    assert db.get_total_from_donor('Jeff Bezos') == 300
    assert db.count_donors == 2
    assert db.count_donations == 3
    assert db.total_donations == 900
    assert db.average_total_donation == 450
    assert db.average_single_donation == 300
    test_list = db.donor_list()
    assert test_list.startswith('Paul Allen')
    assert test_list.endswith('Jeff Bezos')
Esempio n. 12
0
def test_class():
    donor = Donor("Class", [100, 200, 300])
    print(donor)
Esempio n. 13
0
def test_init():
    Donor('John Doe', 450)
    assert True
Esempio n. 14
0
def test_new_donation():
    d = Donor('John Doe', 450)
    d.new_donation(50)
    d.new_donation(15)
    assert d.amount[1] == 50
    assert d.amount[2] == 15
Esempio n. 15
0
 def test_donor_init(self):
     with self.assertRaises(ValueError):
         test_obj = Donor(None)
def testDonor_init():
    d1 = Donor('henry',50)
    assert d1.name == 'henry'
    assert d1.donation == 50
Esempio n. 17
0
def test_add_donation():
    donor = Donor("Fred Flintstone")
    donor.add_donation(500)
    assert donor.num_donations == 1
Esempio n. 18
0
def test_create_donor():
    donor = Donor("Fred Flintstone")
    assert donor.name == "Fred Flintstone"
Esempio n. 19
0
def test_donor_thank_you_letter():
    Fred = Donor("Fred Flintstone")
    Fred.add_donation(500)
    Fred.add_donation(10)

    assert Fred.write_letter == """Dearest Fred Flintstone,
Esempio n. 20
0
def test_last_donation():
    donor = Donor("Fred Flintstone")
    donor.add_donation(500)
    assert donor.last_donation == 500
def testDonor_sort():
    d1 = Donor('henry',[50,90])
    d2 = Donor('george',[1000,3000])
    d3 = [d1,d2]
    d3.sort(reverse=True)
    assert d3[0].name == 'george'
Esempio n. 22
0

def send_letter_everyone(d):
    """This method creates the letter for each donor in the donor's database"""
    print("Letters have been sent to all the donors!!!")
    d.send_letter_everyone()



if __name__=="__main__":
    """The flow control of the program. It separates the business logic from
    the data manipulation"""

    options = {1:thank_you,2:print_report,3:send_letter_everyone,4:quit}

    donor_1 = Donor("Adam Johnson",[6000.20, 2200, 1050,100])
    donor_2 = Donor("Matt Marvin",[550,1000,250])
    donor_3 = Donor("Ashley Wiggins",[55.66,270,1000])
    donor_4 = Donor("Kristina Laughrey",[500, 500,200])
    donor_5 = Donor("Kimberley Allen",[12000.99, 5000])
    donor_6 = Donor("Doug Boolinger",[260.57, 930.90])
    donor_7 = Donor("Sherry Henning",[6000, 2460.20, 900])

    d = DonorCollection(donor_1,donor_2,donor_3,donor_4,donor_5,donor_6,donor_7)

    while True:
        user_response = prompt_user()
        if user_response == 4:
            quit()
        try:
             options[user_response](d)
def test_numDonations():
    d1 = Donor('henry',[50,90])
    assert d1.num_donations == 2
def test_11():
    Donor('test', 10)
    assert 'test' in donations
Esempio n. 25
0
def test_name_amount():
    d = Donor('John Doe', 450)
    assert d.name == 'John Doe'
    assert d.amount[0] == 450
def test_12():
    Donor('other test', .01)
    assert 'other test' in donations
Esempio n. 27
0
def test_total_donation():
    d = Donor('John Doe', 450)
    d.new_donation(50)
    d.new_donation(15)
    assert d.total_donation == 515
Esempio n. 28
0
import mailroom_oo as mr
from mailroom_oo import Donor
import pytest

test = []
test1 = Donor("Test1", [100,200])
test2 = Donor("Test2", [500,1200])
test.extend([test1, test2])

def test_class():
    donor = Donor("Class", [100, 200, 300])
    print(donor)

def test_add_donor():
    mr.add_donor("Fake Donor", 1000)
    assert mr.donors[-1].total == 1000

def test_thank_letter():
    letter = mr.thank_letter(test1.name, test1.donations[0])
    assert "Test1" in letter
def test_Donor():
    e = Donor('Ghassan', [100, 200, 300])
    assert e.total_donations == 100 + 200 + 300
    e.add_donation(400)
    assert e.total_donations == 100 + 200 + 300 + 400
from mailroom_oo import Donor, DonorDB

d = Donor('Paul Allen')
d.add_donations(6000)
d2 = Donor('Shigeru Miamoto')
d2.add_donations(9000)
db_test = DonorDB()
db_test.add_donor(d)
db_test.add_donor(d2)


def test_donor_init():
    d = Donor('William Gates III')
    assert d.name == 'William Gates III'
    assert d.donations == []
    d.add_donations(2000)
    d.add_donations(3000)
    assert d.total_donations == 5000


def test_donorDB():
    d = Donor('Paul Allen')
    d.add_donations(6000)
    d2 = Donor('Shigeru Miamoto')
    d2.add_donations(9000)
    db = DonorDB()
    db.add_donor(d)
    db.add_donor(d2)
    assert db.database_dict == {
        'Paul Allen': [6000],
        'Shigeru Miamoto': [9000]