async def test_signal(loop): gr = GroupResolver() context = Context({}, loop=loop, group_resolver=gr) s = Signal(context) s.append(1, ('1', )) s.append(1) await s.send(gr) await s.send(GroupResolver(all_groups=True))
def context(loop, config): with Context( config, loop=loop, # Run all groups group_resolver=GroupResolver( include=['web', 'workers', 'engine'])) as ctx: yield ctx
def context(loop, groups, config): from aioworkers.core.context import Context, GroupResolver gr = GroupResolver( include=groups.include, exclude=groups.exclude, ) with Context(config, group_resolver=gr, loop=loop) as ctx: yield ctx
def context(loop, groups, config): gr = GroupResolver(**groups) with Context(config, loop=loop, group_resolver=gr) as ctx: yield ctx
def test_group_resolver(): gr = GroupResolver() assert not gr.match(['1']) assert gr.match(None) gr = GroupResolver(all_groups=True) assert gr.match(['1']) assert gr.match(None) gr = GroupResolver(default=False) assert not gr.match(['1']) assert not gr.match(None) gr = GroupResolver(exclude=['1']) assert not gr.match(['1']) assert not gr.match(['1', '2']) assert gr.match(None) gr = GroupResolver(exclude=['1'], all_groups=True) assert not gr.match(['1']) assert not gr.match(['1', '2']) assert gr.match(None) gr = GroupResolver(include=['1']) assert gr.match(['1']) assert gr.match(None)