예제 #1
0
    def test_bmi_bar_chart_with_correct_data_matches_reference_chart(self):
        # Arrange
        file_name = 'testdata\\test_output.txt'
        chart_type = "bmi"
        expected_image_file = 'reference_charts\\bar_chart_bmi.png'
        actual_image_file = 'created_charts\\bar_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.bar_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.assertTrue(chart_images_match)
예제 #2
0
 def test_bar_chart_false(self):
     test_name = "Calc Chart Data Bar Chart FALSE Test #05"
     data_to_test = "testing"
     class_to_test = CalcData()
     expected_result = None
     class_to_test.calc_bar_bmi("Overweight")
     class_to_test.calc_bar_bmi("Underweight")
     # Action
     result = class_to_test.bar_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))
예제 #3
0
 def test_bar_chart_birthday(self):
     test_name = "Calc Chart Data Bar Chart Birthday Test #03"
     data_to_test = None
     class_to_test = CalcData()
     expected_result = None
     class_to_test.calc_bar_birthday("12/12/12")
     class_to_test.calc_bar_birthday("12/10/12")
     # Action
     result = class_to_test.bar_chart("birthday")
     # 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))