Orchestrata Ultimate › Tests › Reference › knowledge_graph › test_code_intelligence
Tests reference — tests/knowledge_graph/test_code_intelligence.py
Module of tests/knowledge_graph, split out because the directory page would be too large.
Prose pending.
tests/knowledge_graph/test_code_intelligence.py
source · 57 tests · 975 lines
Tests for code intelligence: call graph, inheritance, imports, method-to-class.
Covers: core.tracing.traceability, knowledge_graph.code_parser, knowledge_graph.synchronizer, knowledge_graph.types
| Kind | Name | Line | Description |
|---|---|---|---|
| class | TestMethodExtraction |
129 | FR-017: methods extracted as FunctionNodes with class_id set. |
| method | TestMethodExtraction.test_methods_extracted_as_function_nodes |
164 | Parse a class with 3 methods -> 3 FunctionNodes with class_id set. |
| method | TestMethodExtraction.test_method_has_class_id |
176 | Each method FunctionNode.class_id equals the parent ClassNode.id. |
| method | TestMethodExtraction.test_method_preserves_parameters |
186 | Method params including self are correctly extracted. |
| method | TestMethodExtraction.test_method_preserves_async |
192 | Async method has is_async=True. |
| method | TestMethodExtraction.test_method_preserves_decorators |
197 | @staticmethod is present in FunctionNode.decorators. |
| method | TestMethodExtraction.test_method_preserves_docstring |
202 | Method docstrings are extracted correctly. |
| method | TestMethodExtraction.test_standalone_functions_no_class_id |
207 | Top-level functions have class_id=None. |
| method | TestMethodExtraction.test_class_methods_list_still_populated |
215 | ClassNode.methods[] still carries method names for backward compatibility. |
| class | TestCallGraphResolution |
229 | FR-014: resolve_calls builds CALLS edges between FunctionNodes. |
| method | TestCallGraphResolution.test_resolve_calls_same_file |
241 | Two functions in same file where one calls the other -> edge with confidence 1.0. |
| method | TestCallGraphResolution.test_resolve_calls_cross_file |
262 | Function in file_a calls function in file_b (same dir) -> confidence 0.9. |
| method | TestCallGraphResolution.test_resolve_calls_global |
280 | Function calling another in a different package dir -> confidence 0.8. |
| method | TestCallGraphResolution.test_resolve_calls_ambiguous |
304 | Two functions with same name in different files -> edges to both, |
| method | TestCallGraphResolution.test_resolve_calls_unresolved_skipped |
332 | Calls to stdlib functions not in the project index produce no edges. |
| method | TestCallGraphResolution.test_resolve_calls_self_call_skipped |
342 | Recursive function calling itself produces no CALLS edge to self. |
| method | TestCallGraphResolution.test_resolve_calls_idempotent |
356 | Running resolve_calls twice on the same data produces identical edges. |
| method | TestCallGraphResolution.test_resolve_calls_empty |
370 | Empty analysis list -> empty result. |
| method | TestCallGraphResolution.test_resolve_calls_no_calls |
374 | Functions with no call sites produce no edges. |
| method | TestCallGraphResolution.test_resolve_calls_method_calls |
384 | Method of class A calling method of class B -> CALLS edge created. |
| class | TestInheritanceResolution |
418 | FR-015: resolve_inheritance builds INHERITS edges between ClassNodes. |
| method | TestInheritanceResolution.test_resolve_inheritance_simple |
430 | Class B(A) -> one INHERITS edge with child=B, parent=A. |
| method | TestInheritanceResolution.test_resolve_inheritance_multiple |
444 | Class C(A, B) -> two INHERITS edges. |
| method | TestInheritanceResolution.test_resolve_inheritance_chain |
461 | A(B), B(C) -> two direct edges; no transitive A->C edge. |
| method | TestInheritanceResolution.test_resolve_inheritance_unresolved_skipped |
478 | Class Foo(ABC) where ABC is not in parsed files -> no edge. |
| method | TestInheritanceResolution.test_resolve_inheritance_cross_file |
488 | Parent class in a different file -> INHERITS edge created. |
| method | TestInheritanceResolution.test_resolve_inheritance_idempotent |
503 | Same input twice -> identical output, no duplicate edges. |
| method | TestInheritanceResolution.test_resolve_inheritance_empty |
516 | No analyses -> empty list. |
| class | TestImportResolution |
527 | FR-016: resolve_imports builds IMPORTS edges between File nodes. |
| method | TestImportResolution.test_resolve_imports_same_package |
534 | File importing a module in the same package directory resolves to an edge. |
| method | TestImportResolution.test_resolve_imports_cross_package |
549 | Fully-qualified import from another package directory resolves. |
| method | TestImportResolution.test_resolve_imports_partial_match |
566 | import orchestrata_ultimate.cxp (package-level) resolves via prefix matching. |
| method | TestImportResolution.test_resolve_imports_unresolved_skipped |
580 | Stdlib imports (os, sys) not in project index produce no edges. |
| method | TestImportResolution.test_resolve_imports_self_import_skipped |
588 | A file that imports from itself produces no IMPORTS edge. |
| method | TestImportResolution.test_resolve_imports_idempotent |
598 | Same analyses passed twice -> same edges, no duplicates. |
| method | TestImportResolution.test_resolve_imports_empty |
613 | Empty analyses -> empty list. |
| method | TestImportResolution.test_resolve_imports_properties |
617 | Import edge carries imported_names, line_number, is_relative. |
| class | TestFilePathToModule |
639 | Unit tests for the _file_path_to_module helper function. |
| method | TestFilePathToModule.test_standard_package_path |
642 | packages/orchestrata_ultimate-cxp/src/orchestrata_ultimate/cxp/packet.py |
| method | TestFilePathToModule.test_src_prefix_path |
651 | src/orchestrata_ultimate/knowledge/types.py -> orchestrata_ultimate.knowledge.types |
| method | TestFilePathToModule.test_init_file |
656 | packages/orchestrata_ultimate-core/src/orchestrata_ultimate/core/init.py |
| method | TestFilePathToModule.test_no_src_prefix |
665 | orchestrata_ultimate/core/types.py -> orchestrata_ultimate.core.types (no /src/ present). |
| method | TestFilePathToModule.test_windows_separators |
670 | Backslashes are converted to forward slashes before processing. |
| class | TestSamePackage |
684 | Unit tests for the _same_package helper function. |
| method | TestSamePackage.test_same_directory |
687 | Two files in the same directory -> True. |
| method | TestSamePackage.test_different_directory |
694 | Files in different sibling directories -> False. |
| method | TestSamePackage.test_nested_vs_parent |
701 | File in sub/ vs its parent dir -> False. |
| class | TestResolutionResult |
712 | Tests for the ResolutionResult dataclass. |
| method | TestResolutionResult.test_defaults |
715 | Default ResolutionResult has all-zero edge counts and empty lists. |
| method | TestResolutionResult.test_total_resolved_edges |
725 | total_resolved_edges sums call + inherit + import + method counts. |
| method | TestResolutionResult.test_files_synced |
735 | files_synced counts only COMPLETED SyncResult entries. |
| method | TestResolutionResult.test_to_dict |
746 | to_dict serialises all fields including computed properties. |
| method | TestResolutionResult.test_to_dict_with_sync_results |
766 | Nested SyncResult objects are included as dicts via their to_dict(). |
| class | TestSyncProjectWithResolution |
784 | Integration tests for FileSynchronizer.sync_project_with_resolution. |
| method | TestSyncProjectWithResolution.test_basic_resolution |
792 | Sync the cross-ref project, verify inherit and method edges are resolved. |
| method | TestSyncProjectWithResolution.test_resolution_without_neo4j |
806 | No graph client -> total_edges_created is 0 but no exception is raised. |
| method | TestSyncProjectWithResolution.test_resolution_nonexistent_dir |
813 | Non-existent path -> ResolutionResult with a single failed SyncResult. |
| method | TestSyncProjectWithResolution.test_resolution_respects_extensions |
821 | Only .py files synced when extensions={'.py'}; .pl files excluded. |
| method | TestSyncProjectWithResolution.test_resolution_duration_tracked |
834 | duration_ms is a positive float after a real sync operation. |
| method | TestSyncProjectWithResolution.test_resolution_collects_method_edges |
841 | A file with a class that has 2 methods -> method_edges >= 2. |
| class | TestPreExistingNodeResolution |
864 | Verify that resolution works across separately-synced batches. |
| method | TestPreExistingNodeResolution.test_cross_batch_inheritance |
876 | Class in batch 2 inherits from class in batch 1. |
| method | TestPreExistingNodeResolution.test_cross_batch_inheritance_missing_without_prior_batch |
896 | Without batch 1 in the analysis list, inheritance is unresolved. |
| method | TestPreExistingNodeResolution.test_cross_batch_calls |
906 | Function in batch 2 calls function defined in batch 1. |
| method | TestPreExistingNodeResolution.test_cross_batch_calls_missing_without_prior_batch |
931 | Without batch 1, the call to compute() is unresolved. |
| method | TestPreExistingNodeResolution.test_incremental_resolution_combines_batches |
940 | Simulates incremental sync: resolve batch 1 alone, then batch 1+2. |