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'
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')
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'
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')
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'