Esempio 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
Esempio 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'
Esempio 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
Esempio 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'
Esempio 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'
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)
def config(celery_config):
    return config_factory.create('dict', celery=celery_config)
def config(flask_config):
    return config_factory.create('dict', **{'flask': flask_config})
def config(socketio_config):
    return config_factory.create('dict', **{'socketio': socketio_config})
Esempio n. 10
0
    def test_undefined_config_type(self):
        config_type = 'undefined'

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