def test_create_a_report(): expected = [['Chuck', '$', 10000, 1, '$', 10000.0], ['Bob', '$', 3000, 2, '$', 1500.0], ['Anna', '$', 600, 3, '$', 200.0], ['Ethan', '$', 30, 2, '$', 15.0], ['David', '$', 1, 1, '$', 1.0]] assert (expected == mailroom4.create_a_report()) is True
def test_create_a_report(): report_output = ['Cheryl Tunt $ 98,342.30 2 49,171.15', 'Pam Poovey $ 80,891.30 3 26,963.77', 'Ray Gillette $ 3,820.90 1 3,820.90', 'Lana Kane $ 2,999.99 1 2,999.99', 'Cyril Figgis $ 1,828.37 3 609.46'] assert mailroom.create_a_report() == report_output
def test_create_report(self): expected_report = \ ''' Donor Name | Total Given | Num Gifts | Average Gift sai emani $ 101.47 3 $ 33.82 sirisha marthy $ 113.78 2 $ 56.89 ani emani $ 18.25 2 $ 9.12 charles dickens $ 450.76 3 $ 150.25 mark twain $ 678.99 1 $ 678.99 ''' capture_print = io.StringIO() sys.stdout = capture_print mr.create_a_report() sys.stdout = sys.__stdout__ self.assertEqual(capture_print.getvalue().strip(), expected_report.strip())
def test_createAReport(self): self.assertEqual( mail.create_a_report(), "\nDonor Name | Total Given | # Gifts | Average Gift\n" + "------------------------------------------------------------------" + "\nBill Gates $ 185.00 2 $ 92.50" + "\nElon Musk $ 40.00 2 $ 20.00" + "\nJeff Bezos $ 145.00 3 $ 48.33" + "\nKevin Hart $ 30.00 1 $ 30.00" + "\nThe Rock $ 430.00 3 $ 143.33")
def test_create_a_report(): """ Tests if the nicely formatted overall summary report is generated """ # Check the report is created properly results = mailroom.create_a_report() # Check the number of the rows generated by the report # Assert == 7 because of newly added donor from test_send_email() function, i.e. Michael Jordan assert len(results.split('\n')) == 7
def test_creat_a_report(): report = mailroom4.create_a_report() assert report[ 0] == ' --------------------------------------------------------------------- ' assert report[ 1] == '| Donor Name | Total Given | Num Gifts | Average Gift |' assert report[ 2] == '|---------------------------------------------------------------------|' assert report[ 3] == '| Robert Rowe | 20000000.00 | 1 | 20000000.00 |' assert report[ 4] == '| Yue Ma | 1661132.00 | 2 | 830566.00 |' assert report[ 5] == '| Jianqiang Ma | 1056023.00 | 3 | 352007.67 |' assert report[ 6] == '| Yanan Ma | 12833.00 | 4 | 3208.25 |' assert report[ 7] == '| Chunhong Liu | 1100.61 | 2 | 550.31 |' assert report[ 8] == ' --------------------------------------------------------------------- '
def test_create_a_report(): donation_history = [{ 'name': 'Anna', 'donations': [100, 200, 300] }, { 'name': 'Bob', 'donations': [1000, 2000] }, { 'name': 'Chuck', 'donations': [10000] }, { 'name': 'David', 'donations': [1] }, { 'name': 'Ethan', 'donations': [10, 20] }] expected = [['Chuck', '$', 10000, 1, '$', 10000.0], ['Bob', '$', 3000, 2, '$', 1500.0], ['Anna', '$', 600, 3, '$', 200.0], ['Ethan', '$', 30, 2, '$', 15.0], ['David', '$', 1, 1, '$', 1.0]] assert (expected == mailroom4.create_a_report()) is True