Orchestrata Ultimate › Tests › Reference › knowledge_graph › test_kg_context
Tests reference — tests/knowledge_graph/test_kg_context.py
Module of tests/knowledge_graph, split out because the directory page would be too large.
Prose pending.
tests/knowledge_graph/test_kg_context.py
source · 50 tests · 1048 lines
Tests for spike/kg_context.py KGCodeContext class.
Covers: knowledge_graph.kg_context, core.graph/ (package)
| Kind | Name | Line | Description |
|---|---|---|---|
| class | TestDisconnectedFallback |
65 | Tests that methods return safe defaults when not connected. |
| method | TestDisconnectedFallback.test_get_file_content_returns_none |
68 | get_file_content returns None when not connected. |
| method | TestDisconnectedFallback.test_get_project_files_returns_empty |
75 | get_project_files returns empty list when not connected. |
| method | TestDisconnectedFallback.test_get_source_listing_returns_empty |
81 | get_source_listing returns empty string when not connected. |
| method | TestDisconnectedFallback.test_get_classes_and_functions_returns_empty |
87 | get_classes_and_functions returns empty when not connected. |
| method | TestDisconnectedFallback.test_get_source_listing_for_files_returns_empty |
93 | get_source_listing_for_files returns '' when not connected. |
| method | TestDisconnectedFallback.test_get_dependencies_returns_empty |
102 | get_dependencies returns empty list when not connected. |
| method | TestDisconnectedFallback.test_store_design_doc_returns_empty |
108 | store_design_doc returns empty string when not connected. |
| method | TestDisconnectedFallback.test_get_design_docs_returns_empty |
119 | get_design_docs returns empty list when not connected. |
| method | TestDisconnectedFallback.test_sync_files_to_kg_returns_zero |
125 | sync_files_to_kg returns 0 when not connected. |
| method | TestDisconnectedFallback.test_get_monorepo_classes_returns_empty |
131 | get_monorepo_classes returns empty dict when disconnected. |
| class | TestConnectCloseLifecycle |
138 | Tests for connect/close lifecycle. |
| method | TestConnectCloseLifecycle.test_connect_returns_true |
142 | connect() returns True when the graph is reachable. |
| method | TestConnectCloseLifecycle.test_close_resets_state |
152 | close() sets _connected=False and _driver=None. |
| method | TestConnectCloseLifecycle.test_double_close_is_safe |
161 | Calling close() twice does not raise. |
| method | TestConnectCloseLifecycle.test_connect_with_bad_uri_returns_false |
168 | connect() returns False for an unreachable URI. |
| class | TestGetSourceListing |
181 | Tests for get_source_listing with real graph. |
| method | TestGetSourceListing.test_returns_string_for_known_project |
184 | get_source_listing returns a string (may be empty). |
| method | TestGetSourceListing.test_returns_empty_for_nonexistent_project |
196 | get_source_listing returns '' for a path with no files. |
| class | TestGetClassesAndFunctions |
210 | Tests for get_classes_and_functions with real graph. |
| method | TestGetClassesAndFunctions.test_returns_string_for_known_project |
213 | get_classes_and_functions returns a string. |
| method | TestGetClassesAndFunctions.test_returns_empty_for_nonexistent_project |
225 | Returns '' for a path with no entities. |
| class | TestSyncFilesToKG |
239 | Tests for sync_files_to_kg with real graph. |
| method | TestSyncFilesToKG.test_syncs_python_files_from_temp_dir |
242 | sync_files_to_kg creates File nodes for .py files. |
| method | TestSyncFilesToKG.test_sync_skips_pycache_and_hidden |
281 | sync_files_to_kg skips pycache and hidden directories. |
| class | TestStoreAndGetDesignDocs |
313 | Tests for store_design_doc and get_design_docs. |
| method | TestStoreAndGetDesignDocs.test_store_returns_id_and_get_retrieves |
316 | store_design_doc returns an ID; get_design_docs retrieves it. |
| method | TestStoreAndGetDesignDocs.test_get_design_docs_filters_by_type |
351 | get_design_docs with doc_type filter returns only that type. |
| class | TestSharedDriverUnreachable |
393 | Exercises the ServiceUnavailable branches using a real graph |
| method | TestSharedDriverUnreachable.test_connect_with_unreachable_shared_driver_returns_false |
400 | connect() verifies a shared-but-unreachable driver, hits the |
| method | TestSharedDriverUnreachable.test_get_file_content_returns_none_on_service_unavailable |
419 | get_file_content swallows a real ServiceUnavailable raised by |
| method | TestSharedDriverUnreachable.test_store_design_doc_returns_empty_on_service_unavailable |
439 | store_design_doc swallows ServiceUnavailable and returns ''. |
| method | TestSharedDriverUnreachable.test_get_design_docs_returns_empty_on_service_unavailable |
462 | get_design_docs swallows ServiceUnavailable and returns []. |
| class | TestSharedDriverSuccess |
481 | Exercises the shared-driver verify-success branch of connect() |
| method | TestSharedDriverSuccess.test_connect_with_working_shared_driver_returns_true |
487 | connect() verifies a live shared driver and reports connected. |
| class | TestBrokenDriverFallback |
503 | Exercises the generic except Exception branches by force- |
| method | TestBrokenDriverFallback.test_get_file_content_returns_none |
522 | |
| method | TestBrokenDriverFallback.test_get_project_files_returns_empty |
526 | |
| method | TestBrokenDriverFallback.test_get_source_listing_returns_empty |
530 | |
| method | TestBrokenDriverFallback.test_get_classes_and_functions_returns_empty |
534 | |
| method | TestBrokenDriverFallback.test_get_dependencies_returns_empty |
538 | |
| method | TestBrokenDriverFallback.test_store_design_doc_returns_empty |
542 | |
| method | TestBrokenDriverFallback.test_get_design_docs_returns_empty |
552 | |
| method | TestBrokenDriverFallback.test_get_monorepo_classes_returns_empty |
556 | |
| method | TestBrokenDriverFallback.test_sync_files_to_kg_returns_zero |
560 | The file read from disk succeeds; the KG write fails. |
| class | TestGetMonorepoClassesEdgeCases |
568 | Covers the disk-read-OSError branch of get_monorepo_classes with |
| method | TestGetMonorepoClassesEdgeCases.test_skips_unreadable_disk_file_permission_denied |
586 | KG has no content for the file; the disk fallback exists but |
| class | TestGetFileContentConnected |
618 | Exercises get_file_content's connected/success branches (content |
| method | TestGetFileContentConnected.test_returns_content_when_present |
624 | |
| method | TestGetFileContentConnected.test_falls_back_to_signatures_when_no_content |
642 | |
| class | TestGetSourceListingConnected |
673 | Exercises get_source_listing's content and signature-fallback |
| method | TestGetSourceListingConnected.test_content_file_and_signature_fallback_file |
677 | |
| class | TestGetSourceListingForFilesConnected |
710 | Exercises get_source_listing_for_files' content and missing-file |
| method | TestGetSourceListingForFilesConnected.test_known_and_missing_files |
714 | |
| class | TestGetClassesAndFunctionsConnected |
741 | Exercises get_classes_and_functions' class/method/standalone- |
| method | TestGetClassesAndFunctionsConnected.test_with_seeded_classes_methods_and_functions |
745 | |
| class | TestGetDependenciesConnected |
777 | Exercises get_dependencies' success branch with real seeded |
| method | TestGetDependenciesConnected.test_returns_seeded_imports |
781 | |
| class | TestSyncFilesToKGEdgeCases |
806 | Exercises sync_files_to_kg's unreadable-file and >500-line |
| method | TestSyncFilesToKGEdgeCases.test_unreadable_file_is_skipped |
818 | A file with invalid UTF-8 bytes raises UnicodeDecodeError on |
| method | TestSyncFilesToKGEdgeCases.test_truncates_files_over_max_lines |
846 | Files longer than _MAX_CONTENT_LINES (500) get truncated |
| class | TestGetMonorepoClassesConnected |
879 | Exercises get_monorepo_classes' KG-content, disk-fallback, |
| method | TestGetMonorepoClassesConnected.test_returns_content_from_kg |
884 | |
| method | TestGetMonorepoClassesConnected.test_falls_back_to_disk_when_kg_content_empty |
910 | |
| method | TestGetMonorepoClassesConnected.test_skips_when_no_kg_content_and_no_disk_file |
940 | KG content empty AND no file on disk -> `if not content: |
| method | TestGetMonorepoClassesConnected.test_truncates_content_over_200_lines |
968 | |
| method | TestGetMonorepoClassesConnected.test_undecodable_disk_file_is_skipped_others_still_load |
999 | Regression test: a class whose disk-fallback file has invalid |