Skip to content

Commit 942b263

Browse files
committed
Add back TestGenerateResponses
1 parent ad00b9b commit 942b263

1 file changed

Lines changed: 42 additions & 38 deletions

File tree

tests/unittests/evaluation/test_evaluation_generator.py

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -597,44 +597,6 @@ async def mock_generate_inferences_side_effect(
597597
called_with_content = mock_generate_inferences.call_args.args[3]
598598
assert called_with_content.parts[0].text == "message 1"
599599

600-
@pytest.mark.asyncio
601-
async def test_generate_responses_forwards_llm_backed_user_simulator_config(
602-
self, mocker
603-
):
604-
"""Tests that an LlmBackedUserSimulatorConfig is forwarded to the provider verbatim."""
605-
mock_provider_cls = mocker.patch(
606-
"google.adk.evaluation.evaluation_generator.UserSimulatorProvider"
607-
)
608-
mocker.patch(
609-
"google.adk.evaluation.evaluation_generator.EvaluationGenerator._process_query",
610-
new_callable=mocker.AsyncMock,
611-
return_value=[],
612-
)
613-
614-
user_simulator_config = LlmBackedUserSimulatorConfig(
615-
model="test-model",
616-
max_allowed_invocations=5,
617-
)
618-
eval_set = EvalSet(
619-
eval_set_id="test_set",
620-
eval_cases=[EvalCase(eval_id="case_0", conversation=[])],
621-
)
622-
623-
await EvaluationGenerator.generate_responses(
624-
eval_set=eval_set,
625-
agent_module_path="some.agent.module",
626-
repeat_num=1,
627-
user_simulator_config=user_simulator_config,
628-
)
629-
630-
mock_provider_cls.assert_called_once_with(
631-
user_simulator_config=user_simulator_config
632-
)
633-
assert (
634-
mock_provider_cls.call_args.kwargs["user_simulator_config"]
635-
is user_simulator_config
636-
)
637-
638600
@pytest.mark.asyncio
639601
async def test_generates_inferences_with_user_simulator_live(
640602
self, mocker, mock_runner, mock_session_service
@@ -725,6 +687,48 @@ async def mock_generate_inferences_live_side_effect(*args, **kwargs):
725687
mock_live_session_cls.assert_called_once()
726688

727689

690+
class TestGenerateResponses:
691+
"""Test cases for EvaluationGenerator.generate_responses method."""
692+
693+
@pytest.mark.asyncio
694+
async def test_generate_responses_forwards_llm_backed_user_simulator_config(
695+
self, mocker
696+
):
697+
"""Tests that an LlmBackedUserSimulatorConfig is forwarded to the provider verbatim."""
698+
mock_provider_cls = mocker.patch(
699+
"google.adk.evaluation.evaluation_generator.UserSimulatorProvider"
700+
)
701+
mocker.patch(
702+
"google.adk.evaluation.evaluation_generator.EvaluationGenerator._process_query",
703+
new_callable=mocker.AsyncMock,
704+
return_value=[],
705+
)
706+
707+
user_simulator_config = LlmBackedUserSimulatorConfig(
708+
model="test-model",
709+
max_allowed_invocations=5,
710+
)
711+
eval_set = EvalSet(
712+
eval_set_id="test_set",
713+
eval_cases=[EvalCase(eval_id="case_0", conversation=[])],
714+
)
715+
716+
await EvaluationGenerator.generate_responses(
717+
eval_set=eval_set,
718+
agent_module_path="some.agent.module",
719+
repeat_num=1,
720+
user_simulator_config=user_simulator_config,
721+
)
722+
723+
mock_provider_cls.assert_called_once_with(
724+
user_simulator_config=user_simulator_config
725+
)
726+
assert (
727+
mock_provider_cls.call_args.kwargs["user_simulator_config"]
728+
is user_simulator_config
729+
)
730+
731+
728732
class TestLiveSessionCallbacks:
729733
"""Unit tests verifying that _LiveSession manually triggers callbacks."""
730734

0 commit comments

Comments
 (0)