Esempio n. 1
0
    def test_subscribe_producer_composite_rejected(self):
        setup = BoboSetup()
        sub = StubSubscriberSetup()

        setup.add_complex_event(event_def=BoboComplexEvent(
            name=NAME_NFA_A, pattern=stub_pattern_1, action=NoAction()))

        # this rejects all events passed to Producer
        setup.config_producer(NoAction(bool_return=False))

        setup.subscribe_producer(NAME_NFA_A, sub)
        setup.configure()

        producer = setup.get_producer()
        producer.setup()

        c_event = CompositeEvent(timestamp=EpochNSClock.generate_timestamp(),
                                 name=NAME_NFA_A,
                                 history=BoboHistory(),
                                 data={})

        producer.on_decider_complex_event(c_event)
        producer.loop()

        self.assertEqual(c_event, sub.rejected_producer_event[0])
Esempio n. 2
0
    def test_subscribe_producer_action(self):
        setup = BoboSetup()
        sub = StubSubscriberSetup()

        setup.add_complex_event(event_def=BoboComplexEvent(
            name=NAME_NFA_A, pattern=stub_pattern_1, action=NoAction()))

        setup.subscribe_producer(NAME_NFA_A, sub)
        setup.configure()

        producer = setup.get_producer()
        producer.setup()

        a_event = NoAction().execute(
            CompositeEvent(timestamp=EpochNSClock.generate_timestamp(),
                           name=NAME_NFA_A,
                           history=BoboHistory(),
                           data={}))

        producer.on_action_attempt(a_event)
        producer.loop()

        self.assertEqual(a_event, sub.producer_action[0])