Orchestrata Ultimate › Tests › Reference › knowledge_graph › test_anomaly_detector_extended

Tests reference — tests/knowledge_graph/test_anomaly_detector_extended.py

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

Prose pending.

tests/knowledge_graph/test_anomaly_detector_extended.py

source · 23 tests · 678 lines

Extended tests for anomaly detection and correction (Spec 008 FR-010).

Covers: knowledge_graph.anomaly_detector, knowledge_graph.code_parser, knowledge_graph.config, knowledge_graph.graph_client, knowledge_graph.synchronizer

Kind Name Line Description
class TestConnectMethod 195 Test AnomalyDetector.connect() path coverage.
method TestConnectMethod.test_connect_triggers_client_connect 198 connect() calls client.connect() when client is not connected.
class TestGetLoop 213 Test _get_loop() path coverage.
method TestGetLoop.test_get_loop_with_provided_loop 216 _get_loop returns the explicitly provided loop.
method TestGetLoop.test_get_loop_with_closed_loop_falls_back 229 _get_loop falls back when the provided loop is closed.
class TestCorrectDispatch 248 Test correct() handler dispatch edge cases.
method TestCorrectDispatch.test_correct_no_handler_returns_not_corrected 251 correct() returns not-corrected when no handler exists.
class TestCheckLineCountEdgeCases 276 Test _check_line_count uncovered branches.
method TestCheckLineCountEdgeCases.test_check_line_count_oserror_on_directory 279 _check_line_count returns [] when Path.read_text raises OSError.
method TestCheckLineCountEdgeCases.test_check_line_count_no_drift_returns_empty 300 _check_line_count returns [] when disk and graph counts match.
class TestCheckEntitiesEdgeCases 323 Test _check_entities uncovered branches.
method TestCheckEntitiesEdgeCases.test_check_entities_parse_failure_returns_empty 326 _check_entities returns [] when file has syntax errors.
class TestFindMissingFilesEdgeCases 349 Test _find_missing_files uncovered branches.
method TestFindMissingFilesEdgeCases.test_find_missing_files_non_directory_returns_empty 352 _find_missing_files returns [] when project_path is not a dir.
method TestFindMissingFilesEdgeCases.test_find_missing_files_ignores_wrong_extension 367 _find_missing_files skips files with unsupported extensions.
method TestFindMissingFilesEdgeCases.test_find_missing_files_ignores_pycache 382 _find_missing_files skips files inside ignored directories.
class TestMissingFileDetection 400 Test MISSING_FILE anomaly detection end-to-end.
method TestMissingFileDetection.test_detects_missing_file 403 File on disk but not in graph is detected as MISSING_FILE.
class TestCorrectMissingFile 427 Test _correct_missing_file path coverage.
method TestCorrectMissingFile.test_correct_missing_file_syncs_to_graph 430 _correct_missing_file syncs a real file into the graph.
class TestCorrectOrphanRelationship 461 Test _correct_orphan_relationship edge cases.
method TestCorrectOrphanRelationship.test_correct_orphan_no_entity_id_returns_not_corrected 464 _correct_orphan_relationship returns False when details lack entity_id.
class TestApplyCorrections 486 Test _apply_corrections uncovered branches.
method TestApplyCorrections.test_apply_corrections_uncorrectable_skipped 489 Uncorrectable anomalies are added to report.uncorrectable.
method TestApplyCorrections.test_apply_corrections_failed_correction_marked_uncorrectable 510 Failed corrections are moved to report.uncorrectable.
method TestApplyCorrections.test_apply_corrections_interactive_skips_on_no 533 Interactive mode skips anomaly when user answers 'n'.
class TestGetOrCreateLoop 563 Test _get_or_create_loop in subprocess for parallel safety.
method TestGetOrCreateLoop.test_get_or_create_loop_returns_usable_loop 566 _get_or_create_loop returns a non-closed event loop.
method TestGetOrCreateLoop.test_get_or_create_loop_replaces_closed_loop 582 _get_or_create_loop creates a new loop when the current one is closed.
method TestGetOrCreateLoop.test_get_or_create_loop_closed_loop_replaced_direct 601 _get_or_create_loop replaces a closed loop (direct call in thread).
method TestGetOrCreateLoop.test_get_or_create_loop_runtime_error_direct 617 _get_or_create_loop handles RuntimeError when no loop exists (thread).
class TestPromptUser 631 Test _prompt_user via stdin redirection.
method TestPromptUser.test_prompt_user_y_returns_true 634 _prompt_user returns True when user inputs 'y'.
method TestPromptUser.test_prompt_user_n_returns_false 649 _prompt_user returns False when user inputs 'n'.
method TestPromptUser.test_prompt_user_q_raises_keyboard_interrupt 664 _prompt_user raises KeyboardInterrupt when user inputs 'q'.