Пример #1
0
def test_get_key_success(monkeypatch):
    def get_config(appname):
        return {'section': {'key': 'value'}}

    monkeypatch.setattr('qwcore.config.get_config', get_config)
    config.get_value('app', 'key', section='section',
                     default='default') == 'value'
Пример #2
0
def test_get_key_key_not_found(monkeypatch):
    def get_config(appname):
        return {'section': {}}

    monkeypatch.setattr('qwcore.config.get_config', get_config)
    with pytest.raises(exception.ConfigFileKeyNotFoundError):
        config.get_value('app', 'key', section='section')
Пример #3
0
def test_get_key_key_not_found_default(monkeypatch):
    def get_config(appname):
        return {'section': {}}

    monkeypatch.setattr('qwcore.config.get_config', get_config)
    config.get_value('app', 'key', section='section',
                     default='default') == 'default'
Пример #4
0
def test_get_key_config_not_found(monkeypatch):
    def get_config(appname):
        raise exception.ConfigFileNotFoundError()

    monkeypatch.setattr('qwcore.config.get_config', get_config)
    with pytest.raises(exception.ConfigFileNotFoundError):
        config.get_value('app', 'key')
Пример #5
0
def test_get_key_config_not_found_default(monkeypatch):
    def get_config(appname):
        raise exception.ConfigFileNotFoundError()

    monkeypatch.setattr('qwcore.config.get_config', get_config)
    config.get_value('app', 'key', default='default') == 'default'
Пример #6
0
def test_get_key_success(monkeypatch):
    def get_config(appname):
        return {'section': {'key': 'value'}}
    monkeypatch.setattr('qwcore.config.get_config', get_config)
    config.get_value('app', 'key', section='section', default='default') == 'value'
Пример #7
0
def test_get_key_key_not_found_default(monkeypatch):
    def get_config(appname):
        return {'section': {}}
    monkeypatch.setattr('qwcore.config.get_config', get_config)
    config.get_value('app', 'key', section='section', default='default') == 'default'
Пример #8
0
def test_get_key_key_not_found(monkeypatch):
    def get_config(appname):
        return {'section': {}}
    monkeypatch.setattr('qwcore.config.get_config', get_config)
    with pytest.raises(exception.ConfigFileKeyNotFoundError):
        config.get_value('app', 'key', section='section')
Пример #9
0
def test_get_key_config_not_found_default(monkeypatch):
    def get_config(appname):
        raise exception.ConfigFileNotFoundError()
    monkeypatch.setattr('qwcore.config.get_config', get_config)
    config.get_value('app', 'key', default='default') == 'default'
Пример #10
0
def test_get_key_config_not_found(monkeypatch):
    def get_config(appname):
        raise exception.ConfigFileNotFoundError()
    monkeypatch.setattr('qwcore.config.get_config', get_config)
    with pytest.raises(exception.ConfigFileNotFoundError):
        config.get_value('app', 'key')