Complete implementation of the DCOS package including: - 40+ Python source files across agents, communication, core, learning, memory, protocols, utils - pyproject.toml build configuration - 102 unit tests across all subsystems - Fixed flake.nix (Python 3.12, proper dependencies, pyproject build) - Fixed .woodpecker.yml (correct paths, removed silent-fail flags) - Added .gitignore - Cleared stale pytest cache
27 lines
801 B
Python
27 lines
801 B
Python
"""
|
|
Tests for CommunicationProtocol.
|
|
"""
|
|
|
|
import pytest
|
|
from dcos.communication.protocol import CommunicationProtocol, Message
|
|
|
|
|
|
class TestCommunicationProtocol:
|
|
def test_encode_decode(self):
|
|
proto = CommunicationProtocol()
|
|
msg = Message(sender="alice", recipient="bob", payload="hello")
|
|
encoded = proto.encode(msg)
|
|
assert encoded["sender"] == "alice"
|
|
assert encoded["recipient"] == "bob"
|
|
|
|
decoded = proto.decode(encoded)
|
|
assert decoded.payload == "hello"
|
|
|
|
def test_send_and_ack(self):
|
|
proto = CommunicationProtocol()
|
|
msg = Message(sender="a", recipient="b", payload="data")
|
|
assert proto.send(msg) is True
|
|
ack = proto.ack(msg.msg_id)
|
|
assert ack is not None
|
|
assert ack.msg_id == msg.msg_id
|