Ejemplo n.º 1
0
def dummy_consumer(test_queue):
    class DummyConsumerMicroAgent(MicroAgent):
        @consumer(test_queue, timeout=60, option1=1)
        def handler(self, **kw):
            pass

    return DummyConsumerMicroAgent(bus=BusMock(), broker=BrokerMock())
Ejemplo n.º 2
0
def dummy_period():
    class DummyPeriodMicroAgent(MicroAgent):
        @periodic(period=60, timeout=55, start_after=30)
        def period_handler(self):
            pass

        @cron('0 * * * *', timeout=60)
        def cron_handler(self):
            pass

    return DummyPeriodMicroAgent(bus=BusMock(), broker=BrokerMock())
Ejemplo n.º 3
0
def dummy_hook():
    class DummyHookMicroAgent(MicroAgent):
        @on('pre_start')
        def pre_setup(self):
            self._setup_pre_called = True

        @on('pre_start')
        def pre_start(self):
            self._start_pre_called = True

        @on('post_start')
        async def post_setup(self):
            self._setup_post_called = True

    return DummyHookMicroAgent(bus=BusMock(), broker=BrokerMock())
Ejemplo n.º 4
0
def dummy_receiver(test_signal, else_signal, test_queue):
    class DummyReceiverMicroAgent(MicroAgent):
        handler = AsyncMock()
        handler_sync = Mock()

        @receiver(test_signal)
        async def handler_one(self, uuid, **kw):
            await self.handler(kw)

        @receiver(test_signal, else_signal, timeout=10)
        async def handler_two(self, **kw):
            await self.handler(kw)

        @receiver(else_signal, timeout=5)
        def handler_three(self, **kw):
            self.handler_sync(kw)

    return DummyReceiverMicroAgent(bus=BusMock(), broker=BrokerMock())