def test_on_sync(self): setup = BoboSetup() setup.add_complex_event(event_def=BoboComplexEvent( name=NAME_NFA_A, pattern=stub_pattern_4, action=NoAction())) setup.config_null_data(delay_sec=NULL_DATA_DELAY, null_data=BoboNullDataStatic(DATA_DICT_A)) setup.config_distributed(exchange_name=EXCHANGE_NAME, user_name=USER_NAME, parameters=parameters) setup.configure() self.assertFalse(setup.get_receiver().is_active()) self.assertFalse(setup.get_decider().is_active()) self.assertFalse(setup.get_producer().is_active()) self.assertFalse(setup.get_forwarder().is_active()) self.assertFalse(setup.get_null_data_generator().is_active()) setup.on_sync() self.assertTrue(setup.get_receiver().is_active()) self.assertTrue(setup.get_decider().is_active()) self.assertTrue(setup.get_producer().is_active()) self.assertTrue(setup.get_forwarder().is_active()) self.assertTrue(setup.get_null_data_generator().is_active())
def test_config_arguments(self): setup = BoboSetup() event_def = BoboComplexEvent(NAME_NFA_A, stub_pattern_1) validator = StrDictValidator() action_producer = RateLimitAction() action_forwarder = NoAction() null_data = BoboNullDataStatic(DATA_DICT_A) setup.add_complex_event(event_def) setup.config_receiver(validator) setup.config_producer(action_producer) setup.config_forwarder(action_forwarder) setup.config_null_data(NULL_DATA_DELAY, null_data) setup.config_distributed(EXCHANGE_NAME, USER_NAME, parameters) setup.configure() receiver = setup.get_receiver() decider = setup.get_decider() producer = setup.get_producer() forwarder = setup.get_forwarder() nullgen = setup.get_null_data_generator() manager = setup.get_distributed() self.assertEqual(validator, receiver.get_validator()) self.assertEqual(NAME_NFA_A, decider.get_all_handlers()[0].nfa.name) self.assertEqual(action_producer, producer._action) self.assertEqual(action_forwarder, forwarder._action) self.assertEqual(null_data, nullgen.null_data) self.assertEqual(receiver, nullgen.receiver) self.assertEqual(manager.outgoing.decider, decider) self.assertEqual(manager.outgoing.exchange_name, EXCHANGE_NAME) self.assertTrue(manager.outgoing.user_id.find(USER_NAME) != -1) self.assertEqual(manager.outgoing.parameters, parameters) self.assertEqual(manager.incoming.decider, decider) self.assertEqual(manager.incoming.exchange_name, EXCHANGE_NAME) self.assertTrue(manager.incoming.user_id.find(USER_NAME) != -1) self.assertEqual(manager.incoming.parameters, parameters)