Add code + tests for adding items to a list

This commit is contained in:
yuvipanda
2018-07-28 11:05:29 -07:00
parent 6f99da5d95
commit f0c944aeb8
3 changed files with 127 additions and 6 deletions

View File

@@ -51,6 +51,36 @@ def test_set_overwrite():
assert new_conf == {'a': 'hi'}
def test_add_to_config_one_level():
conf = {}
new_conf = config.add_item_to_config(conf, 'a.b', 'c')
assert new_conf == {
'a': {'b': ['c']}
}
def test_add_to_config_zero_level():
conf = {}
new_conf = config.add_item_to_config(conf, 'a', 'b')
assert new_conf == {
'a': ['b']
}
def test_add_to_config_multiple():
conf = {}
new_conf = config.add_item_to_config(conf, 'a.b.c', 'd')
assert new_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']}}
}
def test_show_config():
"""
Test stdout output when showing config