Exemplo n.º 1
0
def test_thankyou_note():
    M_S = Donor("Morgan Stanley")
    M_S.donations = [10]
    M_S.append(7.50)

    assert M_S.thank_you(
    ) == "Thanks Morgan Stanley for your $17.50 in donations."
Exemplo n.º 2
0
def test_thankyou_email():
    '''Test email text'''
    M_S = Donor("Morgan Stanley")
    M_S.donations = [10]
    M_S.append(7.5)

    assert M_S.email().startswith("Greetings Morgan Stanley")
    assert M_S.email().endswith("(DZCAWCRG)\n")
Exemplo n.º 3
0
def test_init_donation():
    '''Creating first donation'''
    Paul = Donor('Paul')
    Paul.donations = [15]

    assert Paul.donations == [15]
    Paul.append([16, 17])
    assert Paul.donations == [15, 16, 17]
Exemplo n.º 4
0
def test_sum_gift():
    DC = Donor_Collect()
    WG = Donor('Bill Gates')
    WG.donations = [15]
    WG.append([16, 17])
    DC.append(WG)
    new_dict = DC.calc_report()

    print(new_dict)

    assert isinstance(new_dict, dict)
    assert new_dict[repr(WG)] is not None
    assert new_dict[repr(WG)][0] == 48.0
    assert new_dict[repr(WG)][1] == 3
    assert new_dict[repr(WG)][2] == 16.0
Exemplo n.º 5
0
def receiver():
    '''For processing user interface for creating a single thank you'''
    viable_ans = False

    while viable_ans == False:
        new_vs_ex = input("Donor Name, List, Quit? ")
        name = new_vs_ex
        if new_vs_ex.lower() == "quit":
            name = "quit"
            viable_ans = True
            break
        elif new_vs_ex.lower() == "list":
            don_col.print_don_list()
            don_num = int(input("Select # above: "))
            try:
                name = don_col.donors[don_num-1]
            except IndexError:
                print("Must select a value from the list!")
                name = "quit"

        if new_vs_ex.lower() != "quit":
            donation_value = input("What is the value of the donation? ")            
            if donation_value.lower() == "quit":
                name = "quit"
                viable_ans = True
            elif isinstance(donation_value, float):
                viable_ans = True
            elif float(donation_value) <= 0:
                print("All donations must be greater than 0")
                name = "quit"
                viable_ans = False
        
        if name in don_col.donors:
            try:
                name.append(float(donation_value))
                viable_ans = True
            except ValueError:
                print("Donation must be whole number or decimal value")
                name = "quit"
        elif don_col.donor_validation(name):
            confirmation = input("Confirm donor name:")
            if confirmation == name:
                name = Donor(name)
                name.append(float(donation_value))
                don_col.append(name)
                viable_ans = True
            else:
                print("Names not the same please restart")
                name = "quit"
        elif name != "quit":
            name = Donor(name)
            name.append(float(donation_value))
            don_col.append(name)
            viable_ans = True
    
    if name != "quit":
        try:
            print("\n" + name.thank_you() + "\n")
        except AttributeError:
            name = "quit"

    return name
Exemplo n.º 6
0
from Donor_Models import Donor, Donor_Collect  

'''Initial setup'''
don_col = Donor_Collect()
MS = Donor("Morgan Stanley")    
CV = Donor("Cornelius Vanderbilt")
JDR = Donor("John D. Rockefeller")
SG = Donor("Stephen Girard")
AC = Donor("Andrew Carnegie")
don_col.append(MS)
don_col.append(CV)
don_col.append(JDR)
don_col.append(SG)
don_col.append(AC)
MS.append([0.01, 20.00])
CV.append([800, 15, 10.00])
JDR.append([7000, 150.00, 25])
SG.append([60000])
AC.append([0.04, 999.99])

def receiver():
    '''For processing user interface for creating a single thank you'''
    viable_ans = False

    while viable_ans == False:
        new_vs_ex = input("Donor Name, List, Quit? ")
        name = new_vs_ex
        if new_vs_ex.lower() == "quit":
            name = "quit"
            viable_ans = True