Example #1
0
def test_factories():
    for factory_name, dependencies in test_tuples:
        factory = factory_builder.build(config, name=factory_name)

        injector = Injectark(factory=factory)

        for abstract, concrete in dependencies:
            result = injector.resolve(abstract)
            assert type(result).__name__ == concrete
Example #2
0
async def test_config(test_data):
    for config in test_data:
        factory = build_factory(config)
        strategy = build_strategy(config['strategies'], config['strategy'])
        resolver = Injectark(strategy=strategy, factory=factory)
        resolver["TenantProvider"].setup(Tenant(id="1", name="default"))
        for resource in strategy.keys():
            result = resolver.resolve(resource)
            classes = inspect.getmro(type(result))
            assert resource in [item.__name__ for item in classes]
Example #3
0
def test_factories():
    for factory_name, strategy_names in test_tuples:
        factory = factory_builder.build(config, name=factory_name)
        strategy = strategy_builder.build(strategy_names)

        injector = Injectark(strategy=strategy, factory=factory)

        for resource in strategy.keys():
            result = injector.resolve(resource)
            classes = inspect.getmro(type(result))
            assert resource in [item.__name__ for item in classes]
Example #4
0
async def main(args=None):  # pragma: no cover
    logging.basicConfig()
    logging.getLogger().setLevel(config['loglevel'])
    factory = factory_builder.build(config)
    injector = Injectark(factory=factory)

    await Shell(config, injector).run(args or [])
Example #5
0
def scheduler() -> Scheduler:
    config['factory'] = 'CheckFactory'
    factory = factory_builder.build(config)

    injector = Injectark(factory)

    return Scheduler(injector)
Example #6
0
def shell() -> Shell:
    config['factory'] = 'CheckFactory'
    factory = factory_builder.build(config)

    injector = Injectark(factory)

    return Shell(injector)
Example #7
0
async def main(args=None):  # pragma: no cover
    strategy = strategy_builder.build(config['strategies'])
    factory = factory_builder.build(config)
    injector = Injectark(strategy=strategy, factory=factory)
    if config.get('auto'):
        injector['MigrationSupplier'].migrate()

    await Shell(config, injector).run(args or [])
Example #8
0
def cli() -> Cli:
    """Create app testing client"""
    config = DEVELOPMENT_CONFIG
    strategy = strategy_builder.build(config['strategies'], config['strategy'])
    factory = factory_builder.build(config)

    injector = Injectark(strategy, factory)

    return Cli(config, injector)
Example #9
0
async def main(args=None):
    factory = factory_builder.build(config)
    injector = Injectark(factory)
    await injector['SetupManager'].setup({})

    await Shell(config, injector).run(args or [])

    del injector
    await asyncio.gather(*asyncio.all_tasks())
Example #10
0
def shell() -> Shell:
    """Create app testing client"""
    config['factory'] = 'CheckFactory'

    factory = factory_builder.build(config)

    injector = Injectark(factory)

    return Shell(config, injector)
Example #11
0
def app(loop, aiohttp_client):
    config['factory'] = 'CheckFactory'
    factory = factory_builder.build(config)

    injector = Injectark(factory)

    app = RestApplication(injector)

    return loop.run_until_complete(aiohttp_client(app))
Example #12
0
def app(tmp_path, loop, aiohttp_client) -> web.Application:
    config = build_config('DEV')
    strategy = build_strategy(config['strategies'], config['strategy'])
    factory = build_factory(config)

    resolver = Injectark(strategy, factory)

    app = create_app(config, resolver)

    return loop.run_until_complete(aiohttp_client(app))
Example #13
0
def main(args):  # pragma: no cover
    mode = os.environ.get('ESTIMARK_MODE', 'PROD')
    config_path = os.environ.get('ESTIMARK_CONFIG', 'config.json')
    config = build_config(config_path, mode)

    factory = build_factory(config)
    strategy = config['strategy']
    resolver = Injectark(strategy=strategy, factory=factory)

    Cli(config, resolver).run(args)
Example #14
0
def shell() -> Shell:
    config['factory'] = 'BaseFactory'
    config['strategies'] = ['base']

    strategy = strategy_builder.build(config['strategies'])
    factory = factory_builder.build(config)

    injector = Injectark(strategy, factory)

    return Shell(config, injector)
