Ejemplo n.º 1
0
 def test_fail(self, mock_subproc_call):
     """ Function to test when the subprocess call fails"""
     mock_subproc_call.return_value = True
     cloceagleobj = ClocEagle()
     self.dummy_dataf()
     cloceagleobj.orchestrate_cloc(TestResource.input_json)
     out_str = (sys.stdout.getvalue().split('\n'))
     matches = [c for c in out_str if 'There was error while processing the sub process command' in c]
     self.assertEqual(len(list(filter(None, matches))), 1)
     self.assertEqual(matches[0], 'There was error while processing the sub process command')
     self.assertEqual(False, os.path.isfile(os.path.join(TestResource.report, "cloc_report", "cloc-report.html")))
Ejemplo n.º 2
0
 def test_cmd_with_no_arg_to_cmd(self, mock_subproc_call):
     """ Function to test the command when optional arguments are not passed """
     mock_subproc_call.return_value = False
     cloceagleobj = ClocEagle()
     self.dummy_dataf()
     data = {**TestResource.input_json, 'cloc_args': None, }
     cloceagleobj.orchestrate_cloc(data)
     f_cmd = open(os.path.join(TestResource.report, "cloc_report", "cloc.cmd"), "r")
     self.assertEqual(f_cmd.readline().replace("/", os.sep).rstrip(), 'cloc "%s" --csv --out="%s"' %
                      (TestResource.tst_resource_folder, os.path.join(TestResource.report, "cloc_report",
                                                                      "cloc.csv")))
     self.assertTrue(mock_subproc_call.called)
Ejemplo n.º 3
0
    def test_cmd_file_generation_and_content(self, mock_subproc_call):
        """ Function to test the command file generation and the content verification"""
        mock_subproc_call.return_value = False
        cloceagleobj = ClocEagle()
        self.dummy_dataf()
        cloceagleobj.orchestrate_cloc(TestResource.input_json)
        f_cmd = open(os.path.join(TestResource.report, "cloc_report", "cloc.cmd"), "r")
        cmd_out = (f_cmd.readline())

        self.assertEqual(cmd_out.replace("/", os.sep).rstrip(),
                         'cloc "%s" --csv --out="%s" --exclude-dir=src --exclude-ext=*.cpp,*.java' %
                         (TestResource.tst_resource_folder, os.path.join(TestResource.report,
                                                                         "cloc_report", "cloc.csv")))
        self.assertTrue(mock_subproc_call.called)
Ejemplo n.º 4
0
    def test_init_cmd_path(self, mock_subproc_call):
        """ Function to test the default init , command forming, and path creation"""
        mock_subproc_call.return_value = False
        self.dummy_dataf()
        cloceagleobj = ClocEagle()
        self.assertEqual(cloceagleobj.cmd, "")
        self.assertEqual(cloceagleobj.report_path, None)

        cloceagleobj.orchestrate_cloc(TestResource.input_json)

        self.assertEqual(cloceagleobj.cmd.replace("/", os.sep),
                         'cloc "%s" --csv --out="%s" --exclude-dir=src --exclude-ext=*.cpp,*.java' %
                         (TestResource.tst_resource_folder, os.path.join(TestResource.report,
                                                                         "cloc_report", "cloc.csv")))
        self.assertEqual(cloceagleobj.report_path, os.path.join(TestResource.report, "cloc_report"))
        self.assertTrue(mock_subproc_call.called)
Ejemplo n.º 5
0
 def test_report_file_generation_content(self, mock_subproc_call):
     """ Function to test the report file generation from the csv generated from command out """
     from pandas.util.testing import assert_frame_equal
     mock_subproc_call.return_value = False
     cloceagleobj = ClocEagle()
     self.dummy_dataf()
     cloceagleobj.orchestrate_cloc(TestResource.input_json)
     dataframe = pd.read_html(os.path.join(TestResource.report, "cloc_report", "cloc-report.html"))
     dataframe = pd.concat(dataframe)
     dataframe.drop(dataframe.columns[0], axis=1, inplace=True)
     dataframe_out = self.dummy_dataf()
     dataframe_out.drop(dataframe_out.columns[5], axis=1, inplace=True)
     assert_frame_equal(dataframe, dataframe_out)
     self.assertTrue(mock_subproc_call.called)
     self.assertEqual(True, os.path.isfile(os.path.join(TestResource.report, "cloc_report", "cloc.cmd")))
     self.assertEqual(True, os.path.isfile(os.path.join(TestResource.report, "cloc_report", "cloc-report.html")))
     self.assertEqual(True, os.path.isfile(os.path.join(TestResource.report, "cloc_report", "cloc.csv")))
Ejemplo n.º 6
0
 def __eaglewatch_cloc__(json):
     """ Function which invokes the Cloc class for analysis """
     cloceagleobj = ClocEagle()
     cloceagleobj.orchestrate_cloc(json)
Ejemplo n.º 7
0
 def test_path(self, mock_subproc_call):
     """ Function to test the path setting """
     mock_subproc_call.return_value = True
     cloceagleobj = ClocEagle()
     cloceagleobj.orchestrate_cloc(TestResource.input_json)
     self.assertEqual(cloceagleobj.report_path, os.path.join(TestResource.report, "cloc_report"))