| Total Complexity | 3 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | from networkx_query.operator import lookup_path |
||
| 4 | |||
| 5 | |||
| 6 | def test_lookup_path_default(): |
||
| 7 | with pytest.raises(RuntimeError): |
||
| 8 | lookup_path(True, None) |
||
| 9 | |||
| 10 | |||
| 11 | def test_lookup_path(): |
||
| 12 | |||
| 13 | node = {'a': {'b': 1, 'c': {"d": "test"}}, 'e': False, 'd': None} |
||
| 14 | |||
| 15 | assert (False, None) == lookup_path(None, None) |
||
| 16 | assert (False, None) == lookup_path(None, "a") |
||
| 17 | assert (False, None) == lookup_path(node, None) |
||
| 18 | assert (True, False) == lookup_path(node, "e") |
||
| 19 | assert (False, None) == lookup_path(node, ()) |
||
| 20 | assert (True, False) == lookup_path(node, ("e",)) |
||
| 21 | assert (True, 1) == lookup_path(node, ("a", "b")) |
||
| 22 | assert (True, "test") == lookup_path(node, ("a", "c", "d")) |
||
| 23 | assert (False, None) == lookup_path(node, ("a", "d", "c", "d")) |
||
| 24 | assert (True, None) == lookup_path(node, "d") |
||
| 25 |