4040import pytest
4141
4242
43- _TEST_AGENT_FRAMEWORK = "test-agent-framework"
43+ _TEST_AGENT_FRAMEWORK = _genai_types .ReasoningEngineAgentFramework .GOOGLE_ADK
44+ _TEST_AGENT_FRAMEWORK_STR = "google-adk"
4445GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY = (
4546 "GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY"
4647)
@@ -976,9 +977,11 @@ def test_create_agent_engine_config_with_source_packages(
976977 entrypoint_object = "app" ,
977978 requirements_file = requirements_file_path ,
978979 class_methods = _TEST_AGENT_ENGINE_CLASS_METHODS ,
980+ agent_framework = _TEST_AGENT_FRAMEWORK ,
979981 )
980982 assert config ["display_name" ] == _TEST_AGENT_ENGINE_DISPLAY_NAME
981983 assert config ["description" ] == _TEST_AGENT_ENGINE_DESCRIPTION
984+ assert config ["spec" ]["agent_framework" ] == _TEST_AGENT_FRAMEWORK_STR
982985 assert config ["spec" ]["source_code_spec" ] == {
983986 "inline_source" : {"source_archive" : "test_tarball" },
984987 "python_spec" : {
@@ -1500,6 +1503,7 @@ def test_create_agent_engine_with_env_vars_dict(
15001503 entrypoint_module = None ,
15011504 entrypoint_object = None ,
15021505 requirements_file = None ,
1506+ agent_framework = None ,
15031507 )
15041508 request_mock .assert_called_with (
15051509 "post" ,
@@ -1586,6 +1590,7 @@ def test_create_agent_engine_with_custom_service_account(
15861590 entrypoint_module = None ,
15871591 entrypoint_object = None ,
15881592 requirements_file = None ,
1593+ agent_framework = None ,
15891594 )
15901595 request_mock .assert_called_with (
15911596 "post" ,
@@ -1674,6 +1679,7 @@ def test_create_agent_engine_with_experimental_mode(
16741679 entrypoint_module = None ,
16751680 entrypoint_object = None ,
16761681 requirements_file = None ,
1682+ agent_framework = None ,
16771683 )
16781684 request_mock .assert_called_with (
16791685 "post" ,
@@ -1826,6 +1832,7 @@ def test_create_agent_engine_with_class_methods(
18261832 entrypoint_module = None ,
18271833 entrypoint_object = None ,
18281834 requirements_file = None ,
1835+ agent_framework = None ,
18291836 )
18301837 request_mock .assert_called_with (
18311838 "post" ,
@@ -1845,6 +1852,92 @@ def test_create_agent_engine_with_class_methods(
18451852 None ,
18461853 )
18471854
1855+ @mock .patch .object (agent_engines .AgentEngines , "_create_config" )
1856+ @mock .patch .object (_agent_engines_utils , "_await_operation" )
1857+ def test_create_agent_engine_with_agent_framework (
1858+ self ,
1859+ mock_await_operation ,
1860+ mock_create_config ,
1861+ ):
1862+ mock_create_config .return_value = {
1863+ "display_name" : _TEST_AGENT_ENGINE_DISPLAY_NAME ,
1864+ "description" : _TEST_AGENT_ENGINE_DESCRIPTION ,
1865+ "spec" : {
1866+ "package_spec" : {
1867+ "python_version" : _TEST_PYTHON_VERSION ,
1868+ "pickle_object_gcs_uri" : _TEST_AGENT_ENGINE_GCS_URI ,
1869+ "requirements_gcs_uri" : _TEST_AGENT_ENGINE_REQUIREMENTS_GCS_URI ,
1870+ },
1871+ "class_methods" : [_TEST_AGENT_ENGINE_CLASS_METHOD_1 ],
1872+ "agent_framework" : _TEST_AGENT_FRAMEWORK_STR ,
1873+ },
1874+ }
1875+ mock_await_operation .return_value = _genai_types .AgentEngineOperation (
1876+ response = _genai_types .ReasoningEngine (
1877+ name = _TEST_AGENT_ENGINE_RESOURCE_NAME ,
1878+ spec = _TEST_AGENT_ENGINE_SPEC ,
1879+ )
1880+ )
1881+ with mock .patch .object (
1882+ self .client .agent_engines ._api_client , "request"
1883+ ) as request_mock :
1884+ request_mock .return_value = genai_types .HttpResponse (body = "" )
1885+ self .client .agent_engines .create (
1886+ agent = self .test_agent ,
1887+ config = _genai_types .AgentEngineConfig (
1888+ display_name = _TEST_AGENT_ENGINE_DISPLAY_NAME ,
1889+ requirements = _TEST_AGENT_ENGINE_REQUIREMENTS ,
1890+ extra_packages = [_TEST_AGENT_ENGINE_EXTRA_PACKAGE_PATH ],
1891+ staging_bucket = _TEST_STAGING_BUCKET ,
1892+ agent_framework = _TEST_AGENT_FRAMEWORK ,
1893+ ),
1894+ )
1895+ mock_create_config .assert_called_with (
1896+ mode = "create" ,
1897+ agent = self .test_agent ,
1898+ staging_bucket = _TEST_STAGING_BUCKET ,
1899+ requirements = _TEST_AGENT_ENGINE_REQUIREMENTS ,
1900+ display_name = _TEST_AGENT_ENGINE_DISPLAY_NAME ,
1901+ description = None ,
1902+ gcs_dir_name = None ,
1903+ extra_packages = [_TEST_AGENT_ENGINE_EXTRA_PACKAGE_PATH ],
1904+ env_vars = None ,
1905+ service_account = None ,
1906+ context_spec = None ,
1907+ psc_interface_config = None ,
1908+ min_instances = None ,
1909+ max_instances = None ,
1910+ resource_limits = None ,
1911+ container_concurrency = None ,
1912+ encryption_spec = None ,
1913+ labels = None ,
1914+ agent_server_mode = None ,
1915+ class_methods = None ,
1916+ source_packages = None ,
1917+ entrypoint_module = None ,
1918+ entrypoint_object = None ,
1919+ requirements_file = None ,
1920+ agent_framework = _TEST_AGENT_FRAMEWORK ,
1921+ )
1922+ request_mock .assert_called_with (
1923+ "post" ,
1924+ "reasoningEngines" ,
1925+ {
1926+ "displayName" : _TEST_AGENT_ENGINE_DISPLAY_NAME ,
1927+ "description" : _TEST_AGENT_ENGINE_DESCRIPTION ,
1928+ "spec" : {
1929+ "agent_framework" : _TEST_AGENT_FRAMEWORK_STR ,
1930+ "class_methods" : [_TEST_AGENT_ENGINE_CLASS_METHOD_1 ],
1931+ "package_spec" : {
1932+ "pickle_object_gcs_uri" : _TEST_AGENT_ENGINE_GCS_URI ,
1933+ "python_version" : _TEST_PYTHON_VERSION ,
1934+ "requirements_gcs_uri" : _TEST_AGENT_ENGINE_REQUIREMENTS_GCS_URI ,
1935+ },
1936+ },
1937+ },
1938+ None ,
1939+ )
1940+
18481941 @pytest .mark .usefixtures ("caplog" )
18491942 @mock .patch .object (_agent_engines_utils , "_prepare" )
18501943 @mock .patch .object (_agent_engines_utils , "_await_operation" )
0 commit comments