Navegador

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

Keyboard Shortcuts

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