def test_report_error_in_MT_conf_interval_plot(self): with mock.patch("tlsfuzzer.analysis.Analysis.load_data", self.mock_read_csv): with mock.patch( "tlsfuzzer.analysis.Analysis.ecdf_plot") as mock_ecdf: with mock.patch( "tlsfuzzer.analysis.Analysis.box_plot") as mock_box: with mock.patch("tlsfuzzer.analysis.Analysis.scatter_plot" ) as mock_scatter: with mock.patch( "tlsfuzzer.analysis.Analysis.conf_interval_plot" ) as mock_conf_int: with mock.patch("__main__.__builtins__.open", mock.mock_open()) as mock_open: with mock.patch("builtins.print"): with mock.patch( "tlsfuzzer.analysis.Analysis._convert_to_binary" ): mock_conf_int.side_effect = Exception( "Test") analysis = Analysis( "/tmp", multithreaded_graph=True) with self.assertRaises( Exception) as exc: ret = analysis.generate_report() self.assertIn("Conf interval graph", str(exc.exception))
def test_report_neq(self): timings = pd.DataFrame(data=self.neq_data) mock_read_csv = mock.Mock(spec=pd.read_csv) mock_read_csv.return_value = timings.transpose() with mock.patch("tlsfuzzer.analysis.pd.read_csv", mock_read_csv): with mock.patch("tlsfuzzer.analysis.Analysis.qq_plot") as mock_qq: with mock.patch( "tlsfuzzer.analysis.Analysis.ecdf_plot") as mock_ecdf: with mock.patch("tlsfuzzer.analysis.Analysis.box_plot" ) as mock_box: with mock.patch( "tlsfuzzer.analysis.Analysis.scatter_plot" ) as mock_scatter: with mock.patch("__main__.__builtins__.open", mock.mock_open()) as mock_open: analysis = Analysis("/tmp") ret = analysis.generate_report() mock_read_csv.assert_called_once() mock_qq.assert_called_once() mock_ecdf.assert_called_once() mock_box.assert_called_once() mock_scatter.assert_called_once() mock_open.assert_called_once() self.assertEqual(ret, 1)
def test_report_neq(self): timings = pd.DataFrame(data=self.neq_data) mock_read_csv = mock.Mock() mock_read_csv.return_value = timings with mock.patch("tlsfuzzer.analysis.Analysis.load_data", mock_read_csv): with mock.patch( "tlsfuzzer.analysis.Analysis.ecdf_plot") as mock_ecdf: with mock.patch( "tlsfuzzer.analysis.Analysis.box_plot") as mock_box: with mock.patch("tlsfuzzer.analysis.Analysis.scatter_plot" ) as mock_scatter: with mock.patch( "tlsfuzzer.analysis.Analysis.conf_interval_plot" ) as mock_conf_int: with mock.patch("__main__.__builtins__.open", mock.mock_open()) as mock_open: with mock.patch("builtins.print"): analysis = Analysis("/tmp") ret = analysis.generate_report() mock_read_csv.assert_called_once() #mock_ecdf.assert_called_once() #mock_box.assert_called_once() #mock_scatter.assert_called_once() # we're writing to report.csv, legend.csv, # and report.txt self.assertEqual(mock_open.call_count, 3) self.assertEqual(ret, 1)
def test_report(self): with mock.patch("tlsfuzzer.analysis.Analysis.load_data", self.mock_read_csv): with mock.patch( "tlsfuzzer.analysis.Analysis.ecdf_plot") as mock_ecdf: with mock.patch( "tlsfuzzer.analysis.Analysis.box_plot") as mock_box: with mock.patch("tlsfuzzer.analysis.Analysis.scatter_plot" ) as mock_scatter: with mock.patch( "tlsfuzzer.analysis.Analysis.conf_interval_plot" ) as mock_conf_int: with mock.patch("__main__.__builtins__.open", mock.mock_open()) as mock_open: with mock.patch("builtins.print"): with mock.patch( "tlsfuzzer.analysis.Analysis._convert_to_binary" ): analysis = Analysis("/tmp") ret = analysis.generate_report() self.mock_read_csv.assert_called_once() #mock_ecdf.assert_called_once() #mock_box.assert_called_once() #mock_scatter.assert_called_once() # we're writing to report.csv, legend.csv, and # report.txt self.assertEqual( mock_open.call_count, 3) self.assertEqual(ret, 0)
def analyse(self): """ Starts analysis if available :return: int 0 for no difference, 1 for difference, 2 unavailable """ if self.check_analysis_availability(): from tlsfuzzer.analysis import Analysis analysis = Analysis(self.out_dir) return analysis.generate_report() print("Analysis is not available. " "Install required packages to enable.") return 2
def test_report(self): with mock.patch("tlsfuzzer.analysis.pd.read_csv", self.mock_read_csv): with mock.patch("tlsfuzzer.analysis.Analysis.qq_plot") as mock_qq: with mock.patch( "tlsfuzzer.analysis.Analysis.ecdf_plot") as mock_ecdf: with mock.patch("tlsfuzzer.analysis.Analysis.box_plot" ) as mock_box: with mock.patch( "tlsfuzzer.analysis.Analysis.scatter_plot" ) as mock_scatter: with mock.patch("__main__.__builtins__.open", mock.mock_open()) as mock_open: analysis = Analysis("/tmp") ret = analysis.generate_report() self.mock_read_csv.assert_called_once() mock_qq.assert_called_once() mock_ecdf.assert_called_once() mock_box.assert_called_once() mock_scatter.assert_called_once() mock_open.assert_called_once() self.assertEqual(ret, 0)