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)
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]
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)
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])
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)
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
def test_get_average_donation_single_donation(): donor = Donor("Test User") donor.add_donation(100) assert donor.get_average_donation() == 100.00
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
def test_get_donations(): donor = Donor("Test User") donor.add_donation(200) donor.add_donation(100) assert [200, 100] == donor.get_donations()
def test_add_donation(): donor = Donor("Test User") donor.add_donation(100) assert 100 in donor.donations
def test_add_donation(): donor = Donor("Fred Flintstone") donor.add_donation(500) assert donor.num_donations == 1
def test_add_donation(): d = Donor("Fred Flintstone") d.add_donation(100) assert d.donation_count == 1 assert d.latest_donation == 100
def test_add_donation(): d1 = Donor("Shawn", "Hopkins", 100) d1.add_donation(100) assert sum(d1.donation) == 200
def test_add_donation(): donor = Donor("Fred Flinstone") donor.add_donation(500) assert donor.donation == [ 500, ]
def test_add_donation(): donor = Donor("Road Runner") donor.add_donation(4839283.32) assert donor.num_donations == 1
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
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]