Skip to content

Commit

Permalink
(issue14) Move agent_manager to respective app/helpers folder
Browse files Browse the repository at this point in the history
  • Loading branch information
shoutsid committed Oct 18, 2023
1 parent 9d766ac commit f5ab6a1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
File renamed without changes.
38 changes: 38 additions & 0 deletions tests/app/agents/message_router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from app.helpers.message_router import MessageRouter
from app.helpers.agent_manager import AgentManager
import os
import sys
import pytest

sys.path.insert(
0, os.path.abspath(os.path.join(
os.path.dirname(__file__), "..", "..", ".."))
)


@pytest.mark.asyncio
async def test_message_routing():
# Initialize AgentManager and MessageRouter
agent_manager = AgentManager()
message_router = MessageRouter(agent_manager)

# Register an agent for testing
await agent_manager.register_agent(
"001", {"name": "Agent Smith", "status": "active"}
)

# Test message sending
assert (
await message_router.send_message("001", "Hello, Agent Smith.")
== "Message sent to agent 001."
)

# Test message fetching
assert await message_router.fetch_messages("001") == ["Hello, Agent Smith."]

# Test message sending after unregistration
await agent_manager.unregister_agent("001")
assert (
await message_router.send_message("001", "Hello, Agent Smith.")
== "Agent 001 not found."
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from app.helpers.inter_agent_comm import InterAgentComm
from agents.helpers.agent_manager import AgentManager
from app.helpers.agent_manager import AgentManager


@pytest.mark.asyncio
Expand Down
2 changes: 1 addition & 1 deletion tests/app/helpers/message_router_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from app.helpers.message_router import MessageRouter
from agents.helpers.agent_manager import AgentManager
from app.helpers.agent_manager import AgentManager
from app.helpers.inter_agent_comm import InterAgentComm
import pytest

Expand Down

0 comments on commit f5ab6a1

Please sign in to comment.