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

tests.test_lookup_path   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_lookup_path_default() 0 3 2
A test_lookup_path() 0 14 1
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