Orchestrata Ultimate › Tests › Reference › session › test_coverage_session_context

Tests reference — tests/session/test_coverage_session_context.py

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

Prose pending.

tests/session/test_coverage_session_context.py

source · 24 tests · 509 lines

Test coverage for src/core/kernel/session_context.py

Covers: core.packet.packet, core.redis_factory, kernel.session_context

Kind Name Line Description
class TestContextValidator 32 Test ContextValidator validation logic
method TestContextValidator.test_validate_schema_non_dict 35 Line 65: validate_schema with non-dict raises ValueError
method TestContextValidator.test_validate_key_non_string 46 Line 87: validate_key with non-string raises ValueError
method TestContextValidator.test_validate_key_exceeds_max_length 57 Line 93: validate_key with key > MAX_KEY_LENGTH (256)
method TestContextValidator.test_validate_schema_with_invalid_keys 72 Ensure validate_schema catches invalid keys via validate_key
class TestSessionContextRedisFailure 86 Test SessionContext Redis connection failure cleanup
method TestSessionContextRedisFailure.test_init_redis_connection_failure 89 Lines 157-165: Redis connection failure during init
method TestSessionContextRedisFailure.test_init_redis_invalid_db 99 Redis connection with invalid database index
class TestSessionContextErrorHandling 114 Test SessionContext error handling paths
method TestSessionContextErrorHandling.test_set_redis_error 123 Lines 210-218: set() raises ConnectionError when connection fails.
method TestSessionContextErrorHandling.test_set_json_encode_error 146 Lines 210-218: set() raises ValueError for non-serializable value.
method TestSessionContextErrorHandling.test_get_json_decode_error 161 Lines 241-249: get() returns default when stored value is corrupted JSON.
method TestSessionContextErrorHandling.test_get_redis_error 181 Lines 241-249: get() raises RedisError when connection fails.
method TestSessionContextErrorHandling.test_update_json_encode_error 195 Lines 267-269: update() raises ValueError for non-serializable value.
method TestSessionContextErrorHandling.test_update_redis_error 210 Lines 277-282: update() raises RedisError when connection fails.
class TestExtractContext 230 Test extract_context with packets lacking payload
method TestExtractContext.test_extract_context_packet_without_payload 233 Line 343: packet without payload returns {}
method TestExtractContext.test_extract_context_packet_with_none_payload 252 Packet with payload=None
method TestExtractContext.test_extract_context_packet_payload_no_context 263 Packet with payload but no context attribute
class TestSerializeErrorHandling 284 Test serialize() error handling
method TestSerializeErrorHandling.test_serialize_json_decode_error 293 Lines 367-370: serialize() skips keys with malformed JSON, returns partial result.
method TestSerializeErrorHandling.test_serialize_redis_error 318 Lines 373-378: serialize() raises RedisError when connection fails.
class TestValidateSessionIsolation 338 Test validate_session_isolation with None session_id
method TestValidateSessionIsolation.test_validate_session_isolation_packet_session_id_none 341 Line 452: packet_session_id is None
method TestValidateSessionIsolation.test_validate_session_isolation_header_none 360 Packet with header=None
method TestValidateSessionIsolation.test_validate_session_isolation_no_header 371 Packet without header attribute
class TestSessionRouter 387 Test SessionRouter routing edge cases
method TestSessionRouter.test_route_within_session_recipient_not_in_session 390 Line 513: route raises ValueError when recipient is not in session.
method TestSessionRouter.test_route_within_session_packet_without_header 426 Line 519: route returns [] when packet has no header attribute.
class TestErrorPathsWithoutRedis 455 Test that error paths are properly defined even if Redis unavailable
method TestErrorPathsWithoutRedis.test_context_validator_comprehensive 458 Comprehensive validation tests
method TestErrorPathsWithoutRedis.test_packet_structures 480 Verify packet-like structures for edge case testing