Example #1
0
	def test_challenge_donor_db_with_projection_over50(self):
		# create two donors with some donations		
		the_cb = fp_mr.Donor("Griffin")
		the_cb.add_donation(50)
		the_cb.add_donation(75)
		the_cb.add_donation(787)
		the_cb.add_donation(797)

		the_lb = fp_mr.Donor("Wagner")
		the_lb.add_donation(25)
		the_lb.add_donation(49)
		the_lb.add_donation(130)
		the_lb.add_donation(155)

		# create a DonorList() and add the donors
		defense = fp_mr.DonorList()
		defense.add_donor(the_cb)
		defense.add_donor(the_lb)

		# project donor database where all contributions under 100 are doubled
		defense_post_challenge = defense.challenge_donors(inflation_factor = 2, max_donations = 100, projection = True)

		# get new donation lists
		the_cb_post = list(defense_post_challenge.donors['Griffin'].donations)
		the_lb_post = list(defense_post_challenge.donors['Wagner'].donations)

		self.assertEqual([the_cb_post, the_lb_post], [[100.0, 150.0, 787, 797], [50.0, 98.0, 130.0, 155.0]])		
Example #2
0
	def test_send_a_thank_you(self, mocked_input):
		mocked_input.side_effect = ['Earl', 400]
		donor_list4 = fp_mr.DonorList()
		donor_list4.add_donor(fp_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)
Example #3
0
	def test_challenge_donor_with_filter_db(self):
		# create two donors with some donations		
		the_cb = fp_mr.Donor("Griffin")
		the_cb.add_donation(2000)
		the_cb.add_donation(5000)

		the_lb = fp_mr.Donor("Wagner")
		the_lb.add_donation(10000)
		the_lb.add_donation(100)

		# create a DonorList() and add the donors
		defense = fp_mr.DonorList()
		defense.add_donor(the_cb)
		defense.add_donor(the_lb)

		# filter out donations less than 1000 and greater than 6000
		defense_post_challenge = defense.challenge_donors(inflation_factor = 1, min_donations = 1000, max_donations = 6000)

		# get new donation lists
		the_cb_post = list(defense_post_challenge.donors['Griffin'].donations)
		the_lb_post = list(defense_post_challenge.donors['Wagner'].donations)

		self.assertEqual([the_cb_post, the_lb_post], [[2000.0, 5000.0], []])
Example #4
0
	def test_challenge_donor_db(self):
		# create two donors with some donations		
		the_cb = fp_mr.Donor("Griffin")
		the_cb.add_donation(100)
		the_cb.add_donation(200)

		the_lb = fp_mr.Donor("Wagner")
		the_lb.add_donation(5000)
		the_lb.add_donation(10000)

		# create a DonorList() and add the donors
		defense = fp_mr.DonorList()
		defense.add_donor(the_cb)
		defense.add_donor(the_lb)

		# inflate the donations by 10
		defense_post_challenge = defense.challenge_donors(inflation_factor = 10)

		# get new donation lists
		the_cb_post = defense_post_challenge.donors['Griffin'].donations
		the_lb_post = defense_post_challenge.donors['Wagner'].donations

		self.assertEqual([the_cb_post, the_lb_post], [[1000.0, 2000.0], [50000.0, 100000.0]])
Example #5
0
	def test_send_letters_to_everyone(self):		
		# create cat and dog donors
		cat = fp_mr.Donor("cat")
		cat.add_donation(50)
		cat.add_donation(50)

		dog = fp_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 = fp_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)
Example #6
0
	def test_receive_input(self, input):
		donor_list3 = fp_mr.DonorList()
		answer = donor_list3.receive_thank_you_card_recepient_input()
		self.assertEqual(answer, "Earl")
Example #7
0
	def test_add_donor_to_donorList(self):
		donor6 = fp_mr.Donor("Sherm")
		donor_list2 = fp_mr.DonorList()
		donor_list2.add_donor(donor6)
		self.assertEqual(donor_list2.donor_list, ["Sherm"])
Example #8
0
	def test_empty_dict(self):
		donor_list1 = fp_mr.DonorList()
		self.assertEqual(donor_list1.donors, {})