Пример #1
0
def test_send_thanks_single_donation():
    """ test thank you letter """
    mailroom = Mailroom()
    donor = Donor("Monty Python")
    donor.add_donation(10)
    assert "\n\nDear Monty Python,\nThank you for your donation of 10.\n\n" == mailroom.send_thanks(
        donor)
Пример #2
0
	def test_add_first_donation_to_donor(self):
		donor_name = "Sireesha Sankuratripati"
		donor = Donor (donor_name)
		self.assertEqual(donor_name, donor.donor_name)
		self.assertEqual(0, len(donor.donation_amounts_list))
		#add a donation
		donation_val = 1000.90
		donor.add_donation(donation_val)
		self.assertEqual(1, len(donor.donation_amounts_list))
		self.assertEqual(donation_val, donor.donation_amounts_list[0])
def test_donor_donation():
    d = Donor("Stuart")
    assert d.donations == []

    with pytest.raises(Exception) as excinfo:
        d.add_donation(-50)
    assert str(excinfo.value) == "A positive donation value is required."

    d.add_donation(50)
    assert d.donations == [50]
Пример #4
0
	def test_add_invalid_amount(self):
		donor_name = "Sireesha Sankuratripati"
		donor = Donor (donor_name)
		self.assertEqual(donor_name, donor.donor_name)
		self.assertEqual(0, len(donor.donation_amounts_list))
		#add a donation
		donation_val = 'i am not a number'
		with self.assertRaises(TypeError):
			donor.add_donation(donation_val)
		donation_val = -1000
		with self.assertRaises(ValueError):
			donor.add_donation(donation_val)
Пример #5
0
	def test_add_multiple_donations_to_donor(self):
		donor_name = "Sireesha Sankuratripati"
		donor = Donor (donor_name)
		self.assertEqual(donor_name, donor.donor_name)
		self.assertEqual(0, len(donor.donation_amounts_list))
		#add a donation
		donation_val = 2000.90
		donor.add_donation(donation_val)
		self.assertEqual(1, len(donor.donation_amounts_list))
		self.assertEqual(donation_val, donor.donation_amounts_list[0])

		donation_val = 12000.00
		donor.add_donation(donation_val)
		self.assertEqual(2, len(donor.donation_amounts_list))
		self.assertEqual(donation_val, donor.donation_amounts_list[1])
Пример #6
0
def test_send_thanks_multiple_donation():
    """ test thank you letter with multiple donations"""
    mailroom = Mailroom()
    donor = Donor("Monty Python")
    donor.add_donation(30)
    donor.add_donation(20)
    donor.add_donation(100)
    donor.add_donation(150)
    donor.add_donation(10)
    assert "\n\nDear Monty Python,\nThank you for your donation of 10.\n\n" == mailroom.send_thanks(
        donor)
Пример #7
0
def test_get_average_donation_multiple_donation():
    donor = Donor("Test Uesr")
    donor.add_donation(200)
    donor.add_donation(100)
    assert donor.get_average_donation() == 150.00
Пример #8
0
def test_get_average_donation_single_donation():
    donor = Donor("Test User")
    donor.add_donation(100)
    assert donor.get_average_donation() == 100.00
Пример #9
0
def test_get_total_donations_multiple_donations():
    donor = Donor("Test User")
    donor.add_donation(200)
    donor.add_donation(100)
    assert donor.get_total_donations() == 2
Пример #10
0
def test_get_donations():
    donor = Donor("Test User")
    donor.add_donation(200)
    donor.add_donation(100)
    assert [200, 100] == donor.get_donations()
Пример #11
0
def test_add_donation():
    donor = Donor("Test User")
    donor.add_donation(100)
    assert 100 in donor.donations
Пример #12
0
def test_add_donation():
    donor = Donor("Fred Flintstone")

    donor.add_donation(500)

    assert donor.num_donations == 1
Пример #13
0
def test_add_donation():
    d = Donor("Fred Flintstone")
    d.add_donation(100)
    assert d.donation_count == 1
    assert d.latest_donation == 100
Пример #14
0
def test_add_donation():
    d1 = Donor("Shawn", "Hopkins", 100)
    d1.add_donation(100)
    assert sum(d1.donation) == 200
Пример #15
0
def test_add_donation():
    donor = Donor("Fred Flinstone")
    donor.add_donation(500)
    assert donor.donation == [
        500,
    ]
Пример #16
0
def test_add_donation():
    donor = Donor("Road Runner")

    donor.add_donation(4839283.32)

    assert donor.num_donations == 1
Пример #17
0
def test_Donor_add_donation():
    donor = Donor('Bill Murray', [{'amount': 23.20, 'date': datetime.now()}])
    donor.add_donation(44.13)
    assert len(donor.donations) == 2
Пример #18
0
def test_append_donation():
    donor = Donor("Fred Flinstone")
    donor.add_donation(500, 365.00)
    assert donor.donation == [500, 365.00]
    donor.add_donation(1007)
    assert donor.donation == [500, 365.00, 1007]