Пример #1
0
def test_save():
    file = "test_profiles.dat"
    a = Donor("Sting", 300.00)
    x = Donors(a)
    x.new_donor("Cher", 400.00)
    x.new_donor("James Bond", 500.00)
    x.save(file)
    assert os.path.isfile(file) == True
Пример #2
0
def test_thank_you_files1():
    a = Donor("Sting", 300.00)
    x = Donors(a)
    x.new_donor("Cher", 400.00)
    x.new_donor("James Bond", 500.00)
    x.thank_yous()
    assert os.path.isfile("sting.txt") == True
    assert os.path.isfile("cher.txt") == True
    assert os.path.isfile("james_bond.txt") == True
Пример #3
0
def test_load1():
    file = "test_no_profiles.dat"
    file2 = "does_not_exist.txt"
    x = Donors()
    x.save(file)
    x.load(file)
    assert x.profiles == []
    x.load(file2)
    assert x.profiles == []
Пример #4
0
def test_edit_a_donor1():
    a = Donor("Sting", 300.00)
    x = Donors(a)
    x.new_donor("Cher", 400.00)
    x.new_donor("Bond James", 500.00)
    p = x.find_donor("Bond James")
    p.person = "James Bond"
    assert str(x) =="\
Пример #5
0
def test_edit_a_donation2():
    a = Donor("Sting", 300.00)
    x = Donors(a)
    x.new_donor("Cher", 400.00)
    x.new_donor("Bond James", 500.00)
    p = x.find_donor("Bond James")
    p.change_donation(1, 200)
    assert str(x) =="\
Пример #6
0
def test_thank_you_files2():
    a = Donor("test1", 300.00)
    x = Donors(a)
    x.new_donor("test2", 400.00)
    x.thank_yous("test1")
    assert os.path.isfile("test1.txt") == True
    assert os.path.isfile("test2.txt") == False
Пример #7
0
def test_str_donors():
    a = Donor("Sting", 100.00)
    x = Donors(a)
    x.new_donor("Cher", 200.00)
    x.new_donor("James Bond", 300.00)
    print(str(x))
    assert str(x) =="\
Пример #8
0
#Change Log: (Who, When, What)
#Brent Kieszling, 2021-Jan-25, created file
#-------------------------------------------#

from donor_modles import Donor, Donors
#DATA---------------------------------------
main_menu = "Main Menu\n\n[1] Write a thank you letter.\n[2] Display current donor rankings.\
\n[3] Write thank you letters for all donors.\n[4] Exit program.\n"

ty_menu = "Thank You Menu\n\n[1] Create thank you for existing donor.\n[2] Create thank you for new donor.\n\
[3] View and edit donor information.\n[4] Return to main menu.\n"

save_file = "donor_profiles.dat"

#PROCESS------------------------------------
donor_history = Donors()
donor_history.load(save_file)


def menu_selection(menu, dispatch):
    """Navigate a menu.
    
        Args:
            menu(str): Display menu
            dispatch(dict): Dictionary controlling menu options
    """
    while True:
        response = input(menu)
        try:
            response = int(response)
        except ValueError:
Пример #9
0
def test_load3():
    file = "test_profiles_3.dat"
    a = Donor("Sting", 300.00)
    x = Donors(a)
    x.new_donor("Cher", 400.00)
    x.new_donor("James Bond", 500.00)
    x.save(file)
    b = Donor("Michael Bolton", 5000.00)
    z = Donors(b)
    z.load(file)
    print(x.profiles)
    print(z.profiles)
    assert str(x.profiles) == str(z.profiles)
Пример #10
0
def test_load2():
    file = "test_profiles_2.dat"
    a = Donor("Sting", 300.00)
    x = Donors(a)
    x.new_donor("Cher", 400.00)
    x.new_donor("James Bond", 500.00)
    x.save(file)
    z = Donors()
    z.load(file)
    print(x.profiles)
    print(z.profiles)
    assert str(x.profiles) == str(z.profiles)
Пример #11
0
def test_new_donor():
    x = Donors()
    a = Donor("Sting", 500.00)
    x.new_donor("Sting", 500.00)
    assert repr(x.find_donor("Sting")) == repr(a)
Пример #12
0
def test_find_donor2():
    a = Donor("Scrooge McDuck", 100.11)
    z = Donors(a)
    with pytest.raises(IndexError):
        z.find_donor("Scrooge")
Пример #13
0
def test_find_donor1():
    a = Donor("Scrooge McDuck", 100.11)
    z = Donors(a)
    assert z.find_donor("Scrooge McDuck") == a
Пример #14
0
def test_donors_init():
    a = Donor("Scrooge McDuck", 100.11)
    x = Donors()
    z = Donors(a)