Ejemplo n.º 1
0
    def test_subscribe_forward_action_failure(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 Forwarder
        setup.config_forwarder(NoAction(bool_return=False))

        setup.subscribe_forwarder(sub)
        setup.configure()

        forwarder = setup.get_forwarder()
        forwarder.setup()

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

        forwarder.on_producer_action(a_event)
        forwarder.loop()

        self.assertEqual(a_event, sub.forwarder_failure_event[0])
Ejemplo n.º 2
0
    def test_subscribe_forward_composite_success(self):
        setup = BoboSetup()
        sub = StubSubscriberSetup()

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

        setup.subscribe_forwarder(sub)
        setup.configure()

        forwarder = setup.get_forwarder()
        forwarder.setup()

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

        forwarder.on_accepted_producer_event(c_event)
        forwarder.loop()

        self.assertEqual(c_event, sub.forwarder_success_event[0])