Beispiel #1
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)
Beispiel #2
0
def test_check_donation():
    a = Donor("Scrooge McDuck", 999.91)
    assert a.donations[0] == 999.91
    a.new_donation(100.00)
    a.new_donation(2)
    a.new_donation(300.11)
    assert a.donations[2] == 2.00
    print(a.donations)
Beispiel #3
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) =="\
Beispiel #4
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
Beispiel #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) =="\
Beispiel #6
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) =="\
Beispiel #7
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
Beispiel #8
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
Beispiel #9
0
def test_str_donor():
    a = Donor("Scrooge McDuck", 100.11)
    a.donations.append(200.11)
    print(a)
    assert "Scrooge McDuck" in str(a)
    assert "300.22" in str(a)
    assert "150.11" in str(a)
    assert" 2 " in str(a)
    assert str(a) == "\
Beispiel #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)
Beispiel #11
0
def test_thank_you():
    a = Donor("Scrooge McDuck", 100.00)
    print(a.thank_you())
    assert a.thank_you() == """
    Dear Scrooge McDuck,
    
    Thank you for your most recent donation of $100.00. We are humbled by your 
    lifetime contribution of $100.00.
    
    Sincerly,
    Making Good Things Happen"""
    a.new_donation(1000.00)
    assert a.thank_you() == """
Beispiel #12
0
def test_donors_init():
    a = Donor("Scrooge McDuck", 100.11)
    x = Donors()
    z = Donors(a)
Beispiel #13
0
def test_repr_donor():
    a = Donor("Scrooge McDuck", 100.11)
    print(repr(a))
    assert repr(a) == "Scrooge McDuck       $ 100.11           1      $     100.11"
Beispiel #14
0
def test_total_donated():
    a = Donor("Scrooge McDuck", 999.91)
    assert a.total == 999.91
    a.donations.append(100.11)
    assert a.total == 1100.02
Beispiel #15
0
def test_average_donation():
    a = Donor("Scrooge McDuck", 999.91)
    a.donations.append(100.00)
    print (a.average)
    assert a.average == 549.95
Beispiel #16
0
def test_change_donation2():
    a = Donor("Scrooge McDuck", 999.91)
    a.new_donation(100.00)
    a.new_donation(2)
    a.change_donation(1, 1000)
    assert a.donations[0] == 1000.00
Beispiel #17
0
def test_total_gifts():
    a = Donor("Scrooge McDuck", 999.91)
    a.donations.append(100.00)
    print(a.gifts)
    assert a.gifts == 2
Beispiel #18
0
def test_find_donor1():
    a = Donor("Scrooge McDuck", 100.11)
    z = Donors(a)
    assert z.find_donor("Scrooge McDuck") == a
Beispiel #19
0
def test_change_donation1():
    a = Donor("Scrooge McDuck", 999.91)
    a.new_donation(100.00)
    a.new_donation(2)
    a.change_donation(3, -200)
    assert a.donations[2] == 0.00
Beispiel #20
0
def test_find_donor2():
    a = Donor("Scrooge McDuck", 100.11)
    z = Donors(a)
    with pytest.raises(IndexError):
        z.find_donor("Scrooge")
Beispiel #21
0
def test_new_donation2():
    a = Donor("Scrooge McDuck", 999.91)
    a.new_donation(-100.00)
    assert a.donations == [999.91, 0]
Beispiel #22
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)
Beispiel #23
0
def test_thank_you_file():
    a = Donor("TestSting1", 300.00)
    b = Donor("Test Sting2", 300.00)
    c = Donor("Test-Sting3", 300.00)
    a.create_file()
    b.create_file()
    c.create_file()
    assert os.path.isfile("teststing1.txt") == True
    assert os.path.isfile("test_sting2.txt") == True
    assert os.path.isfile("test-sting3.txt") == True
    with open("teststing1.txt", 'r') as file:
            letter = file.read()
    print(letter)
    print(a.thank_you())
    assert letter == a.thank_you()
Beispiel #24
0
def test_init():
    a = Donor("Scrooge McDuck", 999.91)
    with pytest.raises(TypeError):
        b = Donor(123, 100)
    with pytest.raises(TypeError):
        c = Donor("Bob", "Ten dollars")
Beispiel #25
0
def test_name_change1():
    a = Donor("Scrooge McDuck", 999.91)
    a.person = "Donald Duck"
    assert a.person == "Donald Duck"
Beispiel #26
0
def test_name():
    a = Donor("Scrooge McDuck", 999.91)
    print(a.person)
    assert a.person == "Scrooge McDuck"