1414#
1515# pylint: disable=protected-access,bad-continuation,missing-function-docstring
1616
17- import contextlib
1817import os
19- from unittest import mock
2018from tests .unit .agentplatform .genai .replays import pytest_helper
2119from agentplatform ._genai import types
2220from agentplatform .frameworks .a2a import default_a2a_agent
3028from a2a .utils .constants import TransportProtocol
3129
3230
33- def test_create_a2a_agent (client , is_replay_mode ):
31+ def test_create_a2a_agent (client ):
3432 my_agent = default_a2a_agent ()
3533
3634 my_agent .agent_card .supported_interfaces .append (
@@ -44,30 +42,20 @@ def test_create_a2a_agent(client, is_replay_mode):
4442
4543 staging_bucket = os .environ ["GCS_BUCKET" ]
4644
47- # In replay mode, GCS operations are mocked and blob.open("rb") returns a mock
48- # that fails when cloudpickle.load expects bytes. We mock _upload_runtime
49- # to skip this verification step, which is not needed when replaying API calls.
50- upload_patch = (
51- mock .patch ("agentplatform._genai._runtimes_utils._upload_runtime" )
52- if is_replay_mode
53- else contextlib .nullcontext ()
45+ runtime = client .runtimes .create (
46+ agent = my_agent ,
47+ config = {
48+ "staging_bucket" : staging_bucket ,
49+ "display_name" : "test-a2a-agent" ,
50+ "http_options" : {"api_version" : "v1beta1" },
51+ "requirements" : [
52+ "google-cloud-aiplatform[agent_engines]" ,
53+ "a2a-sdk" ,
54+ "sse-starlette" ,
55+ ],
56+ },
5457 )
5558
56- with upload_patch :
57- runtime = client .runtimes .create (
58- agent = my_agent ,
59- config = {
60- "staging_bucket" : staging_bucket ,
61- "display_name" : "test-a2a-agent" ,
62- "http_options" : {"api_version" : "v1beta1" },
63- "requirements" : [
64- "google-cloud-aiplatform[agent_engines]" ,
65- "a2a-sdk" ,
66- "sse-starlette" ,
67- ],
68- },
69- )
70-
7159
7260 assert isinstance (runtime , types .Runtime )
7361 assert runtime .api_resource .display_name == "test-a2a-agent"
0 commit comments