Example #15
0
def app(loop, aiohttp_client):
    config['factory'] = 'CheckFactory'
    config['tokens']['verification']['secret'] = ('DEVSECRET123')
    factory = factory_builder.build(config)

    injector = Injectark(factory)

    app = RestApplication(injector)

    return loop.run_until_complete(aiohttp_client(app))
Example #16
0
def test_create_app():
    config['factory'] = 'CheckFactory'
    factory = factory_builder.build(config)

    injector = Injectark(factory)

    app = create_app(config, injector)

    assert app is not None
    assert isinstance(app, web.Application)
Example #17
0
def main(args: List[str] = None):  # pragma: no cover
    args = args or sys.argv[1:]
    logging.basicConfig(stream=sys.stdout,
                        level=logging.DEBUG,
                        format='%(message)s')

    factory = factory_builder.build(config)

    injector = Injectark(factory)

    Shell(config, injector).run(args)
Example #18
0
def app(loop, aiohttp_client):
    """Create app testing client"""
    config = DEVELOPMENT_CONFIG
    strategy = strategy_builder.build(config['strategies'])
    factory = factory_builder.build(config)

    resolver = Injectark(strategy, factory)

    app = create_app(config, resolver)

    return loop.run_until_complete(aiohttp_client(app))
Example #19
0
def test_create_app():
    config = build_config('DEV')
    strategy = build_strategy(config['strategies'], config['strategy'])
    factory = build_factory(config)

    injector = Injectark(strategy, factory)

    app = create_app(config, injector)

    assert app is not None
    assert isinstance(app, web.Application)
Example #20
0
def app(loop, aiohttp_client):
    """Create app testing client"""
    config['factory'] = 'CheckFactory'

    factory = factory_builder.build(config)

    injector = Injectark(factory)

    app = create_app(config, injector)

    return loop.run_until_complete(aiohttp_client(app))
Example #21
0
async def main(args=None):  # pragma: no cover
    mode = os.environ.get('MEDIARK_MODE', 'PROD')
    config_path = os.environ.get('MEDIARK_CONFIG', 'config.json')
    config = build_config(mode, config_path)

    factory = build_factory(config)
    strategy = build_strategy(config['strategies'], config['strategy'])
    injector = Injectark(strategy=strategy, factory=factory)
    injector['SetupSupplier'].setup()

    await Cli(config, injector).run(args or [])
Example #22
0
def test_create_app():
    config = DEVELOPMENT_CONFIG
    strategy = strategy_builder.build(config['strategies'])
    factory = factory_builder.build(config)

    injector = Injectark(strategy, factory)

    app = create_app(config, injector)

    assert app is not None
    assert isinstance(app, web.Application)
Example #23
0
def app(loop, aiohttp_client):
    """Create app testing client"""
    config['factory'] = 'CheckFactory'
    config['strategies'] = ['base', 'check']

    strategy = strategy_builder.build(config['strategies'])
    factory = factory_builder.build(config)

    injector = Injectark(strategy, factory)

    app = RestApplication(config, injector)

    return loop.run_until_complete(aiohttp_client(app))
Example #24
0
async def main(args=None):  # pragma: no cover
    config_path = Path(os.environ.get('PROCESARK_CONFIG', 'config.json'))
    config = loads(config_path.read_text()) if config_path.is_file() else {}
    config: Config = {**PRODUCTION_CONFIG, **config}

    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG,
                        format='%(message)s')

    factory = factory_builder.build(config)
    strategy = strategy_builder.build(
        config['strategies'], config['strategy'])
    injector = Injectark(strategy=strategy, factory=factory)
    # injector['SetupSupplier'].setup()

    await Cli(config, injector).run(args or [])
Example #25
0
async def main(args=None):  # pragma: no cover
    factory = factory_builder.build(config)
    injector = Injectark(factory=factory)
    await Shell(injector).run(args or [])
Example #26
0
def trial_resolver(trial_config) -> Injectark:
    config = trial_config
    factory = build_factory(config)
    strategy = config['strategy']
    resolver = Injectark(strategy=strategy, factory=factory)
    return resolver
Example #27
0
def injector(config):
    config['factory'] = 'CheckFactory'
    factory = factory_builder.build(config)

    return Injectark(factory)
Example #28
0
def injector(factory):
    injector = Injectark(factory)
    injector.config['notification']['url'] = ('https://api.service.com/events')
    return injector