def test_raises_AttributeError_if_default_not_given(query): app_conf = conf.Config({'test1': { 'sub': 'test value', }}) with pytest.raises(AttributeError): app_conf.get(query)
def patch_pelconf( values: Optional[conf.ConfigDict] = None, *, path: str = '/fake/proj/pelconf.yaml', ): return patch('peltak.core.conf.g_conf', conf.Config( values=values, path=path, ))
def test_return_default_when_provided_and_value_not_found(query): """ Return default when provided and value not found. And the second line """ app_conf = conf.Config({'test1': { 'sub': 'test value', }}) assert app_conf.get(query, -1) == -1 assert app_conf.get(query, -1) == -1
def test_get_existing_root_value_works(): app_conf = conf.Config({'test1': 'test value'}) assert app_conf.get('test1') == 'test value'
def test_can_just_get_the_full_nested_object(): app_conf = conf.Config({'test1': { 'sub': 'test value', }}) assert app_conf.get('test1') == {'sub': 'test value'}
def test_get_existing_nested_value_works(): app_conf = conf.Config({'test1': { 'sub': 'test value', }}) assert app_conf.get('test1.sub') == 'test value'
def app_conf(): appconf = conf.Config() with patch('peltak.core.conf.g_conf', appconf): yield appconf
def test_works_with_abspath_split_into_parts(): app_conf = conf.Config(path='/fake/proj/pelconf.yaml') assert app_conf.proj_path('/sub', 'testfile') == '/sub/testfile'
def test_can_join_paths(): app_conf = conf.Config(path='/fake/proj/pelconf.yaml') assert app_conf.proj_path('sub', 'testfile') == '/fake/proj/sub/testfile'
def test_returns_input_path_if_no_project_root_found(): # setattr(pelconf._find_proj_root, util.cached_result.CACHE_VAR, None) app_conf = conf.Config() assert app_conf.proj_path('hello/world') == 'hello/world'
def test_does_not_modify_absolute_paths(): app_conf = conf.Config({}, path='/fake/proj/pelconf.yaml') assert app_conf.proj_path('/abs/path') == '/abs/path'
def test_converts_project_path_to_an_absolute_path(proj_path, abs_path): # Patch project root location app_conf = conf.Config({}, path='/fake/proj/pelconf.yaml') assert app_conf.proj_path(proj_path) == abs_path