@@ -705,20 +705,27 @@ async def __aexit__(self, *args):
705705
706706 mock_live_client .aio .live .connect .return_value = MockLiveConnect ()
707707
708- async with gemini_llm .connect (llm_request ) as connection :
709- # Verify that the connect method was called with the right config
710- mock_live_client .aio .live .connect .assert_called_once ()
711- call_args = mock_live_client .aio .live .connect .call_args
712- config_arg = call_args .kwargs ["config" ]
713-
714- # Verify that http_options remains None since no custom headers were provided
715- assert config_arg .http_options is None
716-
717- # Verify that system instruction and tools were still set
718- assert config_arg .system_instruction is not None
719- assert config_arg .tools == llm_request .config .tools
720-
721- assert isinstance (connection , GeminiLlmConnection )
708+ with mock .patch (
709+ "google.adk.models.google_llm.GeminiLlmConnection"
710+ ) as MockGeminiLlmConnection :
711+ async with gemini_llm .connect (llm_request ) as connection :
712+ # Verify that the connect method was called with the right config
713+ mock_live_client .aio .live .connect .assert_called_once ()
714+ call_args = mock_live_client .aio .live .connect .call_args
715+ config_arg = call_args .kwargs ["config" ]
716+
717+ # Verify that http_options remains None since no custom headers were provided
718+ assert config_arg .http_options is None
719+
720+ # Verify that system instruction and tools were still set
721+ assert config_arg .system_instruction is not None
722+ assert config_arg .tools == llm_request .config .tools
723+
724+ MockGeminiLlmConnection .assert_called_once_with (
725+ mock_live_session ,
726+ api_backend = gemini_llm ._api_backend ,
727+ model_version = llm_request .model ,
728+ )
722729
723730
724731@pytest .mark .parametrize (
0 commit comments