def test_serialize(self, time, uuid): time.return_value = 333 uuid.return_value = "1-2-3-4" event = Event("topic", "type") event.set_field("normal", "value1") event.set_field("obfuscated", "value2", kind=FieldKind.OBFUSCATED) event.set_field("high_cardinality", "value3", kind=FieldKind.HIGH_CARDINALITY) event.set_field("empty", "") event.set_field("null", None) serialized = event.serialize() deserialized = json.loads(serialized) self.assertEqual(deserialized, { "event_topic": "topic", "event_type": "type", "event_ts": 333000, "uuid": "1-2-3-4", "payload": { "normal": "value1", "obfuscated_data": { "obfuscated": "value2", }, "interana_excluded": { "high_cardinality": "value3", }, }, })
def test_serialize(self, time, uuid): time.return_value = 333 uuid.return_value = "1-2-3-4" event = Event("topic", "type") event.set_field("normal", "value1") event.set_field("obfuscated", "value2", obfuscate=True) event.set_field("empty", "") event.set_field("null", None) serialized = event.serialize() deserialized = json.loads(serialized) self.assertEqual(deserialized, { "event_topic": "topic", "event_type": "type", "event_ts": 333000, "uuid": "1-2-3-4", "payload": { "normal": "value1", "obfuscated_data": { "obfuscated": "value2", }, }, })
def test_serialize(self, time, uuid): time.return_value = 333 uuid.return_value = "1-2-3-4" event = Event("topic", "type") event.set_field("normal", "value1") event.set_field("obfuscated", "value2", kind=FieldKind.OBFUSCATED) event.set_field("high_cardinality", "value3", kind=FieldKind.HIGH_CARDINALITY) event.set_field("empty", "") event.set_field("null", None) serialized = event.serialize() deserialized = json.loads(serialized) self.assertEqual( deserialized, { "event_topic": "topic", "event_type": "type", "event_ts": 333000, "uuid": "1-2-3-4", "payload": { "normal": "value1", "obfuscated_data": { "obfuscated": "value2", }, "interana_excluded": { "high_cardinality": "value3", }, }, })