Orchestrata Ultimate › Tests › Reference › orchestrator › test_fact_manager_extended

Tests reference — tests/orchestrator/test_fact_manager_extended.py

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

Prose pending.

tests/orchestrator/test_fact_manager_extended.py

source · 65 tests · 875 lines

Extended coverage tests for orchestrata_ultimate.orchestrator.fact_manager.

Covers: orchestrator.fact_manager, core.enums/ (package)

Kind Name Line Description
class TestLifecycleExtended 61
method TestLifecycleExtended.test_start_when_already_running_is_noop 62
method TestLifecycleExtended.test_stop_when_never_started_is_safe 71
method TestLifecycleExtended.test_background_cleanup_loop_removes_expired_facts 77 Start background thread with short interval and verify cleanup.
method TestLifecycleExtended.test_background_cleanup_loop_runs_multiple_cycles 91
class TestFactRegistrationExtended 110
method TestFactRegistrationExtended.test_register_fact_session_scope_without_session_id 111
method TestFactRegistrationExtended.test_register_fact_persistent_scope 123
method TestFactRegistrationExtended.test_register_fact_updates_session_stats 133
method TestFactRegistrationExtended.test_register_fact_assertion_error_wraps_exception 142
method TestFactRegistrationExtended.test_register_fact_with_zero_ttl_treated_as_no_ttl 152 Zero is falsy, so ttl_seconds=0 is treated as no TTL by the code.
class TestFactUnregistrationExtended 167
method TestFactUnregistrationExtended.test_unregister_fact_retract_returns_false 168 When retract_fn returns False, fact is still unregistered from manager.
method TestFactUnregistrationExtended.test_unregister_fact_retract_raises_exception 178
method TestFactUnregistrationExtended.test_unregister_fact_request_scope 189
method TestFactUnregistrationExtended.test_unregister_fact_session_scope_without_session_id 197
method TestFactUnregistrationExtended.test_unregister_fact_not_found_returns_false 205
method TestFactUnregistrationExtended.test_unregister_fact_updates_stats_correctly 209
method TestFactUnregistrationExtended.test_unregister_fact_stats_never_go_negative 220 Stats subtraction is clamped to zero.
class TestSessionLifecycleExtended 238
method TestSessionLifecycleExtended.test_on_session_start_idempotent 239
method TestSessionLifecycleExtended.test_on_session_end_with_no_facts 246
method TestSessionLifecycleExtended.test_on_session_end_clears_session_stats 254
method TestSessionLifecycleExtended.test_on_session_end_partial_failure_still_counts 264 If some retracts fail, count reflects successful unregistrations.
method TestSessionLifecycleExtended.test_on_session_end_does_not_affect_other_sessions 280
class TestRequestLifecycleExtended 294
method TestRequestLifecycleExtended.test_on_request_start_is_callable 295
method TestRequestLifecycleExtended.test_on_request_end_with_no_facts 300
method TestRequestLifecycleExtended.test_on_request_end_clears_request_facts 306
method TestRequestLifecycleExtended.test_on_request_end_does_not_affect_session_facts 317
class TestTtlCleanupExtended 331
method TestTtlCleanupExtended.test_cleanup_expired_with_no_expired_facts 332
method TestTtlCleanupExtended.test_cleanup_expired_mixed_expired_and_fresh 340
method TestTtlCleanupExtended.test_cleanup_expired_stops_at_unexpired_heap_entry 349 Heap traversal breaks when it encounters a non-expired entry.
method TestTtlCleanupExtended.test_cleanup_expired_skips_stale_heap_entries 365 If a fact was already unregistered, its heap entry is stale.
method TestTtlCleanupExtended.test_cleanup_expired_updates_stats 377
method TestTtlCleanupExtended.test_cleanup_expired_multiple_runs 385
class TestQueriesExtended 401
method TestQueriesExtended.test_get_fact_not_found 402
method TestQueriesExtended.test_get_session_facts_empty_session 406
method TestQueriesExtended.test_get_session_facts_with_stale_reference 410 Session facts set may reference a fact already unregistered.
method TestQueriesExtended.test_get_facts_by_predicate_no_match 420
method TestQueriesExtended.test_get_facts_by_predicate_multiple_matches 425
method TestQueriesExtended.test_get_stats_empty_manager 434
method TestQueriesExtended.test_get_stats_returns_copy 444
class TestBulkOperationsExtended 460
method TestBulkOperationsExtended.test_clear_all_empty_manager 461
method TestBulkOperationsExtended.test_clear_all_mixed_scopes 465
method TestBulkOperationsExtended.test_export_facts_empty 477
method TestBulkOperationsExtended.test_export_facts_with_ttl 481
method TestBulkOperationsExtended.test_export_facts_without_ttl 492
method TestBulkOperationsExtended.test_export_facts_multiple 500
class TestThreadSafetyExtended 515
method TestThreadSafetyExtended.test_concurrent_registration 516
method TestThreadSafetyExtended.test_concurrent_unregister_and_cleanup 549
method TestThreadSafetyExtended.test_start_stop_thread_safety 592
class TestSessionManagementIntegrationExtended 629
method TestSessionManagementIntegrationExtended.test_full_session_lifecycle 630
method TestSessionManagementIntegrationExtended.test_multiple_sessions_isolated 659
method TestSessionManagementIntegrationExtended.test_session_end_then_new_session_same_id 672
method TestSessionManagementIntegrationExtended.test_request_facts_outlive_session_end 683 Request facts are independent of session lifecycle.
method TestSessionManagementIntegrationExtended.test_global_facts_survive_all_cleanups 690
class TestErrorHandlingExtended 706
method TestErrorHandlingExtended.test_register_fact_with_non_hashable_args 707 Arguments are stored as tuples; lists should work if assert_fn accepts.
method TestErrorHandlingExtended.test_retract_exception_during_session_end 715
method TestErrorHandlingExtended.test_retract_false_during_clear_all 725
method TestErrorHandlingExtended.test_assert_fn_raises_during_concurrent_registration 732
method TestErrorHandlingExtended.test_cleanup_expired_with_corrupt_heap 754 Heap may contain entries for already-removed facts.
method TestErrorHandlingExtended.test_unregister_fact_after_clear_all 769
method TestErrorHandlingExtended.test_session_end_with_missing_retract 776 Session end must handle retract failures gracefully.
class TestFactMetadataExtended 796
method TestFactMetadataExtended.test_expires_at_with_zero_ttl_is_none 797 timedelta(0) is falsy, so expires_at is None in current implementation.
method TestFactMetadataExtended.test_is_expired_with_zero_ttl_is_false 811 timedelta(0) is falsy, so is_expired() returns False in current implementation.
method TestFactMetadataExtended.test_is_expired_negative_ttl 825
method TestFactMetadataExtended.test_is_expired_future_ttl 838
class TestFactStatsExtended 857
method TestFactStatsExtended.test_fact_stats_custom_values 858
method TestFactStatsExtended.test_fact_stats_field_defaults_are_isolated 871