Esempio n. 1
0
 def deco(self, _deps=None, **overrides):
     _prefix = overrides.get("_prefix", self.__class__._prefix)
     _ = dot_to_deps(_deps or {}, _prefix) if _prefix else dot_to_deps(
         _deps or {})
     _.update(overrides)
     res = __init__(self, _deps, **_)
     return res
Esempio n. 2
0
def test_dot():
    set_self = {".": 10}  # should preserve
    _ = dot_to_deps(set_self)
    assert _ == {'.': 10}, "should contain dot"
Esempio n. 3
0
def test_root_with_dependencies():
    """I don't like this. - Ge"""
    _ = dot_to_deps({'some': 10, 'teacher.replicas_hints': 1}, ".")
    print(_)
Esempio n. 4
0
def test_outrageous_root_prefix():
    """full prefix string can not contain multiple consecutive dots. """
    import pytest
    with pytest.raises(AssertionError):
        _ = dot_to_deps({'some': 10}, "....")
Esempio n. 5
0
def test_root_empty_prefix():
    """to indicate root config, you need to pass in `.` instead. """
    import pytest
    with pytest.raises(AssertionError):
        _ = dot_to_deps({'some': 10}, "")
Esempio n. 6
0
def test_root_prefix():
    _ = dot_to_deps({'some': 10}, ".")
    assert _ == {"some": 10}
Esempio n. 7
0
def test_mixed_prefixes():
    _ = dot_to_deps({'root.resources.teacher.replicas_hint': 10}, "root.resources", "teacher")
    assert _ == {"replicas_hint": 10}
Esempio n. 8
0
def test_multile_prefix():
    _ = dot_to_deps({'resources.teacher.replicas_hint': 10}, "resources", "teacher")
    assert _ == {"replicas_hint": 10}
Esempio n. 9
0
def test_empty():
    empty = {}
    _ = dot_to_deps(empty)
    assert _ == {}, "result should be empty"
Esempio n. 10
0
def test_nested():
    set_bunch = {"resources.teacher.replica_hint": 10, }
    _ = dot_to_deps(set_bunch, 'resources')
    assert _ == {'teacher': {'replica_hint': 10}}, "should contain nested dict"
Esempio n. 11
0
def test_normal():
    _ = dot_to_deps({'root.launch_type': 'local'}, "root")
    assert _ == {"launch_type": 'local'}