Passed
Push — master ( 5b3fdd...dd1c2d )
by Guibert
02:21
created

tests.test_lookup_path.test_lookup_path_default()   A

Complexity

Conditions 2

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 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