@@ -112,16 +112,19 @@ def test_init_with_data_store_specs_without_search_engine_id_raises_error(
112112 ),
113113 ],
114114 )
115+ @mock .patch .object (discovery_engine_search_tool , "_get_api_endpoint" )
115116 @mock .patch .object (discovery_engine_search_tool , "client_options" )
116117 @mock .patch .object (discoveryengine , "SearchServiceClient" )
117118 def test_init_with_regional_location_uses_regional_endpoint (
118119 self ,
119120 mock_search_client ,
120121 mock_client_options ,
122+ mock_get_api_endpoint ,
121123 tool_kwargs ,
122124 expected_endpoint ,
123125 ):
124126 """Test initialization uses the expected regional API endpoint."""
127+ mock_get_api_endpoint .return_value = expected_endpoint
125128 DiscoveryEngineSearchTool (** tool_kwargs )
126129
127130 mock_client_options .ClientOptions .assert_called_once_with (
@@ -132,12 +135,14 @@ def test_init_with_regional_location_uses_regional_endpoint(
132135 client_options = mock_client_options .ClientOptions .return_value ,
133136 )
134137
138+ @mock .patch .object (discovery_engine_search_tool , "_get_api_endpoint" )
135139 @mock .patch .object (discovery_engine_search_tool , "client_options" )
136140 @mock .patch .object (discoveryengine , "SearchServiceClient" )
137141 def test_init_with_explicit_location_override_uses_input_location (
138- self , mock_search_client , mock_client_options
142+ self , mock_search_client , mock_client_options , mock_get_api_endpoint
139143 ):
140144 """Test initialization uses explicit location when resource has none."""
145+ mock_get_api_endpoint .return_value = "eu-discoveryengine.googleapis.com"
141146 DiscoveryEngineSearchTool (
142147 data_store_id = "test_data_store" ,
143148 location = "eu" ,
@@ -239,12 +244,14 @@ def test_init_with_global_location_keeps_default_endpoint(
239244 credentials = "credentials" , client_options = None
240245 )
241246
247+ @mock .patch .object (discovery_engine_search_tool , "_get_api_endpoint" )
242248 @mock .patch .object (discovery_engine_search_tool , "client_options" )
243249 @mock .patch .object (discoveryengine , "SearchServiceClient" )
244250 def test_init_with_regional_location_and_quota_project_id (
245- self , mock_search_client , mock_client_options
251+ self , mock_search_client , mock_client_options , mock_get_api_endpoint
246252 ):
247253 """Test initialization uses endpoint and quota project id together."""
254+ mock_get_api_endpoint .return_value = "eu-discoveryengine.googleapis.com"
248255 mock_credentials = mock .MagicMock ()
249256 mock_credentials .quota_project_id = "test-quota-project"
250257
0 commit comments