Exemplo n.º 1
0
    def testPopEvent(self):
        """Tests the PopEvent function."""
        event_heap = event_heaps.SerializedStreamEventHeap()

        test_event = event_heap.PopEvent()
        self.assertEqual(test_event, (None, None))

        with shared_test_lib.TempDirectory() as temp_directory:
            temp_file = os.path.join(temp_directory, u'storage.plaso')
            storage_file = zip_file.ZIPStorageFile()
            storage_file.Open(path=temp_file, read_only=False)

            test_events = self._CreateTestEvents()
            for event in test_events:
                storage_file.AddEvent(event)
                event_heap.PushEvent(event)

            test_event, stream_number = event_heap.PopEvent()
            self.assertEqual(test_event, test_events[3])
            self.assertEqual(stream_number, 1)

            test_event, _ = event_heap.PopEvent()
            self.assertEqual(test_event, test_events[2])

            test_event, _ = event_heap.PopEvent()
            self.assertEqual(test_event, test_events[0])

            test_event, _ = event_heap.PopEvent()
            self.assertEqual(test_event, test_events[1])
Exemplo n.º 2
0
    def testPushEvent(self):
        """Tests the PushEvent function."""
        event_heap = event_heaps.SerializedStreamEventHeap()

        with shared_test_lib.TempDirectory() as temp_directory:
            temp_file = os.path.join(temp_directory, u'storage.plaso')
            storage_file = zip_file.ZIPStorageFile()
            storage_file.Open(path=temp_file, read_only=False)

            test_events = self._CreateTestEvents()
            for event in test_events:
                storage_file.AddEvent(event)
                event_heap.PushEvent(event)

            self.assertEqual(event_heap.number_of_events, 4)
Exemplo n.º 3
0
 def testNumberOfEvents(self):
     """Tests the number_of_events property."""
     event_heap = event_heaps.SerializedStreamEventHeap()
     self.assertEqual(event_heap.number_of_events, 0)