def test_apply_not_accepted(self): mixin = ProcessorMixin() mixin._telemetry_processors = [] def callback_function(envelope): return envelope.baseType == 'type2' mixin.add_telemetry_processor(callback_function) envelope = Envelope() envelope.baseType = 'type1' envelope2 = Envelope() envelope2.baseType = 'type2' envelopes = mixin.apply_telemetry_processors([envelope, envelope2]) self.assertEqual(len(envelopes), 1) self.assertEqual(envelopes[0].baseType, 'type2')
def test_apply(self): mixin = ProcessorMixin() mixin._telemetry_processors = [] def callback_function(envelope): envelope.baseType += '_world' mixin.add_telemetry_processor(callback_function) envelope = Envelope() envelope.baseType = 'type1' mixin.apply_telemetry_processors([envelope]) self.assertEqual(envelope.baseType, 'type1_world')
def test_apply_exception(self): mixin = ProcessorMixin() mixin._telemetry_processors = [] def callback_function(envelope): raise ValueError() def callback_function2(envelope): envelope.baseType += '_world2' mixin.add_telemetry_processor(callback_function) mixin.add_telemetry_processor(callback_function2) envelope = Envelope() envelope.baseType = 'type1' mixin.apply_telemetry_processors([envelope]) self.assertEqual(envelope.baseType, 'type1_world2')