def testPopEvent(self): """Tests the PopEvent function.""" event_heap = event_heaps.SerializedEventHeap() self.assertEqual(len(event_heap._heap), 0) test_timestamp, test_event_data = event_heap.PopEvent() self.assertIsNone(test_timestamp) self.assertIsNone(test_event_data) event_heap.PushEvent(5134324321, b'event_data1') event_heap.PushEvent(2345871286, b'event_data2') self.assertEqual(len(event_heap._heap), 2) test_timestamp, test_event_data = event_heap.PopEvent() self.assertEqual(test_timestamp, 2345871286) self.assertEqual(test_event_data, b'event_data2') self.assertEqual(len(event_heap._heap), 1)
def __init__(self, maximum_buffer_size=0, storage_type=definitions.STORAGE_TYPE_SESSION): """Initializes a store. Args: maximum_buffer_size (Optional[int]): maximum size of a single storage stream. A value of 0 indicates the limit is _MAXIMUM_BUFFER_SIZE. storage_type (Optional[str]): storage type. Raises: ValueError: if the maximum buffer size value is out of bounds. """ if (maximum_buffer_size < 0 or maximum_buffer_size > self._MAXIMUM_BUFFER_SIZE): raise ValueError('Maximum buffer size value out of bounds.') if not maximum_buffer_size: maximum_buffer_size = self._MAXIMUM_BUFFER_SIZE super(SQLiteStorageFile, self).__init__() self._connection = None self._cursor = None self._last_session = 0 self._maximum_buffer_size = maximum_buffer_size self._serialized_event_heap = event_heaps.SerializedEventHeap() if storage_type == definitions.STORAGE_TYPE_SESSION: self.compression_format = definitions.COMPRESSION_FORMAT_ZLIB else: self.compression_format = definitions.COMPRESSION_FORMAT_NONE self.format_version = self._FORMAT_VERSION self.serialization_format = definitions.SERIALIZER_FORMAT_JSON self.storage_type = storage_type
def testNumberOfEvents(self): """Tests the number_of_events property.""" event_heap = event_heaps.SerializedEventHeap() self.assertEqual(event_heap.number_of_events, 0)