Ejemplo n.º 1
0
    def test_primitive_none(self):
        p_timestamp = EpochNSClock.generate_timestamp()
        p_data = DATA_A
        p_id = EVENT_ID_A

        with self.assertRaises(RuntimeError):
            BoboRuleBuilder.primitive({
                PrimitiveEvent.TIMESTAMP: None,
                PrimitiveEvent.DATA: p_data,
                PrimitiveEvent.EVENT_ID: p_id
            })

        with self.assertRaises(RuntimeError):
            BoboRuleBuilder.primitive({
                PrimitiveEvent.TIMESTAMP: p_timestamp,
                PrimitiveEvent.DATA: None,
                PrimitiveEvent.EVENT_ID: p_id
            })

        with self.assertRaises(RuntimeError):
            BoboRuleBuilder.primitive({
                PrimitiveEvent.TIMESTAMP: p_timestamp,
                PrimitiveEvent.DATA: p_data,
                PrimitiveEvent.EVENT_ID: None
            })
Ejemplo n.º 2
0
    def test_primitive(self):
        # primitive event data
        p_timestamp = EpochNSClock.generate_timestamp()
        p_data = DATA_A
        p_id = EVENT_ID_A

        # Create dict representation of primitive event
        p_dict = {
            PrimitiveEvent.TIMESTAMP: p_timestamp,
            PrimitiveEvent.DATA: p_data,
            PrimitiveEvent.EVENT_ID: p_id
        }

        # Build actual primitive event from dict
        p_event_1 = BoboRuleBuilder.primitive(p_dict)
        p_event_2 = BoboRuleBuilder.event(p_dict)

        for p_event in [p_event_1, p_event_2]:
            self.assertEqual(p_event.timestamp, p_timestamp)
            self.assertEqual(p_event.data, p_data)
            self.assertEqual(p_event.event_id, p_id)