Exemplo n.º 1
0
    def test_dict_config_type(self):
        config_type = 'dict'
        config_dict = {
            'foo': 'bar',
            'bar': 'baz',
        }

        config = config_factory.create(config_type, **config_dict)

        assert config == config_dict
Exemplo n.º 2
0
    def test_get_value(self, monkeypatch):
        monkeypatch.setenv('TESTING_KEY', 'value')
        config_type = 'env'
        config_opt = {
            'bar': 'baz',
        }
        config = config_factory.create(config_type, **config_opt)

        result = config.get('key2', 'undefined')

        assert result == 'undefined'
Exemplo n.º 3
0
    def test_get_section(self):
        config_type = 'env'
        config_opt = {
            'bar': 'baz',
        }

        config = config_factory.create(config_type, **config_opt)

        result = config.get_section('UNDEFINED')

        assert result.__class__ is EnvSection
Exemplo n.º 4
0
    def test_section_option(self, monkeypatch):
        monkeypatch.setenv('TESTING_KEY', 'value')
        config_type = 'env'
        config_opt = {
            'bar': 'baz',
        }
        config = config_factory.create(config_type, **config_opt)
        section = config.get_section('TESTING')

        result = section['key']

        assert result == 'value'
Exemplo n.º 5
0
    def test_get_section_default_value(self):
        config_type = 'env'
        config_opt = {
            'bar': 'baz',
        }

        config = config_factory.create(config_type, **config_opt)

        section = config.get_section('UNDEFINED')

        result = section.get('UNDEFINED', 'undefined')

        assert result == 'undefined'
Exemplo n.º 6
0
def on_preload_parsed(sender, signal, app, options, **kwargs):
    try:
        config_type = options['config_type']
        config_opt = merge_dict(*options['config_opt'])
        config = config_factory.create(config_type, **config_opt)
    except ConfigPluginNotFoundError as e:
        sender.die('ConfigPluginNotFoundError!', e)

    initial = {
        'config': config,
        'kore.components.celery.application': application,
    }
    container_factory.create(**initial)
Exemplo n.º 7
0
def config(celery_config):
    return config_factory.create('dict', celery=celery_config)
Exemplo n.º 8
0
def config(flask_config):
    return config_factory.create('dict', **{'flask': flask_config})
def config(socketio_config):
    return config_factory.create('dict', **{'socketio': socketio_config})
Exemplo n.º 10
0
    def test_undefined_config_type(self):
        config_type = 'undefined'

        with pytest.raises(ConfigPluginNotFoundError):
            config_factory.create(config_type)