Orchestrata Ultimate › Tests › Reference › knowledge_graph › test_code_intelligence_coverage

Tests reference — tests/knowledge_graph/test_code_intelligence_coverage.py

Module of tests/knowledge_graph, split out because the directory page would be too large.

Prose pending.

tests/knowledge_graph/test_code_intelligence_coverage.py

source · 55 tests · 632 lines

Coverage completion tests for code intelligence modules.

Covers: core.tracing.traceability, knowledge_graph.code_parser, knowledge_graph.config, knowledge_graph.nodes, knowledge_graph.schema, knowledge_graph.synchronizer, knowledge_graph.types, knowledge_graph.types_nodes

Kind Name Line Description
class TestCodeParserErrorBranches 63 Cover error and edge-case branches in CodeParser.
method TestCodeParserErrorBranches.test_parse_nonexistent_file 70 Line 46: file not found returns error analysis.
method TestCodeParserErrorBranches.test_parse_unsupported_extension 76 Line 52: unsupported file type returns error.
method TestCodeParserErrorBranches.test_parse_unreadable_file 85 Line 60-61: file read error returns error analysis.
method TestCodeParserErrorBranches.test_parse_python_else_branch 102 Line 73: non-py, non-pl suffix after supported check (defensive).
method TestCodeParserErrorBranches.test_create_file_node_python 113 Lines 199-216: create_file_node for a Python file.
method TestCodeParserErrorBranches.test_create_file_node_prolog 124 Lines 199-216: create_file_node for a Prolog file.
method TestCodeParserErrorBranches.test_create_file_node_unknown_ext 132 Lines 199-216: create_file_node for unknown extension.
method TestCodeParserErrorBranches.test_create_file_node_nonexistent 139 Lines 209-214: error branch when file doesn't exist.
method TestCodeParserErrorBranches.test_extract_class_attribute_base 145 Lines 306-307: base class via ast.Attribute (e.g., abc.ABC).
method TestCodeParserErrorBranches.test_extract_class_attribute_decorator 154 Lines 311-314: decorator via ast.Attribute (e.g., @app.route).
method TestCodeParserErrorBranches.test_extract_function_return_type_unparse_error 171 Lines 341-342: return type annotation that fails ast.unparse.
method TestCodeParserErrorBranches.test_extract_import_plain 180 Line 402: Import (not ImportFrom) returns ImportNode.
method TestCodeParserErrorBranches.test_prolog_dynamic_predicate 188 Line 451: dynamic declaration extraction.
method TestCodeParserErrorBranches.test_resolve_calls_dedup 199 Line 549: duplicate pair skipped via seen set.
method TestCodeParserErrorBranches.test_resolve_inheritance_dedup 217 Lines 607-610: duplicate inheritance pair skipped.
method TestCodeParserErrorBranches.test_resolve_imports_dedup 228 Lines 653-654, 661: duplicate import and self-import.
class TestSynchronizerCoverage 249 Cover uncovered synchronizer methods and error branches.
method TestSynchronizerCoverage.test_sync_file_nonexistent 252 Line 61: sync_file with nonexistent path.
method TestSynchronizerCoverage.test_sync_file_syntax_error 260 Line 79: sync_file with unparseable Python.
method TestSynchronizerCoverage.test_sync_file_no_client_counts 270 Lines 95-111: sync_file without graph client counts nodes.
method TestSynchronizerCoverage.test_sync_file_from_analysis_nonexistent 279 Line 141: _sync_file_from_analysis with nonexistent file.
method TestSynchronizerCoverage.test_sync_file_from_analysis_failed_parse 286 Line 148: _sync_file_from_analysis with failed analysis.
method TestSynchronizerCoverage.test_sync_file_from_analysis_skipped 295 Lines 171-173: _sync_file_from_analysis skips unchanged file.
method TestSynchronizerCoverage.test_sync_project_nonexistent 307 Lines 351-362: sync_project with nonexistent directory.
method TestSynchronizerCoverage.test_sync_project_max_files 316 Line 372: max_files limit respected.
method TestSynchronizerCoverage.test_watch_and_stop 328 Lines 621-637: watch() and stop_watching().
method TestSynchronizerCoverage.test_needs_sync 340 Lines 608-609: needs_sync for tracked and untracked files.
method TestSynchronizerCoverage.test_clear 349 Lines 714-715: clear() resets state.
method TestSynchronizerCoverage.test_resolution_persist_error_handled 361 Lines 482-483: _persist_resolution_edges failure logged, not raised.
class TestNodesCoverage 380 Cover node conversion utilities.
method TestNodesCoverage.test_node_to_cypher_props_basic 383 Lines 34-44: generic Node to Cypher properties.
method TestNodesCoverage.test_node_to_cypher_props_with_valid_until 398 Lines 41-42: valid_until included when set.
method TestNodesCoverage.test_file_node_with_project_id 408 Line 62: project_id included when set.
method TestNodesCoverage.test_file_node_without_project_id 414 Line 62: project_id excluded when None.
method TestNodesCoverage.test_cypher_record_to_node_empty 420 Line 146: empty record returns None.
method TestNodesCoverage.test_cypher_record_to_node_valid 425 Lines 148-163: valid record converted to Node.
method TestNodesCoverage.test_cypher_record_to_node_unknown_type 435 Lines 151-153: unknown type defaults to FILE.
class TestSchemaCoverage 449 Cover schema utility functions.
method TestSchemaCoverage.test_get_all_ddl 452 Line 113: returns combined constraints + indexes + fulltext.
method TestSchemaCoverage.test_get_node_label_known 460 Lines 119-136: known types map correctly.
method TestSchemaCoverage.test_get_node_label_unknown 472 Line 136: unknown type defaults to 'Node'.
class TestTypesSerialization 483 Cover to_dict methods on all data types.
method TestTypesSerialization.test_dependency_to_dict 486 Line 141: Dependency.to_dict().
method TestTypesSerialization.test_dependency_graph_properties 500 Lines 166, 175, 184: DependencyGraph properties.
method TestTypesSerialization.test_change_entry_to_dict 515 Line 213: ChangeEntry.to_dict().
method TestTypesSerialization.test_dashboard_to_dict 523 Line 252: Dashboard.to_dict().
method TestTypesSerialization.test_dashboard_to_dict_with_sync 531 Line 252: Dashboard.to_dict() with last_sync set.
method TestTypesSerialization.test_context_bundle_to_dict 537 Line 288: ContextBundle.to_dict().
class TestTypesNodesSerialization 551 Cover to_dict on all node types.
method TestTypesNodesSerialization.test_node_from_dict 554 Lines 57-60: Node.from_dict round-trip.
method TestTypesNodesSerialization.test_node_from_dict_minimal 563 Lines 57-60: Node.from_dict with minimal data.
method TestTypesNodesSerialization.test_package_node_to_dict 569 Line 92: PackageNode.to_dict().
method TestTypesNodesSerialization.test_module_node_to_dict 577 Line 125: ModuleNode.to_dict().
method TestTypesNodesSerialization.test_file_node_to_dict 586 Line 159: FileNode.to_dict().
method TestTypesNodesSerialization.test_class_node_to_dict 593 Line 195: ClassNode.to_dict().
method TestTypesNodesSerialization.test_function_node_to_dict 600 Line 235: FunctionNode.to_dict().
method TestTypesNodesSerialization.test_predicate_node_to_dict 607 Line 285: PredicateNode.to_dict().
method TestTypesNodesSerialization.test_rule_node_to_dict 614 Line 321: RuleNode.to_dict().
method TestTypesNodesSerialization.test_import_node_to_dict 621 Line 351: ImportNode.to_dict().
method TestTypesNodesSerialization.test_node_to_dict_37 628 Line 37: Node.to_dict() includes valid_until None as null.