Пример #1
0
    def testPushEvent(self):
        """Tests the PushEvent function."""
        event_heap = psort.PsortEventHeap()

        event = TestEvent(5134324321)
        event_heap.PushEvent(event)

        self.assertEqual(event_heap.number_of_events, 1)
Пример #2
0
    def testPushEvent(self):
        """Tests the PushEvent function."""
        event_heap = psort.PsortEventHeap()

        self.assertEqual(len(event_heap._heap), 0)

        event = containers_test_lib.TestEvent(
            5134324321, attributes=self._TEST_EVENT_ATTRIBUTES)
        event_heap.PushEvent(event)

        self.assertEqual(len(event_heap._heap), 1)
Пример #3
0
    def testPushEvent(self):
        """Tests the PushEvent function."""
        event_heap = psort.PsortEventHeap()

        self.assertEqual(len(event_heap._heap), 0)

        event, event_data, event_data_stream = (
            containers_test_lib.CreateEventFromValues(self._TEST_EVENTS[0]))
        event_heap.PushEvent(event, event_data, event_data_stream)

        self.assertEqual(len(event_heap._heap), 1)
Пример #4
0
    def testPopEvents(self):
        """Tests the PopEvents function."""
        event_heap = psort.PsortEventHeap()

        test_events = list(event_heap.PopEvents())
        self.assertEqual(len(test_events), 0)

        event = TestEvent(5134324321)
        event_heap.PushEvent(event)

        test_events = list(event_heap.PopEvents())
        self.assertEqual(len(test_events), 1)
Пример #5
0
    def testPopEvent(self):
        """Tests the PopEvent function."""
        event_heap = psort.PsortEventHeap()

        test_event = event_heap.PopEvent()
        self.assertIsNone(test_event)

        event = TestEvent(5134324321)
        event_heap.PushEvent(event)

        test_event = event_heap.PopEvent()
        self.assertIsNotNone(test_event)
Пример #6
0
    def testGetEventIdentifiers(self):
        """Tests the _GetEventIdentifiers function."""
        event_heap = psort.PsortEventHeap()

        event, event_data, event_data_stream = (
            containers_test_lib.CreateEventFromValues(self._TEST_EVENTS[0]))
        macb_group_identifier, content_identifier = event_heap._GetEventIdentifiers(
            event, event_data, event_data_stream)

        expected_identifier = 'data_type: test:event'
        self.assertEqual(macb_group_identifier, expected_identifier)

        expected_identifier = 'Metadata Modification Time, data_type: test:event'
        self.assertEqual(content_identifier, expected_identifier)
Пример #7
0
    def testGetEventIdentifiers(self):
        """Tests the _GetEventIdentifiers function."""
        event_heap = psort.PsortEventHeap()

        event = containers_test_lib.TestEvent(
            5134324321, attributes=self._TEST_EVENT_ATTRIBUTES)
        macb_group_identifier, content_identifier = (
            event_heap._GetEventIdentifiers(event))

        expected_identifier = 'data_type: test:event'
        self.assertEqual(macb_group_identifier, expected_identifier)

        expected_identifier = 'Metadata Modification Time, data_type: test:event'
        self.assertEqual(content_identifier, expected_identifier)
Пример #8
0
    def testPopEvents(self):
        """Tests the PopEvents function."""
        event_heap = psort.PsortEventHeap()

        self.assertEqual(len(event_heap._heap), 0)

        test_events = list(event_heap.PopEvents())
        self.assertEqual(len(test_events), 0)

        for event, event_data, event_data_stream in (
                containers_test_lib.CreateEventsFromValues(self._TEST_EVENTS)):
            event_heap.PushEvent(event, event_data, event_data_stream)

        self.assertEqual(len(event_heap._heap), 2)

        test_events = list(event_heap.PopEvents())
        self.assertEqual(len(test_events), 2)

        self.assertEqual(len(event_heap._heap), 0)
Пример #9
0
    def testPopEvent(self):
        """Tests the PopEvent function."""
        event_heap = psort.PsortEventHeap()

        self.assertEqual(len(event_heap._heap), 0)

        test_event = event_heap.PopEvent()
        self.assertIsNone(test_event)

        for event, event_data in containers_test_lib.CreateEventsFromValues(
                self._TEST_EVENTS):
            event_heap.PushEvent(event, event_data)

        self.assertEqual(len(event_heap._heap), 2)

        test_event = event_heap.PopEvent()
        self.assertIsNotNone(test_event)

        self.assertEqual(len(event_heap._heap), 1)
Пример #10
0
    def testPopEvents(self):
        """Tests the PopEvents function."""
        event_heap = psort.PsortEventHeap()

        self.assertEqual(len(event_heap._heap), 0)

        test_events = list(event_heap.PopEvents())
        self.assertEqual(len(test_events), 0)

        event1 = containers_test_lib.TestEvent(
            5134324321, attributes=self._TEST_EVENT_ATTRIBUTES)
        event_heap.PushEvent(event1)

        event2 = containers_test_lib.TestEvent(
            2345871286, attributes=self._TEST_EVENT_ATTRIBUTES)
        event_heap.PushEvent(event2)

        self.assertEqual(len(event_heap._heap), 2)

        test_events = list(event_heap.PopEvents())
        self.assertEqual(len(test_events), 2)

        self.assertEqual(len(event_heap._heap), 0)
Пример #11
0
 def testNumberOfEvents(self):
     """Tests the number_of_events property."""
     event_heap = psort.PsortEventHeap()
     self.assertEqual(event_heap.number_of_events, 0)