|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# pylint: disable=protected-access,bad-continuation,missing-function-docstring |
| 16 | + |
| 17 | +from tests.unit.vertexai.genai.replays import pytest_helper |
| 18 | +from vertexai._genai import types |
| 19 | + |
| 20 | +_TEST_CLASS_METHODS = [ |
| 21 | + {"name": "query", "api_mode": ""}, |
| 22 | +] |
| 23 | + |
| 24 | + |
| 25 | +def test_create_with_developer_connect_source(client): |
| 26 | + """Tests creating an agent engine with developer connect source.""" |
| 27 | + developer_connect_source_config = types.ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfig( |
| 28 | + git_repository_link="projects/reasoning-engine-test-1/locations/europe-west3/connections/shawn-develop-connect/gitRepositoryLinks/shawn-yang-google-adk-samples", |
| 29 | + revision="main", |
| 30 | + dir="test", |
| 31 | + ) |
| 32 | + agent_engine = client.agent_engines.create( |
| 33 | + config={ |
| 34 | + "display_name": "test-agent-engine-dev-connect", |
| 35 | + "developer_connect_source": developer_connect_source_config, |
| 36 | + "entrypoint_module": "my_agent", |
| 37 | + "entrypoint_object": "agent", |
| 38 | + "class_methods": _TEST_CLASS_METHODS, |
| 39 | + "http_options": { |
| 40 | + "base_url": "https://europe-west3-aiplatform.googleapis.com", |
| 41 | + "api_version": "v1beta1", |
| 42 | + }, |
| 43 | + }, |
| 44 | + ) |
| 45 | + assert agent_engine.api_resource.display_name == "test-agent-engine-dev-connect" |
| 46 | + assert ( |
| 47 | + agent_engine.api_resource.spec.source_code_spec.developer_connect_source.config.git_repository_link |
| 48 | + == developer_connect_source_config.git_repository_link |
| 49 | + ) |
| 50 | + assert ( |
| 51 | + agent_engine.api_resource.spec.source_code_spec.developer_connect_source.config.revision |
| 52 | + == developer_connect_source_config.revision |
| 53 | + ) |
| 54 | + assert ( |
| 55 | + agent_engine.api_resource.spec.source_code_spec.developer_connect_source.config.dir |
| 56 | + == developer_connect_source_config.dir |
| 57 | + ) |
| 58 | + # Clean up resources. |
| 59 | + client.agent_engines.delete(name=agent_engine.api_resource.name, force=True) |
| 60 | + |
| 61 | + |
| 62 | +pytestmark = pytest_helper.setup( |
| 63 | + file=__file__, |
| 64 | + globals_for_file=globals(), |
| 65 | + test_method="agent_engines.create", |
| 66 | +) |
0 commit comments