|
| 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 | + |
| 21 | +def test_create_sandbox(client): |
| 22 | + agent_engine = client.agent_engines.create() |
| 23 | + assert isinstance(agent_engine, types.AgentEngine) |
| 24 | + assert isinstance(agent_engine.api_resource, types.ReasoningEngine) |
| 25 | + |
| 26 | + operation = client.agent_engines.sandboxes.create( |
| 27 | + name=agent_engine.api_resource.name, |
| 28 | + spec={ |
| 29 | + "code_execution_environment": { |
| 30 | + "machineConfig": "MACHINE_CONFIG_VCPU4_RAM4GIB" |
| 31 | + } |
| 32 | + }, |
| 33 | + config=types.CreateAgentEngineSandboxConfig(display_name="test_sandbox"), |
| 34 | + ) |
| 35 | + assert isinstance(operation, types.AgentEngineSandboxOperation) |
| 36 | + assert operation.response.display_name == "test_sandbox" |
| 37 | + assert operation.response.spec == { |
| 38 | + "code_execution_environment": {"machineConfig": "MACHINE_CONFIG_VCPU4_RAM4GIB"} |
| 39 | + } |
| 40 | + assert operation.response.name.startswith(agent_engine.api_resource.name) |
| 41 | + |
| 42 | + |
| 43 | +pytestmark = pytest_helper.setup( |
| 44 | + file=__file__, |
| 45 | + globals_for_file=globals(), |
| 46 | + test_method="agent_engines.create_sandbox", |
| 47 | +) |
0 commit comments