1515import asyncio
1616import importlib
1717import json
18+ import logging
1819import os
1920import pytest
2021import sys
@@ -963,10 +964,17 @@ def test_list_agent_engine(self):
963964 None ,
964965 )
965966
967+ @pytest .mark .usefixtures ("caplog" )
966968 @mock .patch .object (_agent_engines , "_prepare" )
967969 @mock .patch .object (agent_engines .AgentEngines , "_await_operation" )
968- def test_create_agent_engine (self , mock_await_operation , mock_prepare ):
969- mock_await_operation .return_value = _genai_types .AgentEngineOperation ()
970+ def test_create_agent_engine (self , mock_await_operation , mock_prepare , caplog ):
971+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
972+ response = _genai_types .ReasoningEngine (
973+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
974+ spec = _TEST_AGENT_ENGINE_SPEC ,
975+ )
976+ )
977+ caplog .set_level (logging .INFO , logger = "vertexai_genai.agentengines" )
970978 with mock .patch .object (
971979 self .client .agent_engines ._api_client , "request"
972980 ) as request_mock :
@@ -1004,6 +1012,12 @@ def test_create_agent_engine(self, mock_await_operation, mock_prepare):
10041012 },
10051013 None ,
10061014 )
1015+ assert "View progress and logs at" in caplog .text
1016+ assert "Agent Engine created. To use it in another session:" in caplog .text
1017+ assert (
1018+ f"agent_engine=client.agent_engines.get("
1019+ f"'{ _TEST_AGENT_ENGINE_RESOURCE_NAME } ')" in caplog .text
1020+ )
10071021
10081022 @mock .patch .object (agent_engines .AgentEngines , "_create_config" )
10091023 @mock .patch .object (agent_engines .AgentEngines , "_await_operation" )
@@ -1016,7 +1030,12 @@ def test_create_agent_engine_lightweight(
10161030 display_name = _TEST_AGENT_ENGINE_DISPLAY_NAME ,
10171031 description = _TEST_AGENT_ENGINE_DESCRIPTION ,
10181032 )
1019- mock_await_operation .return_value = _genai_types .AgentEngineOperation ()
1033+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
1034+ response = _genai_types .ReasoningEngine (
1035+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
1036+ spec = _TEST_AGENT_ENGINE_SPEC ,
1037+ )
1038+ )
10201039 with mock .patch .object (
10211040 self .client .agent_engines ._api_client , "request"
10221041 ) as request_mock :
@@ -1061,7 +1080,12 @@ def test_create_agent_engine_with_env_vars_dict(
10611080 "agent_framework" : _TEST_AGENT_ENGINE_FRAMEWORK ,
10621081 },
10631082 }
1064- mock_await_operation .return_value = _genai_types .AgentEngineOperation ()
1083+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
1084+ response = _genai_types .ReasoningEngine (
1085+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
1086+ spec = _TEST_AGENT_ENGINE_SPEC ,
1087+ )
1088+ )
10651089 with mock .patch .object (
10661090 self .client .agent_engines ._api_client , "request"
10671091 ) as request_mock :
@@ -1106,10 +1130,19 @@ def test_create_agent_engine_with_env_vars_dict(
11061130 None ,
11071131 )
11081132
1133+ @pytest .mark .usefixtures ("caplog" )
11091134 @mock .patch .object (_agent_engines , "_prepare" )
11101135 @mock .patch .object (agent_engines .AgentEngines , "_await_operation" )
1111- def test_update_agent_engine_requirements (self , mock_await_operation , mock_prepare ):
1112- mock_await_operation .return_value = _genai_types .AgentEngineOperation ()
1136+ def test_update_agent_engine_requirements (
1137+ self , mock_await_operation , mock_prepare , caplog
1138+ ):
1139+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
1140+ response = _genai_types .ReasoningEngine (
1141+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
1142+ spec = _TEST_AGENT_ENGINE_SPEC ,
1143+ )
1144+ )
1145+ caplog .set_level (logging .INFO , logger = "vertexai_genai.agentengines" )
11131146 with mock .patch .object (
11141147 self .client .agent_engines ._api_client , "request"
11151148 ) as request_mock :
@@ -1149,13 +1182,23 @@ def test_update_agent_engine_requirements(self, mock_await_operation, mock_prepa
11491182 },
11501183 None ,
11511184 )
1185+ assert "Agent Engine updated. To use it in another session:" in caplog .text
1186+ assert (
1187+ f"agent_engine=client.agent_engines.get("
1188+ f"'{ _TEST_AGENT_ENGINE_RESOURCE_NAME } ')" in caplog .text
1189+ )
11521190
11531191 @mock .patch .object (_agent_engines , "_prepare" )
11541192 @mock .patch .object (agent_engines .AgentEngines , "_await_operation" )
11551193 def test_update_agent_engine_extra_packages (
11561194 self , mock_await_operation , mock_prepare
11571195 ):
1158- mock_await_operation .return_value = _genai_types .AgentEngineOperation ()
1196+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
1197+ response = _genai_types .ReasoningEngine (
1198+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
1199+ spec = _TEST_AGENT_ENGINE_SPEC ,
1200+ )
1201+ )
11591202 with mock .patch .object (
11601203 self .client .agent_engines ._api_client , "request"
11611204 ) as request_mock :
@@ -1201,8 +1244,15 @@ def test_update_agent_engine_extra_packages(
12011244
12021245 @mock .patch .object (_agent_engines , "_prepare" )
12031246 @mock .patch .object (agent_engines .AgentEngines , "_await_operation" )
1204- def test_update_agent_engine_env_vars (self , mock_await_operation , mock_prepare ):
1205- mock_await_operation .return_value = _genai_types .AgentEngineOperation ()
1247+ def test_update_agent_engine_env_vars (
1248+ self , mock_await_operation , mock_prepare , caplog
1249+ ):
1250+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
1251+ response = _genai_types .ReasoningEngine (
1252+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
1253+ spec = _TEST_AGENT_ENGINE_SPEC ,
1254+ )
1255+ )
12061256 with mock .patch .object (
12071257 self .client .agent_engines ._api_client , "request"
12081258 ) as request_mock :
@@ -1251,7 +1301,12 @@ def test_update_agent_engine_env_vars(self, mock_await_operation, mock_prepare):
12511301
12521302 @mock .patch .object (agent_engines .AgentEngines , "_await_operation" )
12531303 def test_update_agent_engine_display_name (self , mock_await_operation ):
1254- mock_await_operation .return_value = _genai_types .AgentEngineOperation ()
1304+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
1305+ response = _genai_types .ReasoningEngine (
1306+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
1307+ spec = _TEST_AGENT_ENGINE_SPEC ,
1308+ )
1309+ )
12551310 with mock .patch .object (
12561311 self .client .agent_engines ._api_client , "request"
12571312 ) as request_mock :
@@ -1275,7 +1330,12 @@ def test_update_agent_engine_display_name(self, mock_await_operation):
12751330
12761331 @mock .patch .object (agent_engines .AgentEngines , "_await_operation" )
12771332 def test_update_agent_engine_description (self , mock_await_operation ):
1278- mock_await_operation .return_value = _genai_types .AgentEngineOperation ()
1333+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
1334+ response = _genai_types .ReasoningEngine (
1335+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
1336+ spec = _TEST_AGENT_ENGINE_SPEC ,
1337+ )
1338+ )
12791339 with mock .patch .object (
12801340 self .client .agent_engines ._api_client , "request"
12811341 ) as request_mock :
0 commit comments