|
15 | 15 | # pylint: disable=protected-access,bad-continuation,missing-function-docstring |
16 | 16 |
|
17 | 17 | import os |
| 18 | +import re |
18 | 19 |
|
19 | 20 | from tests.unit.vertexai.genai.replays import pytest_helper |
20 | 21 | from vertexai._genai import types |
|
23 | 24 | {"name": "query", "api_mode": ""}, |
24 | 25 | ] |
25 | 26 |
|
| 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 | + |
26 | 31 |
|
27 | 32 | def test_create_config_lightweight(client): |
28 | 33 | agent_display_name = "test-display-name" |
@@ -146,6 +151,25 @@ def test_create_with_source_packages( |
146 | 151 | client.agent_engines.delete(name=agent_engine.api_resource.name, force=True) |
147 | 152 |
|
148 | 153 |
|
| 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 | + |
149 | 173 | pytestmark = pytest_helper.setup( |
150 | 174 | file=__file__, |
151 | 175 | globals_for_file=globals(), |
|
0 commit comments