def test_donor_add_donation_negative(self, amount): """Negative-Test-Cases""" # Setup donor = donor_models.Donor("Spam Eggs") # Assert with pytest.raises(ValueError): donor.add_donation(amount)
def test_donor_total_gifts(self, num_gifts): """Positive-Test-Cases""" # Setup donor = donor_models.Donor("Spam Eggs") donor.donations = [1] * num_gifts # Assert assert donor.total_gifts == num_gifts
def test_donor_total_given(self, donations_list, total): """Positive-Test-Cases""" # Setup donor = donor_models.Donor("Spam Eggs") donor.donations = donations_list # Assert assert donor.total_given == total
def test_donor_init(self, name): """Positive-Test-Cases""" # Setup donor = donor_models.Donor(name) # Assert assert donor.name == name assert donor.donations == []
def test_donor_thank_you_overall_negative_no_donations(self): """Negative-Test-Cases""" # Setup donor = donor_models.Donor("Spam Eggs") # Assert with pytest.raises(LookupError): donor.thank_you_overall()
def test_donor_add_donation(self, donations_list, total): """Positive-Test-Cases""" # Setup donor = donor_models.Donor("Spam Eggs") # Assert for donation in donations_list: donor.add_donation(donation) assert donor.donations == donations_list assert donor.total_given == total
def test_donor_thank_you_latest(self, donation_list): """Positive-Test-Cases""" # Setup name = "Spam Eggs" donor = donor_models.Donor(name) donor.donations = donation_list thank_you = donor.thank_you_latest() time_s = "times" if len(donation_list) > 1 else "time" # Assert assert name in thank_you assert f"{donation_list[-1]:.2f}" in thank_you assert f"{len(donation_list):d}" in thank_you assert f"{sum(donation_list):.2f}" in thank_you assert time_s in thank_you
def test_donor_thank_you_overall(self, donation_list): """Positive-Test-Cases""" # Setup name = "Spam Eggs" donor = donor_models.Donor(name) donor.donations = donation_list thank_you = donor.thank_you_overall() num_gifts = len(donation_list) time_s = ( f"{num_gifts:d} donations" if num_gifts > 1 else "donation" ) # Grammer correction of "donation" vs "# donations" # Assert assert name in thank_you assert f"{sum(donation_list):.2f}" in thank_you assert time_s in thank_you
def test_donor_init_negative_invalid_name(self, name): """Negative-Test-Cases""" # Assert with pytest.raises(ValueError): donor_models.Donor(name)