vyos.util.vyos_dict_search(path, dict) is a lightweight alternative to jmespath.search() which will traverse a dictionary given on a dot separated path.
KeyError
If we only supply path = 'foo' and 'foo' is not a key within the passed dict a KeyError will be generated:
>>> data = {} >>> vyos_dict_search('foo', data) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3/dist-packages/vyos/util.py", line 685, in vyos_dict_search return dict[path] KeyError: 'foo'
This is most likely not what we have intended for the use of vyos_dict_search(), we rather would see retunring it None or [] - which is yet to be decided.
Add Unittests to vyos-1x builds
As this is a crucial part of the internal API, UnitTests must be supplied.