示例#1
0
def test_load_from_file():
    source = 'file://' + str(Path(__file__).parent / 'stuff.json')
    signals, queues = load_stuff(source)
    assert len(signals) == 2
    assert len(queues) == 1
    assert signals.test_signal.name == 'test_signal'
    assert signals.else_signal.name == 'else_signal'
    assert queues.test_queue.name == 'test_queue'
示例#2
0
def test_load_from_url():
    source = 'https://gist.githubusercontent.com/scailer/ee0baed54a9444f328c9d0fd4ed84bed/raw/dfae17935813ee6a0ef0d441cbebc19572f8488c/stuff.json'  # noqa
    signals, queues = load_stuff(source)
    assert len(signals) == 2
    assert len(queues) == 1
    assert signals.test_signal.name == 'test_signal'
    assert signals.else_signal.name == 'else_signal'
    assert queues.test_queue.name == 'test_queue'
示例#3
0
def test_load_from_url():
    source = 'http://lwr.pw/matest'  # noqa
    signals, queues = load_stuff(source)
    assert len(signals) == 2
    assert len(queues) == 1
    assert signals.test_signal.name == 'test_signal'
    assert signals.else_signal.name == 'else_signal'
    assert queues.test_queue.name == 'test_queue'
示例#4
0
import os
from microagent import MicroAgent, on, consumer, load_stuff

cur_dir = os.path.dirname(os.path.realpath(__file__))
signals, queues = load_stuff('file://' + os.path.join(cur_dir, 'signals.json'))


class EmailAgent(MicroAgent):
    @on('pre_start')
    async def setup(self):
        self.log.info('Run ...\n %s', self.info())

    @consumer(queues.mailer)
    async def example_read_queue(self, **kwargs):
        self.log.info('Catch emailer %s', kwargs)