Skip to content

Commit 186e6d8

Browse files
petjahncopybara-github
authored andcommitted
chore: add replay tests for agent identity fields (identity_type and effective_identity)
PiperOrigin-RevId: 836547231
1 parent dd4775b commit 186e6d8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
1616

1717
import os
18+
import re
1819

1920
from tests.unit.vertexai.genai.replays import pytest_helper
2021
from vertexai._genai import types
@@ -23,6 +24,10 @@
2324
{"name": "query", "api_mode": ""},
2425
]
2526

27+
_AGENT_IDENTITY_REGEX = re.compile(
28+
"agents.global.org-[0-9]+.system.id.goog/resources/aiplatform/projects/[0-9]+/locations/us-central1/reasoningEngines/[0-9a-zA-Z]+"
29+
)
30+
2631

2732
def test_create_config_lightweight(client):
2833
agent_display_name = "test-display-name"
@@ -146,6 +151,25 @@ def test_create_with_source_packages(
146151
client.agent_engines.delete(name=agent_engine.api_resource.name, force=True)
147152

148153

154+
def test_create_with_identity_type(client):
155+
"""Tests creating an agent engine with identity type."""
156+
agent_engine = client.agent_engines.create(
157+
config={
158+
"identity_type": types.IdentityType.AGENT_IDENTITY,
159+
"http_options": {"api_version": "v1beta1"},
160+
},
161+
)
162+
assert (
163+
agent_engine.api_resource.spec.identity_type
164+
== types.IdentityType.AGENT_IDENTITY
165+
)
166+
assert _AGENT_IDENTITY_REGEX.match(
167+
agent_engine.api_resource.spec.effective_identity
168+
)
169+
# Clean up resources.
170+
client.agent_engines.delete(name=agent_engine.api_resource.name, force=True)
171+
172+
149173
pytestmark = pytest_helper.setup(
150174
file=__file__,
151175
globals_for_file=globals(),

0 commit comments

Comments
 (0)