def testAddAnalysisWarning(self): """Tests the AddAnalysisWarning function.""" analysis_warning = warnings.AnalysisWarning( message='Test analysis warning') with shared_test_lib.TempDirectory() as temp_directory: temp_file = os.path.join(temp_directory, 'plaso.sqlite') storage_file = sqlite_file.SQLiteStorageFile() storage_file.Open(path=temp_file, read_only=False) storage_file.AddAnalysisWarning(analysis_warning) storage_file.Close()
def testAddAnalysisWarning(self): """Tests the AddAnalysisWarning function.""" session = sessions.Session() warning = warnings.AnalysisWarning(message='Test analysis warning') storage_writer = fake_writer.FakeStorageWriter(session) storage_writer.Open() storage_writer.AddAnalysisWarning(warning) storage_writer.Close() with self.assertRaises(IOError): storage_writer.AddAnalysisWarning(warning)
def ProduceAnalysisWarning(self, message, plugin_name): """Produces an analysis warning. Args: message (str): message of the warning. plugin_name (str): name of the analysis plugin to which the warning applies. """ warning = warnings.AnalysisWarning(message=message, plugin_name=plugin_name) self._storage_writer.AddAnalysisWarning(warning) self._number_of_warnings += 1 self.last_activity_timestamp = time.time()
def testGetAttributeNames(self): """Tests the GetAttributeNames function.""" attribute_container = warnings.AnalysisWarning() attribute_names = sorted(attribute_container.GetAttributeNames()) self.assertEqual(attribute_names, ['message', 'plugin_name'])