Skip to main content

Unit Tests for CODITECT Message Bus

Part of Track H.2: Inter-Agent Communication Infrastructure

Tests cover:

  • AgentMessage serialization/deserialization
  • MessageBusConfig from various sources
  • LocalMessageQueue functionality
  • MessageBus connection and disconnection
  • Message sending and receiving
  • Health check functionality

Run tests: cd scripts/core python -m pytest test_message_bus.py -v

# Or directly
python test_message_bus.py

Author: CODITECT Framework Created: January 8, 2026 Version: 1.0.0

File: test_message_bus.py

Classes

TestAgentMessage

Test AgentMessage dataclass.

TestMessageBusConfig

Test MessageBusConfig dataclass.

TestLocalMessageQueue

Test LocalMessageQueue for development mode.

TestMessageBusLocalMode

Test MessageBus in local fallback mode (no RabbitMQ).

TestCreateTaskMessage

Test create_task_message helper function.

TestMessageTypeEnum

Test MessageType enum.

TestMessagePriorityEnum

Test MessagePriority enum.

TestMessageBusQueueStats

Test queue statistics functionality.

TestMessageBusSendResponse

Test response sending functionality.

Functions

run_tests()

Run all tests and return results.

test_create_default_message()

Test creating a message with default values.

test_create_custom_message()

Test creating a message with custom values.

test_to_dict()

Test converting message to dictionary.

test_to_json()

Test converting message to JSON string.

test_from_dict()

Test creating message from dictionary.

test_from_json()

Test creating message from JSON string.

test_from_dict_ignores_unknown_fields()

Test that unknown fields are ignored when creating from dict.

test_round_trip_serialization()

Test that message survives JSON round-trip.

test_default_config()

Test default configuration values.

test_custom_config()

Test custom configuration values.

test_url_property()

Test URL generation.

test_url_with_ssl()

Test URL generation with SSL.

test_from_env()

Test creating config from environment variables.

test_from_file()

Test creating config from JSON file.

Usage

python test_message_bus.py