Navegador

navegador / tests / test_schema.py
Blame History Raw 87 lines
1
"""Tests for graph schema — node labels, edge types, and node properties."""
2
3
from navegador.graph.schema import NODE_PROPS, EdgeType, NodeLabel
4
5
6
class TestNodeLabel:
7
def test_code_labels(self):
8
assert NodeLabel.Repository == "Repository"
9
assert NodeLabel.File == "File"
10
assert NodeLabel.Module == "Module"
11
assert NodeLabel.Class == "Class"
12
assert NodeLabel.Function == "Function"
13
assert NodeLabel.Method == "Method"
14
assert NodeLabel.Variable == "Variable"
15
assert NodeLabel.Import == "Import"
16
assert NodeLabel.Decorator == "Decorator"
17
18
def test_knowledge_labels(self):
19
assert NodeLabel.Domain == "Domain"
20
assert NodeLabel.Concept == "Concept"
21
assert NodeLabel.Rule == "Rule"
22
assert NodeLabel.Decision == "Decision"
23
assert NodeLabel.WikiPage == "WikiPage"
24
assert NodeLabel.Person == "Person"
25
26
def test_is_str(self):
27
assert isinstance(NodeLabel.Function, str)
28
29
def test_total_count(self):
30
assert len(set(NodeLabel)) == 15 # 9 code + 6 knowledge
31
32
33
class TestEdgeType:
34
def test_code_edges(self):
35
assert EdgeType.CONTAINS == "CONTAINS"
36
assert EdgeType.DEFINES == "DEFINES"
37
assert EdgeType.IMPORTS == "IMPORTS"
38
assert EdgeType.DEPENDS_ON == "DEPENDS_ON"
39
assert EdgeType.CALLS == "CALLS"
40
assert EdgeType.REFERENCES == "REFERENCES"
41
assert EdgeType.INHERITS == "INHERITS"
42
assert EdgeType.IMPLEMENTS == "IMPLEMENTS"
43
assert EdgeType.DECORATES == "DECORATES"
44
45
def test_knowledge_edges(self):
46
assert EdgeType.BELONGS_TO == "BELONGS_TO"
47
assert EdgeType.RELATED_TO == "RELATED_TO"
48
assert EdgeType.GOVERNS == "GOVERNS"
49
assert EdgeType.DOCUMENTS == "DOCUMENTS"
50
assert EdgeType.ANNOTATES == "ANNOTATES"
51
assert EdgeType.ASSIGNED_TO == "ASSIGNED_TO"
52
assert EdgeType.DECIDED_BY == "DECIDED_BY"
53
54
def test_total_count(self):
55
assert len(set(EdgeType)) == 16 # 9 code + 7 knowledge
56
57
58
class TestNodeProps:
59
def test_all_labels_have_props(self):
60
for label in NodeLabel:
61
assert label in NODE_PROPS, f"Missing NODE_PROPS entry for {label}"
62
63
def test_function_props(self):
64
assert "signature" in NODE_PROPS[NodeLabel.Function]
65
assert "docstring" in NODE_PROPS[NodeLabel.Function]
66
67
def test_concept_props(self):
68
assert "description" in NODE_PROPS[NodeLabel.Concept]
69
assert "domain" in NODE_PROPS[NodeLabel.Concept]
70
71
def test_rule_props(self):
72
assert "severity" in NODE_PROPS[NodeLabel.Rule]
73
assert "rationale" in NODE_PROPS[NodeLabel.Rule]
74
75
def test_decision_props(self):
76
assert "status" in NODE_PROPS[NodeLabel.Decision]
77
assert "rationale" in NODE_PROPS[NodeLabel.Decision]
78
assert "alternatives" in NODE_PROPS[NodeLabel.Decision]
79
80
def test_person_props(self):
81
assert "role" in NODE_PROPS[NodeLabel.Person]
82
assert "email" in NODE_PROPS[NodeLabel.Person]
83
84
def test_wiki_props(self):
85
assert "source" in NODE_PROPS[NodeLabel.WikiPage]
86
assert "content" in NODE_PROPS[NodeLabel.WikiPage]
87

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button