def test_gender_pie_chart_with_bad_data_does_not_match_reference_chart( self): # Arrange file_name = 'testdata\\test_output_all_male_all_500_sales.txt' chart_type = "sales" expected_image_file = 'reference_charts\\pie_chart_sales.png' actual_image_file = 'created_charts\\pie_chart.png' file_contents = [] with open(file_name, "r") as file: for line in file: a_line = line.rstrip() file_contents.append(a_line) file.close() calc_data = CalcData() calc_data.calculate(file_contents, chart_type) # Act calc_data.pie_chart(chart_type) # Assert if filecmp.cmp(expected_image_file, actual_image_file, shallow=False): chart_images_match = True else: chart_images_match = False self.assertFalse(chart_images_match)
def test_pie_chart_false(self): test_name = "Calc Chart Data Pie Chart FALSE Test #08" data_to_test = "testing" class_to_test = CalcData() expected_result = None class_to_test.calc_pie_sales(150) class_to_test.calc_pie_sales(250) # Action result = class_to_test.pie_chart(data_to_test) # Assert try: self.assertTrue(result == expected_result) except AssertionError: print("{} Failed - Should be {}, but was {}.".format( test_name, expected_result, result)) else: print("{} Passed".format(test_name))
def test_pie_chart_gender(self): test_name = "Calc Chart Data Pie Chart Gender Test #06" data_to_test = None class_to_test = CalcData() expected_result = None class_to_test.calc_pie_gender("M") class_to_test.calc_pie_gender("F") # Action result = class_to_test.pie_chart("gender") # Assert try: self.assertTrue(result == expected_result) except AssertionError: print("{} Failed - Should be {}, but was {}.".format( test_name, expected_result, result)) else: print("{} Passed".format(test_name))