コード例 #1
0
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)
コード例 #2
0
ファイル: patches.py プロジェクト: novopl/peltak
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,
                 ))
コード例 #3
0
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
コード例 #4
0
def test_get_existing_root_value_works():
    app_conf = conf.Config({'test1': 'test value'})
    assert app_conf.get('test1') == 'test value'
コード例 #5
0
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'}
コード例 #6
0
def test_get_existing_nested_value_works():
    app_conf = conf.Config({'test1': {
        'sub': 'test value',
    }})
    assert app_conf.get('test1.sub') == 'test value'
コード例 #7
0
def app_conf():
    appconf = conf.Config()
    with patch('peltak.core.conf.g_conf', appconf):
        yield appconf
コード例 #8
0
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'
コード例 #9
0
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'
コード例 #10
0
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'
コード例 #11
0
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'
コード例 #12
0
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