Exemple #1
0
 def test_get_all_event_functions(self):
     event_system.subscribe_to_event('event', self.assertIsNotNone)
     functions = event_system.get_all_event_functions('event')
     self.assertEqual(len(functions), 1)
     for func in functions:
         self.assertTrue(callable(func))
     event_system.subscribe_to_event('event', self.assertIsNotNone)
     event_system.subscribe_to_event('event2', self.assertIsNotNone)
     functions = event_system.get_all_event_functions('event')
     self.assertEqual(len(functions), 2)
     for func in functions:
         self.assertTrue(callable(func))
Exemple #2
0
 def test_sub_publish_unsub(self):
     event_system.subscribe_to_event('event', self.assertIsNotNone)
     event_system.subscribe_to_event('event', raises_exception_on_no_data)
     event_system.subscribe_to_event('error', raises_exception_on_call)
     with self.assertLogs(logger=event_system.__name__,
                          level='ERROR') as cm:
         event_system.publish_event('error', {'some': 'data'})
     self.assertEqual(len(cm.records), 1)
     event_system.unsubscribe_from_event('event', self.assertIsNotNone)
     event_system.unsubscribe_from_event('event',
                                         raises_exception_on_no_data)
     event_system.unsubscribe_from_event('error', raises_exception_on_call)
     event_system.publish_event('event', None)
     event_system.publish_event('error', {})
Exemple #3
0
def subscribe():
    subscribe_to_event('deployment', handle_deployment)
Exemple #4
0
def subscribe():
    logger = logging.getLogger(__name__)
    logger.info('Adding Slack Recommendations as a subscriber.')
    subscribe_to_event('recommendation', handle_recommendation)
Exemple #5
0
def subscribe():
    subscribe_to_event('error', handle_error)