def test_send_letters_to_everyone(self): # create cat and dog donors cat = oo_mr.Donor("cat") cat.add_donation(50) cat.add_donation(50) dog = oo_mr.Donor("dog") # it's been a ruff year, only $2 in donations dog.add_donation(1) dog.add_donation(1) # create a donor list and add the cat and dog donors animal_donors = oo_mr.DonorList() animal_donors.add_donor(cat) animal_donors.add_donor(dog) if (os.path.isfile("thank_you_cat.txt")): os.remove("thank_you_cat.txt") if (os.path.isfile("thank_you_dog.txt")): os.remove("thank_you_dog.txt") animal_donors.send_letters_to_everyone() self.assertEqual( os.path.isfile("thank_you_cat.txt") & os.path.isfile("thank_you_dog.txt"), True)
def test_send_a_thank_you(self, mocked_input): mocked_input.side_effect = ['Earl', 400] donor_list4 = oo_mr.DonorList() donor_list4.add_donor(oo_mr.Donor("Earl")) out = io.StringIO() donor_list4.send_a_thank_you(out=out) output = out.getvalue().strip() self.assertEqual( "Dear Earl, \nThank you for your generous donations totaling $400.00. \nBest, The Donation Foundation", output)
def test_add_donor_to_donorList(self): donor6 = oo_mr.Donor("Sherm") donor_list2 = oo_mr.DonorList() donor_list2.add_donor(donor6) self.assertEqual(donor_list2.donor_list, ["Sherm"])
def test_receive_input(self, input): donor_list3 = oo_mr.DonorList() answer = donor_list3.receive_thank_you_card_recepient_input() self.assertEqual(answer, "Earl")
def test_empty_dict(self): donor_list1 = oo_mr.DonorList() self.assertEqual(donor_list1.donors, {})