Example #1
0
def test_unset_multi_level():
    conf = {'a': {'b': 'c', 'd': 'e'}, 'f': 'g'}

    new_conf = config.unset_item_from_config(conf, 'a.b')
    assert new_conf == {'a': {'d': 'e'}, 'f': 'g'}
    new_conf = config.unset_item_from_config(new_conf, 'a.d')
    assert new_conf == {'f': 'g'}
    new_conf = config.unset_item_from_config(new_conf, 'f')
    assert new_conf == {}
def test_unset_multi_level():
    conf = {"a": {"b": "c", "d": "e"}, "f": "g"}

    new_conf = config.unset_item_from_config(conf, "a.b")
    assert new_conf == {"a": {"d": "e"}, "f": "g"}
    new_conf = config.unset_item_from_config(new_conf, "a.d")
    assert new_conf == {"f": "g"}
    new_conf = config.unset_item_from_config(new_conf, "f")
    assert new_conf == {}
Example #3
0
def test_unset_config_error():
    with pytest.raises(ValueError):
        config.unset_item_from_config({}, 'a')

    with pytest.raises(ValueError):
        config.unset_item_from_config({'a': 'b'}, 'b')

    with pytest.raises(ValueError):
        config.unset_item_from_config({'a': {'b': 'c'}}, 'a.z')
def test_unset_config_error():
    with pytest.raises(ValueError):
        config.unset_item_from_config({}, "a")

    with pytest.raises(ValueError):
        config.unset_item_from_config({"a": "b"}, "b")

    with pytest.raises(ValueError):
        config.unset_item_from_config({"a": {"b": "c"}}, "a.z")
Example #5
0
def test_unset_and_clean_empty_configs():
    conf = {'a': {'b': {'c': {'d': {'e': 'f'}}}}}

    new_conf = config.unset_item_from_config(conf, 'a.b.c.d.e')
    assert new_conf == {}
Example #6
0
def test_unset_one_level():
    conf = {'a': 'b'}

    new_conf = config.unset_item_from_config(conf, 'a')
    assert new_conf == {}
Example #7
0
def test_unset_no_mutate():
    conf = {'a': 'b'}

    new_conf = config.unset_item_from_config(conf, 'a')
    assert conf == {'a': 'b'}
def test_unset_and_clean_empty_configs():
    conf = {"a": {"b": {"c": {"d": {"e": "f"}}}}}

    new_conf = config.unset_item_from_config(conf, "a.b.c.d.e")
    assert new_conf == {}
def test_unset_one_level():
    conf = {"a": "b"}

    new_conf = config.unset_item_from_config(conf, "a")
    assert new_conf == {}
def test_unset_no_mutate():
    conf = {"a": "b"}

    new_conf = config.unset_item_from_config(conf, "a")
    assert conf == {"a": "b"}