Example #1
0
    def test__group_by_time(self):
        event_records = [
            AsciiCastV2Event(0, 'o', b'1', None),
            AsciiCastV2Event(50, 'o', b'2', None),
            AsciiCastV2Event(80, 'o', b'3', None),
            AsciiCastV2Event(200, 'o', b'4', None),
            AsciiCastV2Event(210, 'o', b'5', None),
            AsciiCastV2Event(300, 'o', b'6', None),
            AsciiCastV2Event(310, 'o', b'7', None),
            AsciiCastV2Event(320, 'o', b'8', None),
            AsciiCastV2Event(330, 'o', b'9', None)
        ]

        grouped_event_records = [
            AsciiCastV2Event(0, 'o', b'1', 50),
            AsciiCastV2Event(50, 'o', b'23', 150),
            AsciiCastV2Event(200, 'o', b'45', 100),
            AsciiCastV2Event(300, 'o', b'6789', 1234)
        ]

        result = list(term._group_by_time(event_records, 50, 1234))
        self.assertEqual(grouped_event_records, result)
Example #2
0
            AsciiCastV2Event(20, 'o', b'4', None),
            AsciiCastV2Event(21, 'o', b'5', None),
            AsciiCastV2Event(30, 'o', b'6', None),
            AsciiCastV2Event(31, 'o', b'7', None),
            AsciiCastV2Event(32, 'o', b'8', None),
            AsciiCastV2Event(33, 'o', b'9', None),
            AsciiCastV2Event(43, 'o', b'10', None),
        ]

        with self.subTest(case='maximum record duration'):
            grouped_event_records_max = [
                AsciiCastV2Event(0, 'o', b'1', 5),
                AsciiCastV2Event(5, 'o', b'23', 6),
                AsciiCastV2Event(11, 'o', b'45', 6),
                AsciiCastV2Event(17, 'o', b'6789', 6),
                AsciiCastV2Event(23, 'o', b'10', 1.234),
            ]
            result = list(term._group_by_time(event_records, 5000, 6000, 1234))
            self.assertEqual(grouped_event_records_max, result)

        with self.subTest(case='no maximum record duration'):
            grouped_event_records_no_max = [
                AsciiCastV2Event(0, 'o', b'1', 5),
                AsciiCastV2Event(5, 'o', b'23', 15),
                AsciiCastV2Event(20, 'o', b'45', 10),
                AsciiCastV2Event(30, 'o', b'6789', 13),
                AsciiCastV2Event(43, 'o', b'10', 1.234),
            ]
            result = list(term._group_by_time(event_records, 5000, None, 1234))
            self.assertEqual(grouped_event_records_no_max, result)