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'
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'
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'
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)