diff --git a/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_create.py b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_create.py new file mode 100644 index 0000000000..7a6f822bee --- /dev/null +++ b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_create.py @@ -0,0 +1,38 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pylint: disable=protected-access,bad-continuation,missing-function-docstring + +from tests.unit.vertexai.genai.replays import pytest_helper +from vertexai._genai import types + + +def test_private_create(client): + spec = { + "code_execution_environment": {"machineConfig": "MACHINE_CONFIG_VCPU4_RAM4GIB"} + } + agent_engine_sandbox_operation = client.agent_engines.sandboxes._create( + name=( + "projects/964831358985/locations/us-central1/reasoningEngines/2886612747586371584" + ), + spec=spec, + ) + assert isinstance(agent_engine_sandbox_operation, types.AgentEngineSandboxOperation) + + +pytestmark = pytest_helper.setup( + file=__file__, + globals_for_file=globals(), + test_method="agent_engines.sandboxes._create", +) diff --git a/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_delete.py b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_delete.py new file mode 100644 index 0000000000..45c3eb4cb9 --- /dev/null +++ b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_delete.py @@ -0,0 +1,36 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pylint: disable=protected-access,bad-continuation,missing-function-docstring + +from tests.unit.vertexai.genai.replays import pytest_helper +from vertexai._genai import types + + +def test_private_delete(client): + agent_engine_sandbox_delete_operation = client.agent_engines.sandboxes._delete( + name=( + "reasoningEngines/2886612747586371584/sandboxEnvironments/6068475153556176896" + ), + ) + assert isinstance( + agent_engine_sandbox_delete_operation, types.DeleteAgentEngineSandboxOperation + ) + + +pytestmark = pytest_helper.setup( + file=__file__, + globals_for_file=globals(), + test_method="agent_engines.sandboxes._delete", +) diff --git a/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_execute_code.py b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_execute_code.py new file mode 100644 index 0000000000..ee07284663 --- /dev/null +++ b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_execute_code.py @@ -0,0 +1,62 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pylint: disable=protected-access,bad-continuation,missing-function-docstring + +import json + +from tests.unit.vertexai.genai.replays import pytest_helper +from vertexai._genai import types + + +def test_private_execute_code(client): + + code = """ +with open("test.txt", "r") as input: + with open("output.txt", "w") as output_txt: + for line in input: + output_txt.write(line) +""" + # Transform the input data into chunks as expected by _execute_code + input_chunks = [ + types.Chunk( + mime_type="application/json", + data=json.dumps({"code": code}).encode("utf-8"), + ), + types.Chunk( + mime_type="text/plain", + data=b"Hello, world!", + metadata={"attributes": {"file_name": b"test.txt"}}, + ), + ] + + execute_code_response = client.agent_engines.sandboxes._execute_code( + name=( + "reasoningEngines/2886612747586371584/sandboxEnvironments/6068475153556176896" + ), + inputs=input_chunks, + ) + assert isinstance( + execute_code_response, + types.ExecuteSandboxEnvironmentResponse, + ) + assert isinstance(execute_code_response.outputs, list) + assert isinstance(execute_code_response.outputs[0], types.Chunk) + + +pytestmark = pytest_helper.setup( + file=__file__, + globals_for_file=globals(), + test_method="agent_engines.sandboxes._execute_code", +) diff --git a/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_get.py b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_get.py new file mode 100644 index 0000000000..35a3c41fb1 --- /dev/null +++ b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_get.py @@ -0,0 +1,34 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pylint: disable=protected-access,bad-continuation,missing-function-docstring + +from tests.unit.vertexai.genai.replays import pytest_helper +from vertexai._genai import types + + +def test_private_get(client): + + sandbox_name = "projects/964831358985/locations/us-central1/reasoningEngines/2886612747586371584/sandboxEnvironments/3186171392039059456" + + agent_engine_sandbox = client.agent_engines.sandboxes._get(name=sandbox_name) + assert isinstance(agent_engine_sandbox, types.SandboxEnvironment) + assert agent_engine_sandbox.name == sandbox_name + + +pytestmark = pytest_helper.setup( + file=__file__, + globals_for_file=globals(), + test_method="agent_engines.sandboxes._get", +) diff --git a/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_get_sandbox_operation.py b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_get_sandbox_operation.py new file mode 100644 index 0000000000..bdf1202372 --- /dev/null +++ b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_get_sandbox_operation.py @@ -0,0 +1,38 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pylint: disable=protected-access,bad-continuation,missing-function-docstring + +from tests.unit.vertexai.genai.replays import pytest_helper +from vertexai._genai import types + + +def test_private_get_operation(client): + + operation_name = ( + "projects/964831358985/locations/us-central1/operations/4799455193970245632" + ) + + agent_engine_sandbox = client.agent_engines.sandboxes._get_sandbox_operation( + operation_name=operation_name + ) + assert isinstance(agent_engine_sandbox, types.AgentEngineSandboxOperation) + assert agent_engine_sandbox.name == operation_name + + +pytestmark = pytest_helper.setup( + file=__file__, + globals_for_file=globals(), + test_method="agent_engines.sandboxes._get_sandbox_operation", +) diff --git a/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_list.py b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_list.py new file mode 100644 index 0000000000..0457b49067 --- /dev/null +++ b/tests/unit/vertexai/genai/replays/test_ae_sandboxes_private_list.py @@ -0,0 +1,38 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# pylint: disable=protected-access,bad-continuation,missing-function-docstring + +from tests.unit.vertexai.genai.replays import pytest_helper +from vertexai._genai import types + + +def test_private_list(client): + agent_engine_sandbox_list_operation = client.agent_engines.sandboxes._list( + name=("reasoningEngines/2886612747586371584"), + ) + assert isinstance( + agent_engine_sandbox_list_operation.sandbox_environments[0], + types.SandboxEnvironment, + ) + assert isinstance( + agent_engine_sandbox_list_operation, types.ListAgentEngineSandboxesResponse + ) + + +pytestmark = pytest_helper.setup( + file=__file__, + globals_for_file=globals(), + test_method="agent_engines.sandboxes._list", +)