Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
@@ -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",
)
Original file line number Diff line number Diff line change
@@ -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",
)
Loading