示例#1
0
    def test_plot_barchart_does_plot(self, mock_writer):
        dummy_dataframe = pd.DataFrame(
            data=[["Label %d" % dummyval, dummyval]
                  for dummyval in list(range(0, 10))],
            columns=["Label", "Value"],
        )
        sut.plot_barchart(dummy_dataframe, "", "", "", "")

        self.assertTrue(mock_writer.called)
示例#2
0
    def test_plot_barchart_does_plot_if_data_extends_max_limit(
            self, mock_writer):
        dummy_dataframe = pd.DataFrame(
            data=[[
                "Label with long long long long long long long long long long long long long long text %d"
                % dummyval,
                dummyval,
            ] for dummyval in list(range(0, 100))],
            columns=["Label", "Value"],
        )
        sut.plot_barchart(dummy_dataframe, "", "", "", "")

        self.assertTrue(mock_writer.called)
示例#3
0
 def write_results(self, output_dir):
     writer.write_dataframe_to_xls(
         self._analysis_result,
         "cognitive_complexity_per_method.xls",
         output_dir,
         "Method Complexity",
     )
     methods_with_comp_greater_zero = self._create_barchart_data()
     plot.plot_barchart(
         methods_with_comp_greater_zero,
         "Cognitive complexity",
         "Methods with highest cognitive complexity",
         output_dir,
         "most_complex_methods.pdf",
     )
示例#4
0
 def write_results(self, output_dir):
     writer.write_dataframe_to_xls(
         self._analysis_result,
         "cognitive_complexity_per_class.xls",
         output_dir,
         "Class Complexity",
     )
     batchart_data = self._create_barchart_data()
     plot.plot_barchart(
         batchart_data,
         "Cognitive complexity",
         "Classes with highest cognitive complexity",
         output_dir,
         "most_complex_classes.pdf",
     )
示例#5
0
    def test_plot_barchart_plots_expected_barchart_if_dataframe_extends_max_limit(
            self):
        """Make shure barcharts are limit to _MAX_BARCHART_ENTRIES"""
        dummy_dataframe = pd.DataFrame(
            data=[["Label %d" % dummyval, dummyval]
                  for dummyval in list(range(-10, 100))],
            columns=["Label", "Value"],
        )
        sut.plot_barchart(
            dummy_dataframe,
            "bla",
            "dummyTitle",
            reporttest.TEST_RESULTS_FOLDER,
            self._used_file_name,
        )

        reporttest.assert_images_equal(self._barchart_output_path,
                                       self._ref_barchart_path)
示例#6
0
    def test_plot_barchart_does_not_plot_if_dataframe_empty(self, mock_writer):
        sut.plot_barchart(pd.DataFrame(), "", "", "", "")

        self.assertFalse(mock_writer.called)