コード例 #1
0
def test_remove_from_config():
    conf = {}

    new_conf = config.add_item_to_config(conf, 'a.b.c', 'd')
    new_conf = config.add_item_to_config(new_conf, 'a.b.c', 'e')
    assert new_conf == {'a': {'b': {'c': ['d', 'e']}}}

    new_conf = config.remove_item_from_config(new_conf, 'a.b.c', 'e')
    assert new_conf == {'a': {'b': {'c': ['d']}}}
コード例 #2
0
def test_remove_from_config():
    conf = {}

    new_conf = config.add_item_to_config(conf, "a.b.c", "d")
    new_conf = config.add_item_to_config(new_conf, "a.b.c", "e")
    assert new_conf == {"a": {"b": {"c": ["d", "e"]}}}

    new_conf = config.remove_item_from_config(new_conf, "a.b.c", "e")
    assert new_conf == {"a": {"b": {"c": ["d"]}}}
コード例 #3
0
def test_remove_from_config_error():
    with pytest.raises(ValueError):
        config.remove_item_from_config({}, 'a.b.c', 'e')

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

    with pytest.raises(ValueError):
        config.remove_item_from_config({'a': ['b']}, 'a', 'e')
コード例 #4
0
def test_remove_from_config_error():
    with pytest.raises(ValueError):
        config.remove_item_from_config({}, "a.b.c", "e")

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

    with pytest.raises(ValueError):
        config.remove_item_from_config({"a": ["b"]}, "a", "e")