Mock agent for unit testing.
| 44 | |
| 45 | |
| 46 | class MockAgent(BaseAgent): |
| 47 | """Mock agent for unit testing.""" |
| 48 | |
| 49 | def __init__( |
| 50 | self, |
| 51 | name: str, |
| 52 | parent_agent: Optional[BaseAgent] = None, |
| 53 | ): |
| 54 | super().__init__(name=name, sub_agents=[]) |
| 55 | # BaseAgent doesn't have disallow_transfer_to_parent field |
| 56 | # This is intentional as we want to test non-LLM agents |
| 57 | if parent_agent: |
| 58 | self.parent_agent = parent_agent |
| 59 | |
| 60 | async def _run_async_impl( |
| 61 | self, invocation_context: InvocationContext |
| 62 | ) -> AsyncGenerator[Event, None]: |
| 63 | yield Event( |
| 64 | invocation_id=invocation_context.invocation_id, |
| 65 | author=self.name, |
| 66 | content=types.Content( |
| 67 | role="model", parts=[types.Part(text="Test response")] |
| 68 | ), |
| 69 | ) |
| 70 | |
| 71 | |
| 72 | class MockLiveAgent(BaseAgent): |
no outgoing calls