from pathlib import Path from aioworkers.core.config import Config from aioworkers.core.context import Context config = Config() config.load(Path(__file__).with_suffix('.yaml')) async def test_autorun(loop): async with Context(config.autorun, loop=loop) as ctx: await ctx.sv._future assert ctx.sv._started_at assert not ctx.sv.running() await ctx.sv.stop() assert await ctx.sv.status() assert 2 == await ctx.sv(2) async def run(w, value): return value async def test_super_queue(loop): async with Context(config.super.queue, loop=loop) as ctx: await ctx.q1.put(1) result = await ctx.q2.get() assert result == 1 await ctx.sv(2) result = await ctx.q2.get() assert result == 2
def test_load_config(): p = Path(__file__).parent / 'data' conf = Config(search_dirs=[p]) config = conf.load(p / 'conf1.json', 'conf2.json') assert config assert repr(config)
def config(): c = Config() p = Path(__file__).parent / 'q.ini' c.load(p) return c