MCPcopy Create free account
hub / github.com/google/adk-python / test_resume_async

Function test_resume_async

tests/unittests/agents/test_loop_agent.py:143–168  ·  view source on GitHub ↗
(request: pytest.FixtureRequest)

Source from the content-addressed store, hash-verified

141
142@pytest.mark.asyncio
143async def test_resume_async(request: pytest.FixtureRequest):
144 agent_1 = _TestingAgent(name=f'{request.function.__name__}_test_agent_1')
145 agent_2 = _TestingAgent(name=f'{request.function.__name__}_test_agent_2')
146 loop_agent = LoopAgent(
147 name=f'{request.function.__name__}_test_loop_agent',
148 max_iterations=2,
149 sub_agents=[
150 agent_1,
151 agent_2,
152 ],
153 )
154 parent_ctx = await _create_parent_invocation_context(
155 request.function.__name__, loop_agent, resumable=True
156 )
157 parent_ctx.agent_states[loop_agent.name] = LoopAgentState(
158 current_sub_agent=agent_2.name, times_looped=1
159 ).model_dump(mode='json')
160
161 events = [e async for e in loop_agent.run_async(parent_ctx)]
162
163 simplified_events = testing_utils.simplify_resumable_app_events(events)
164 expected_events = [
165 (agent_2.name, f'Hello, async {agent_2.name}!'),
166 (loop_agent.name, END_OF_AGENT),
167 ]
168 assert simplified_events == expected_events
169
170
171@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 6

LoopAgentClass · 0.90
LoopAgentStateClass · 0.90
_TestingAgentClass · 0.70
model_dumpMethod · 0.45
run_asyncMethod · 0.45

Tested by

no test coverage detected