def test_donorcollection_report(): """Test DonorCollection report instance method.""" donor1 = Donor("Alexander Boone", 500, 2) donor2 = Donor("Alexander", 1200, 2) collection = DonorCollection(donor1, donor2) h = [ 'Donor Name', '|', 'Total Given', '|', 'Num Gifts', '|', 'Average Gift' ] report_headers = '{:<25}{:^5}{:<15}{:^5}{:<10}{:^5}{:<15}'.format(*h) table_divider = '-' * 80 report_test = "\n" + report_headers + "\n" \ + table_divider + "\n" \ + "\n".join([donor.report_row() for donor in collection.donors]) \ + "\n" report = collection.report() assert report == report_test assert "Alexander Boone" in report assert "500.00" in report assert "2" in report assert "250.00" in report assert "1,200.00" in report
def test_donor_collection_report(self, test_input): headers = ['Donor Name', '|', 'Total Given', '|', 'Num Gifts', '|', 'Average Gift'] donors = ["Larry David", "Cosmo Kramer", "Jerry Seinfeld", "Elaine Benes"] num_donations = ["4", "2", "1", "0"] total_donations = ["200.00", "3,654.54", "909,090.90", "0.00"] avg_donations = ["50.00", "1,827.27", "909,090.90", "0.00"] donor_collection = DonorCollection(test_input) print(donor_collection.report()) for header in headers: assert header in donor_collection.report() for donor in donors: assert donor in donor_collection.report() for number in num_donations: assert number in donor_collection.report() for total in total_donations: assert total in donor_collection.report() for avg in avg_donations: assert avg in donor_collection.report()
def test_donor_collection_report(): header = ['Donor Name', '|', 'Total Given', '|', 'Num Gifts', '|', 'Average Gift'] num_donations = ["1", "3", "2", "2", "3"] total_donations = ["25,000.00", "11,109.50", "5,524.00", "1,245.00", "175.01"] avg_donations = ["25,000.00", "3,703.17", "2,762.00", "622.50", "58.34"] donor_collection = DonorCollection(donors_data_report) print(donor_collection.report()) for col in header: assert col in donor_collection.report() for donor in check_donor_names: assert donor in donor_collection.report() for number in num_donations: assert number in donor_collection.report() for total in total_donations: assert total in donor_collection.report() for avg in avg_donations: assert avg in donor_collection.report()
def test_report(): dc = DonorCollection() report = dc.report() assert "Donor Name | Total Given | Num Gifts | Average Gift" in report for patron in dc.donor_list: assert patron.name in report
def test_donor_collection_report_error(self, test_input, expected): donor_collection = DonorCollection(test_input) with raises(expected): donor_collection.report()
def test_DonorCollect_report(): """ tests whether report list is being generated and sorted """ donors = Donors() report = donors.report() assert report[0] == ["Samwise Gamgee", 10601.93, 3, 3533.98] assert report[4] == ["Smeagol", 45.01, 1, 45.01]