-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_node.py
More file actions
77 lines (59 loc) · 1.52 KB
/
test_node.py
File metadata and controls
77 lines (59 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import pytest
from neo4j_viz import CaptionAlignment, Node
def test_nodes_with_all_options() -> None:
node = Node(
id="4:d09f48a4-5fca-421d-921d-a30a896c604d:0",
caption="Person",
caption_align=CaptionAlignment.TOP,
caption_size=1,
color="#FF0000",
size=10,
pinned=True,
x=1,
y=10,
)
assert node.to_dict() == {
"id": "4:d09f48a4-5fca-421d-921d-a30a896c604d:0",
"caption": "Person",
"captionAlign": "top",
"captionSize": 1,
"color": "#ff0000",
"size": 10,
"pinned": True,
"x": 1,
"y": 10,
}
def test_nodes_minimal_node() -> None:
node = Node(
id="1",
)
assert node.to_dict() == {
"id": "1",
}
def test_node_with_float_size() -> None:
node = Node(
id="1",
size=10.2,
)
assert node.to_dict() == {
"id": "1",
"size": 10.2,
}
def test_node_with_additional_fields() -> None:
node = Node(
id="1",
componentId=2,
)
assert node.to_dict() == {
"id": "1",
"component_id": 2,
}
@pytest.mark.parametrize("alias", ["id", "nodeId", "node_id", "ID"])
def test_id_aliases(alias: str) -> None:
node = Node(**{alias: 1})
assert node.to_dict() == {
"id": "1",
}
def test_node_validation() -> None:
with pytest.raises(ValueError, match="Input should be a valid integer, unable to parse string as an integer"):
Node(id="1", x="not a number")