|
| 1 | +import os |
| 2 | +import uuid |
| 3 | +import asyncio |
| 4 | + |
| 5 | +import pytest |
| 6 | +import pytest_asyncio |
| 7 | +from test_utils.async_utils import ( |
| 8 | + poll_messages, |
| 9 | + stream_agent_response, |
| 10 | + send_event_and_poll_yielding, |
| 11 | +) |
| 12 | + |
| 13 | +from agentex import AsyncAgentex |
| 14 | +from agentex.types import TaskMessage |
| 15 | +from agentex.types.agent_rpc_params import ParamsCreateTaskRequest |
| 16 | +from agentex.types.text_content_param import TextContentParam |
| 17 | + |
| 18 | +# Configuration from environment variables |
| 19 | +AGENTEX_API_BASE_URL = os.environ.get("AGENTEX_API_BASE_URL", "http://localhost:5003") |
| 20 | +AGENT_NAME = os.environ.get("AGENT_NAME", "claude_") |
| 21 | + |
| 22 | + |
| 23 | +@pytest_asyncio.fixture |
| 24 | +async def client(): |
| 25 | + """Create an AgentEx client instance for testing.""" |
| 26 | + client = AsyncAgentex(base_url=AGENTEX_API_BASE_URL) |
| 27 | + yield client |
| 28 | + await client.close() |
| 29 | + |
| 30 | + |
| 31 | +@pytest.fixture |
| 32 | +def agent_name(): |
| 33 | + """Return the agent name for testing.""" |
| 34 | + return AGENT_NAME |
| 35 | + |
| 36 | + |
| 37 | +@pytest_asyncio.fixture |
| 38 | +async def agent_id(client: AsyncAgentex, agent_name): |
| 39 | + """Retrieve the agent ID based on the agent name.""" |
| 40 | + agents = await client.agents.list() |
| 41 | + for agent in agents: |
| 42 | + if agent.name == agent_name: |
| 43 | + return agent.id |
| 44 | + raise ValueError(f"Agent with name {agent_name} not found.") |
| 45 | + |
| 46 | + |
| 47 | +class TestNonStreamingEvents: |
| 48 | + """Test non-streaming event sending and polling.""" |
| 49 | + |
| 50 | + @pytest.mark.asyncio |
| 51 | + async def test_send_event_and_poll(self, client: AsyncAgentex, agent_id: str): |
| 52 | + """Test sending an event and polling for the response.""" |
| 53 | + pass |
| 54 | + |
| 55 | + |
| 56 | +class TestStreamingEvents: |
| 57 | + """Test streaming event sending.""" |
| 58 | + |
| 59 | + @pytest.mark.asyncio |
| 60 | + async def test_send_event_and_stream(self, client: AsyncAgentex, agent_id: str): |
| 61 | + """Test sending an event and streaming the response.""" |
| 62 | + pass |
| 63 | + |
| 64 | + |
| 65 | +if __name__ == "__main__": |
| 66 | + pytest.main([__file__, "-v"]) |
0 commit comments