def testTagAndCompileReport(self): """Tests the Sessionize plugin.""" plugin = sessionize.SessionizeAnalysisPlugin() plugin.SetMaximumPause(10) storage_writer = self._AnalyzeEvents(self._TEST_EVENTS, plugin) number_of_reports = storage_writer.GetNumberOfAttributeContainers( 'analysis_report') self.assertEqual(number_of_reports, 1) analysis_report = storage_writer.GetAttributeContainerByIndex( reports.AnalysisReport.CONTAINER_TYPE, 0) self.assertIsNotNone(analysis_report) self.assertEqual(analysis_report.plugin_name, 'sessionize') expected_analysis_counter = collections.Counter({ 'session_0': 3, 'session_1': 2}) self.assertEqual( analysis_report.analysis_counter, expected_analysis_counter) number_of_event_tags = storage_writer.GetNumberOfAttributeContainers( 'event_tag') self.assertEqual(number_of_event_tags, 5)
def testTagAndCompileReport(self): """Tests the Sessionize plugin.""" plugin = sessionize.SessionizeAnalysisPlugin() plugin.SetMaximumPause(10) storage_writer = self._AnalyzeEvents(self._TEST_EVENTS, plugin) self.assertEqual(len(storage_writer.analysis_reports), 1) self.assertEqual(storage_writer.number_of_event_tags, 5) report = storage_writer.analysis_reports[0] expected_report_text = ( 'Sessionize plugin identified 2 sessions and applied 5 tags.\n' '\tSession 0: 3 events\n' '\tSession 1: 2 events') self.assertEqual(report.text, expected_report_text)
def testTagAndCompileReport(self): """Tests the Sessionize plugin.""" plugin = sessionize.SessionizeAnalysisPlugin() plugin.SetMaximumPause(10) storage_writer = self._AnalyzeEvents(self._TEST_EVENTS, plugin) self.assertEqual(storage_writer.number_of_analysis_reports, 1) self.assertEqual(storage_writer.number_of_event_tags, 5) analysis_report = storage_writer.GetAttributeContainerByIndex( reports.AnalysisReport.CONTAINER_TYPE, 0) self.assertIsNotNone(analysis_report) self.assertEqual(analysis_report.analysis_counter['session_0'], 3) self.assertEqual(analysis_report.analysis_counter['session_1'], 2)
def testTagAndCompileReport(self): """Tests the Sessionize plugin.""" plugin = sessionize.SessionizeAnalysisPlugin() plugin.SetMaximumPause(10) storage_writer = self._AnalyzeEvents(self._TEST_EVENTS, plugin) self.assertEqual(storage_writer.number_of_analysis_reports, 1) self.assertEqual(storage_writer.number_of_event_tags, 5) report = storage_writer.GetAttributeContainerByIndex( reports.AnalysisReport.CONTAINER_TYPE, 0) self.assertIsNotNone(report) expected_report_text = ( 'Sessionize plugin identified 2 sessions and applied 5 tags.\n' '\tSession 0: 3 events\n' '\tSession 1: 2 events') self.assertEqual(report.text, expected_report_text)
def testParseOptions(self): """Tests the ParseOptions function.""" options = cli_test_lib.TestOptions() analysis_plugin = sessionize.SessionizeAnalysisPlugin() sessionize_analysis.SessionizeAnalysisArgumentsHelper.ParseOptions( options, analysis_plugin) with self.assertRaises(errors.BadConfigObject): sessionize_analysis.SessionizeAnalysisArgumentsHelper.ParseOptions( options, None) options.sessionize_maximumpause = 0 with self.assertRaises(errors.BadConfigOption): sessionize_analysis.SessionizeAnalysisArgumentsHelper.ParseOptions( options, analysis_plugin) options.sessionize_maximumpause = 'ten' with self.assertRaises(errors.BadConfigOption): sessionize_analysis.SessionizeAnalysisArgumentsHelper.ParseOptions( options, analysis_plugin)