Orchestrata Ultimate › Tests › Reference › postman › test_envelope

Tests reference — tests/postman/test_envelope.py

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

Prose pending.

tests/postman/test_envelope.py

source · 70 tests · 1112 lines

Comprehensive tests for EnvelopeHandler class.

Covers: core.base.traces, postman.constants, postman.envelope, postman.exceptions, postman.types

Kind Name Line Description
class TestEnvelopeCreation 86 Test envelope creation functionality.
method TestEnvelopeCreation.test_create_basic_envelope 89 Create envelope with minimal required fields.
method TestEnvelopeCreation.test_create_envelope_with_all_fields 107 Create envelope with all optional fields populated.
method TestEnvelopeCreation.test_create_envelope_with_topic_recipient 135 Create envelope with topic as recipient.
method TestEnvelopeCreation.test_create_envelope_generates_unique_message_id 147 Each created envelope should have a unique message_id.
method TestEnvelopeCreation.test_create_envelope_sets_utc_timestamp 159 Created envelope should have UTC timestamp.
method TestEnvelopeCreation.test_create_envelope_with_different_priorities 170 Create envelopes with different priority levels.
method TestEnvelopeCreation.test_create_envelope_with_different_content_types 190 Create envelopes with different content types.
class TestEnvelopeCreationErrors 217 Test envelope creation error handling.
method TestEnvelopeCreationErrors.test_create_envelope_empty_sender 220 Creating envelope with empty sender should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_whitespace_sender 227 Creating envelope with whitespace sender should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_empty_recipient 234 Creating envelope with empty recipient should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_whitespace_recipient 241 Creating envelope with whitespace recipient should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_invalid_sender_pattern 259 Creating envelope with invalid sender pattern should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_invalid_priority 267 Creating envelope with invalid priority should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_zero_ttl 282 Creating envelope with zero TTL should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_negative_ttl 293 Creating envelope with negative TTL should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_excessive_ttl 304 Creating envelope with TTL > 24 hours should raise error.
method TestEnvelopeCreationErrors.test_create_envelope_unsupported_content_type 317 Creating envelope with unsupported content type should raise error.
class TestEnvelopeValidation 334 Test envelope validation functionality.
method TestEnvelopeValidation.test_validate_valid_envelope 337 Validating a valid envelope should return True.
method TestEnvelopeValidation.test_validate_envelope_with_topic_recipient 346 Validating envelope with topic recipient should succeed.
method TestEnvelopeValidation.test_validate_envelope_invalid_message_id 356 Validating envelope with invalid message_id should fail.
method TestEnvelopeValidation.test_validate_envelope_empty_sender 367 Validating envelope with empty sender should fail.
method TestEnvelopeValidation.test_validate_envelope_invalid_sender_pattern 378 Validating envelope with invalid sender pattern should fail.
method TestEnvelopeValidation.test_validate_envelope_empty_recipient 389 Validating envelope with empty recipient should fail.
method TestEnvelopeValidation.test_validate_envelope_invalid_recipient_pattern 405 Validating envelope with invalid recipient pattern should fail.
method TestEnvelopeValidation.test_validate_envelope_content_type_validated_at_create 416 Content type is validated by create(), not by validate().
method TestEnvelopeValidation.test_validate_envelope_zero_ttl 433 Validating envelope with zero TTL should fail.
method TestEnvelopeValidation.test_validate_envelope_excessive_ttl 444 Validating envelope with excessive TTL should fail.
method TestEnvelopeValidation.test_validate_envelope_missing_timezone 455 Validating envelope with naive timestamp should fail.
class TestEnvelopeSerialization 473 Test envelope serialization functionality.
method TestEnvelopeSerialization.test_serialize_basic_envelope 476 Serialize envelope to bytes.
method TestEnvelopeSerialization.test_serialize_envelope_contains_all_fields 489 Serialized envelope should contain all fields.
method TestEnvelopeSerialization.test_serialize_envelope_preserves_values 508 Serialized envelope should preserve field values.
method TestEnvelopeSerialization.test_serialize_multiple_envelopes 536 Serialize multiple envelopes independently.
class TestEnvelopeDeserialization 557 Test envelope deserialization functionality.
method TestEnvelopeDeserialization.test_deserialize_basic_envelope 560 Deserialize envelope from bytes.
method TestEnvelopeDeserialization.test_deserialize_envelope_preserves_all_fields 573 Deserialized envelope should preserve all fields.
method TestEnvelopeDeserialization.test_deserialize_envelope_preserves_timestamp 605 Deserialized envelope should preserve timestamp with timezone.
method TestEnvelopeDeserialization.test_deserialize_invalid_json 619 Deserializing invalid JSON should raise error.
method TestEnvelopeDeserialization.test_deserialize_incomplete_envelope 626 Deserializing incomplete envelope handles missing fields gracefully.
method TestEnvelopeDeserialization.test_deserialize_malformed_timestamp 640 Deserializing envelope with malformed timestamp should raise error.
method TestEnvelopeDeserialization.test_roundtrip_serialization 657 Envelope should survive serialization-deserialization roundtrip.
class TestEnvelopeExpiration 684 Test envelope expiration functionality.
method TestEnvelopeExpiration.test_envelope_not_expired_immediately 687 Newly created envelope should not be expired.
method TestEnvelopeExpiration.test_envelope_not_expired_within_ttl 695 Envelope within TTL should not be expired.
method TestEnvelopeExpiration.test_envelope_expired_after_ttl 709 Envelope past TTL should be expired.
method TestEnvelopeExpiration.test_envelope_expiration_boundary 728 Test envelope expiration at exact TTL boundary.
class TestRoutingKeyExtraction 753 Test routing key extraction functionality.
method TestRoutingKeyExtraction.test_get_routing_key_agent_recipient 756 Extract routing key from envelope with agent recipient.
method TestRoutingKeyExtraction.test_get_routing_key_topic_recipient 765 Extract routing key from envelope with topic recipient.
method TestRoutingKeyExtraction.test_get_routing_key_strips_whitespace 774 Routing key should strip whitespace from recipient.
method TestRoutingKeyExtraction.test_get_routing_key_empty_recipient_raises_error 785 Getting routing key from envelope with empty recipient should raise error.
class TestTTLExtension 804 Test TTL extension functionality.
method TestTTLExtension.test_extend_ttl_basic 807 Extend envelope TTL by positive seconds.
method TestTTLExtension.test_extend_ttl_preserves_other_fields 820 Extending TTL should preserve all other envelope fields.
method TestTTLExtension.test_extend_ttl_multiple_times 833 Extend TTL multiple times sequentially.
method TestTTLExtension.test_extend_ttl_zero_seconds_raises_error 843 Extending TTL by zero seconds should raise error.
method TestTTLExtension.test_extend_ttl_negative_seconds_raises_error 852 Extending TTL by negative seconds should raise error.
method TestTTLExtension.test_extend_ttl_exceeds_maximum_raises_error 861 Extending TTL beyond maximum should raise error.
class TestContentTypeValidation 880 Test content type validation functionality.
method TestContentTypeValidation.test_validate_content_type_json 883 JSON content type should be valid.
method TestContentTypeValidation.test_validate_content_type_text 888 Text content type should be valid.
method TestContentTypeValidation.test_validate_content_type_binary 893 Binary content type should be valid.
method TestContentTypeValidation.test_validate_content_type_compressed 898 Compressed content type should be valid.
method TestContentTypeValidation.test_validate_content_type_unsupported 903 Unsupported content types should be invalid.
class TestEdgeCases 923 Test edge cases and error handling.
method TestEdgeCases.test_create_envelope_with_max_ttl 926 Create envelope with maximum allowed TTL.
method TestEdgeCases.test_create_envelope_with_min_ttl 938 Create envelope with minimum allowed TTL.
method TestEdgeCases.test_validate_all_agent_ids 977 Validate envelopes with all valid agent ID patterns.
method TestEdgeCases.test_validate_various_topic_patterns 997 Validate envelopes with various topic patterns.
method TestEdgeCases.test_serialize_deserialize_with_none_optional_fields 1005 Serialize/deserialize envelope with None optional fields.
class TestPreCXPFieldMigration 1043 Compatibility redirects mapping the deleted twin's field names onto
method TestPreCXPFieldMigration.test_sender_property_returns_from_ 1047 sender is a compatibility alias returning the same object as from_.
method TestPreCXPFieldMigration.test_recipient_property_returns_to 1055 recipient is a compatibility alias returning the same object as to.
method TestPreCXPFieldMigration.test_timestamp_property_returns_created_at 1063 timestamp is a compatibility alias returning the same object as created_at.
method TestPreCXPFieldMigration.test_content_type_property_raises_with_pointer_to_new_home 1070 MessageEnvelope has never had content_type; reading it fails loudly, not silently.
method TestPreCXPFieldMigration.test_content_type_hasattr_is_false 1078 hasattr() correctly reports the property absent (AttributeError propagates cleanly).
method TestPreCXPFieldMigration.test_correlation_id_round_trips_through_to_dict_from_dict 1086 REQ-002-FR1-007: correlation_id survives a direct to_dict()/from_dict() round trip.
method TestPreCXPFieldMigration.test_correlation_id_from_dict_missing_key_defaults_to_none 1103 from_dict() tolerates a dict with no correlation_id key (pre-restoration data).