Skip to content

Commit 30bae1c

Browse files
committed
chore: remove redundant test_3lo.py
1 parent 46c3dd8 commit 30bae1c

File tree

5 files changed

+56
-135
lines changed

5 files changed

+56
-135
lines changed

packages/toolbox-adk/src/toolbox_adk/toolset.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from .tool import ToolboxContext, ToolboxTool
2525

2626

27-
2827
class ToolboxToolset(BaseToolset):
2928
"""
3029
A Toolset that provides tools from a remote Toolbox server.

packages/toolbox-adk/tests/integration/test_integration.py

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,23 @@
1313
# limitations under the License.
1414

1515

16-
from typing import Any, Optional
17-
import pytest
1816
import os
19-
from toolbox_adk import ToolboxToolset, CredentialStrategy, ToolboxTool
17+
from typing import Any, Optional
2018
from unittest.mock import MagicMock
21-
from google.adk.auth.auth_credential import AuthCredential, AuthCredentialTypes, OAuth2Auth
19+
20+
import pytest
21+
from google.adk.auth.auth_credential import (
22+
AuthCredential,
23+
AuthCredentialTypes,
24+
OAuth2Auth,
25+
)
26+
27+
from toolbox_adk import CredentialStrategy, ToolboxTool, ToolboxToolset
2228

2329
# Ensure TOOLBOX_VERSION is set for the fixture
2430
if "TOOLBOX_VERSION" not in os.environ:
25-
os.environ["TOOLBOX_VERSION"] = "0.0.1" # Use a valid version or mock
31+
os.environ["TOOLBOX_VERSION"] = "0.0.1" # Use a valid version or mock
32+
2633

2734
@pytest.mark.asyncio
2835
@pytest.mark.usefixtures("toolbox_server")
@@ -35,58 +42,58 @@ class TestToolboxAdkIntegration:
3542
async def test_load_toolset_and_run(self):
3643
# We assume the toolbox server (started by fixture) is at localhost:5000 (default)
3744
# Auth: TOOLBOX_IDENTITY for simplicity in this local test as we don't have ADK identity setup.
38-
45+
3946
toolset = ToolboxToolset(
4047
server_url="http://localhost:5000",
4148
toolset_name="my-toolset",
42-
credentials=CredentialStrategy.TOOLBOX_IDENTITY()
49+
credentials=CredentialStrategy.TOOLBOX_IDENTITY(),
4350
)
44-
51+
4552
try:
4653
tools = await toolset.get_tools()
4754
assert len(tools) > 0
48-
55+
4956
# Find 'get-row-by-id'
5057
tool = next((t for t in tools if t.name == "get-row-by-id"), None)
5158
assert tool is not None
5259
assert isinstance(tool, ToolboxTool)
53-
60+
5461
# Run it
5562
# Mocking ToolContext as we are running directly
5663
ctx = MagicMock()
5764
result = await tool.run_async({"id": "1"}, ctx)
58-
65+
5966
assert "row1" in result
60-
67+
6168
finally:
6269
await toolset.close()
6370

6471
async def test_partial_loading_by_names(self):
6572
toolset = ToolboxToolset(
6673
server_url="http://localhost:5000",
6774
tool_names=["get-n-rows"],
68-
credentials=CredentialStrategy.TOOLBOX_IDENTITY()
75+
credentials=CredentialStrategy.TOOLBOX_IDENTITY(),
6976
)
7077
try:
7178
tools = await toolset.get_tools()
7279
assert len(tools) == 1
7380
assert tools[0].name == "get-n-rows"
74-
81+
7582
# Run it
7683
ctx = MagicMock()
7784
result = await tools[0].run_async({"num_rows": "1"}, ctx)
7885
assert "row1" in result
79-
86+
8087
finally:
8188
await toolset.close()
82-
89+
8390
async def test_bound_params_e2e(self):
8491
# Test binding param at toolset level
8592
toolset = ToolboxToolset(
8693
server_url="http://localhost:5000",
8794
tool_names=["get-n-rows"],
8895
bound_params={"num_rows": "2"},
89-
credentials=CredentialStrategy.TOOLBOX_IDENTITY()
96+
credentials=CredentialStrategy.TOOLBOX_IDENTITY(),
9097
)
9198
try:
9299
tools = await toolset.get_tools()
@@ -103,53 +110,54 @@ async def test_3lo_flow_simulation(self):
103110
server_url="http://localhost:5000",
104111
toolset_name="auth-test-toolset",
105112
credentials=CredentialStrategy.USER_IDENTITY(
106-
client_id="test-client-id",
107-
client_secret="test-client-secret"
108-
)
113+
client_id="test-client-id", client_secret="test-client-secret"
114+
),
109115
)
110-
116+
111117
try:
112118
# 2. Get Tools (This hits the real server)
113119
# We filter for a simple tool if possible, or just take the first one.
114120
# We assume the fixture loads a manifest with at least one tool.
115121
tools = await toolset.get_tools()
116122
assert len(tools) > 0
117-
123+
118124
# Pick a tool
119125
tool = tools[0]
120126
assert isinstance(tool, ToolboxTool)
121-
127+
122128
# 3. Simulate First Call (No Credential)
123129
# Create a mock context that behaves like ADK's ReadonlyContext
124130
mock_ctx_first = MagicMock()
125131
# Simulate "No Auth Response Found"
126132
mock_ctx_first.get_auth_response.return_value = None
127-
133+
128134
print("Running tool first time (expecting auth request)...")
129135
result_first = await tool.run_async({}, mock_ctx_first)
130-
136+
131137
# 4. Verify Interruption
132138
# The wrapper should catch the missing creds and request them.
133-
assert result_first is None, "Tool should return None to signal auth requirement"
139+
assert (
140+
result_first is None
141+
), "Tool should return None to signal auth requirement"
134142
mock_ctx_first.request_credential.assert_called_once()
135-
143+
136144
# Inspect the requested config
137145
auth_config = mock_ctx_first.request_credential.call_args[0][0]
138146
assert auth_config.raw_auth_credential.oauth2.client_id == "test-client-id"
139-
147+
140148
# 5. Simulate Runner Handling & Second Call (With Credential)
141149
# The runner would get the token. We simulate passing it back in context.
142150
mock_ctx_second = MagicMock()
143-
151+
144152
# Simulate "Auth Response Found"
145153
mock_creds = AuthCredential(
146154
auth_type=AuthCredentialTypes.OAUTH2,
147-
oauth2=OAuth2Auth(access_token="fake-access-token")
155+
oauth2=OAuth2Auth(access_token="fake-access-token"),
148156
)
149157
mock_ctx_second.get_auth_response.return_value = mock_creds
150-
158+
151159
print("Running tool second time (expecting success or server error)...")
152-
160+
153161
try:
154162
result_second = await tool.run_async({}, mock_ctx_second)
155163
assert result_second is not None

packages/toolbox-adk/tests/unit/test_3lo.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

packages/toolbox-adk/tests/unit/test_client.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ def test_init_no_auth(self, mock_core_client):
2727
creds = CredentialStrategy.TOOLBOX_IDENTITY()
2828
client = ToolboxClient("http://server", credentials=creds)
2929

30-
mock_core_client.assert_called_with(
31-
url="http://server", client_headers={}
32-
)
30+
mock_core_client.assert_called_with(url="http://server", client_headers={})
3331

3432
@patch("toolbox_adk.client.toolbox_core.ToolboxClient")
3533
def test_init_manual_token(self, mock_core_client):
@@ -172,45 +170,38 @@ async def test_delegation(self, mock_core_client):
172170
@patch("toolbox_adk.client.toolbox_core.ToolboxClient")
173171
def test_init_additional_headers_callable(self, mock_core_client):
174172
creds = CredentialStrategy.TOOLBOX_IDENTITY()
175-
173+
176174
def my_header_provider():
177175
return "dynamic-val"
178-
179-
headers = {
180-
"X-Static": "static-val",
181-
"X-Dynamic": my_header_provider
182-
}
183-
176+
177+
headers = {"X-Static": "static-val", "X-Dynamic": my_header_provider}
178+
184179
client = ToolboxClient(
185-
"http://server",
186-
credentials=creds,
187-
additional_headers=headers
180+
"http://server", credentials=creds, additional_headers=headers
188181
)
189-
182+
190183
mock_core_client.assert_called_with(
191184
url="http://server",
192-
client_headers={
193-
"X-Static": "static-val",
194-
"X-Dynamic": my_header_provider
195-
}
185+
client_headers={"X-Static": "static-val", "X-Dynamic": my_header_provider},
196186
)
197-
187+
198188
@patch("toolbox_adk.client.toolbox_core.ToolboxClient")
199189
def test_close_calls_client_close(self, mock_core_client):
200190
# Coverage for close()
201191
mock_instance = mock_core_client.return_value
202192
# Make close an async mock
203193
mock_instance.close = AsyncMock()
204-
194+
205195
client = ToolboxClient("http://server")
206-
196+
207197
import asyncio
198+
208199
loop = asyncio.new_event_loop()
209200
loop.run_until_complete(client.close())
210201
loop.close()
211-
202+
212203
mock_instance.close.assert_called_once()
213-
204+
214205
@patch("toolbox_adk.client.toolbox_core.ToolboxClient")
215206
def test_credential_config_property(self, mock_core_client):
216207
# Coverage for credential_config property
@@ -224,9 +215,9 @@ async def test_load_tool_delegates(self, mock_core_client):
224215
# Coverage for load_tool()
225216
mock_instance = mock_core_client.return_value
226217
mock_instance.load_tool = AsyncMock(return_value="tool_result")
227-
218+
228219
client = ToolboxClient("http://server")
229220
result = await client.load_tool("my-tool", arg="val")
230-
221+
231222
assert result == "tool_result"
232223
mock_instance.load_tool.assert_called_with("my-tool", arg="val")

packages/toolbox-adk/tests/unit/test_toolset.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from toolbox_adk.toolset import ToolboxToolset
2121

2222

23-
2423
class TestToolboxToolset:
2524

2625
@patch("toolbox_adk.toolset.ToolboxClient")

0 commit comments

Comments
 (0)