Skip to content

Commit 2f10aa7

Browse files
QEDadycopybara-github
authored andcommitted
fix: test fix internal
PiperOrigin-RevId: 855176412
1 parent 0705a37 commit 2f10aa7

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

tests/unit/vertexai/genai/replays/test_create_agent_engine.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import os
1818
import re
19+
import sys
1920

2021
from tests.unit.vertexai.genai.replays import pytest_helper
2122
from vertexai._genai import types
@@ -124,6 +125,32 @@ def test_create_with_source_packages(
124125
mock_agent_engine_create_path_exists,
125126
):
126127
"""Tests creating an agent engine with source packages."""
128+
if sys.version_info >= (3, 13):
129+
try:
130+
client._api_client._initialize_replay_session_if_not_loaded()
131+
if client._api_client.replay_session:
132+
target_ver = f"{sys.version_info.major}.{sys.version_info.minor}"
133+
for interaction in client._api_client.replay_session.interactions:
134+
135+
def _update_ver(obj):
136+
if isinstance(obj, dict):
137+
if "python_spec" in obj and isinstance(
138+
obj["python_spec"], dict
139+
):
140+
if "version" in obj["python_spec"]:
141+
obj["python_spec"]["version"] = target_ver
142+
for v in obj.values():
143+
_update_ver(v)
144+
elif isinstance(obj, list):
145+
for item in obj:
146+
_update_ver(item)
147+
148+
if hasattr(interaction.request, "body_segments"):
149+
_update_ver(interaction.request.body_segments)
150+
if hasattr(interaction.request, "body"):
151+
_update_ver(interaction.request.body)
152+
except Exception:
153+
pass
127154
with (
128155
mock_agent_engine_create_base64_encoded_tarball,
129156
mock_agent_engine_create_path_exists,
@@ -144,12 +171,11 @@ def test_create_with_source_packages(
144171
},
145172
},
146173
)
147-
assert (
148-
agent_engine.api_resource.display_name
149-
== "test-agent-engine-source-packages"
150-
)
151-
# Clean up resources.
152-
client.agent_engines.delete(name=agent_engine.api_resource.name, force=True)
174+
assert (
175+
agent_engine.api_resource.display_name == "test-agent-engine-source-packages"
176+
)
177+
# Clean up resources.
178+
client.agent_engines.delete(name=agent_engine.api_resource.name, force=True)
153179

154180

155181
def test_create_with_identity_type(client):

0 commit comments

Comments
 (0)