forked from PrefectHQ/marvin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_team_mcp_forward.py
More file actions
44 lines (30 loc) · 1.18 KB
/
Copy pathtest_team_mcp_forward.py
File metadata and controls
44 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from unittest.mock import AsyncMock, MagicMock
import pytest
from pydantic_ai.mcp import MCPServer
from marvin.agents.agent import Agent
from marvin.agents.team import Team
class DummyAgent(Agent):
from typing import Callable, Any
from marvin.agents.agent import Agent
from marvin.agents.team import Team
class DummyAgent(Agent):
async def get_agentlet(
self,
tools: list[Callable[..., Any]],
end_turn_tools: list["EndTurn"],
active_mcp_servers: list[MCPServer] | None = None,
):
# Assert that the forwarded arg is passed through
self._seen_active_mcp_servers = active_mcp_servers
# Return a minimal stub that satisfies Orchestrator usage patterns if needed
stub = MagicMock()
stub.iter = AsyncMock()
return stub
@pytest.mark.asyncio
async def test_team_forwards_active_mcp_servers():
mock_server = MagicMock(spec=MCPServer)
a1 = DummyAgent(name="A1")
a2 = DummyAgent(name="A2")
team = Team(members=[a1, a2])
await team.get_agentlet(tools=[], end_turn_tools=[], active_mcp_servers=[mock_server])
assert getattr(team.active_member, "_seen_active_mcp_servers", None) == [mock_server]