Skip to content

Commit f53a4da

Browse files
committed
lint
1 parent 25a3eee commit f53a4da

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

packages/toolbox-core/tests/test_tool.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import pytest
16-
from unittest.mock import AsyncMock, MagicMock
1715
from inspect import Parameter, Signature
18-
from typing import Any, Optional, Callable
16+
from typing import Any, Callable, Optional
17+
from unittest.mock import AsyncMock, MagicMock
18+
19+
import pytest
1920

2021
from toolbox_core.tool import ToolboxTool
2122

23+
2224
class TestToolboxTool:
2325
@pytest.fixture
2426
def mock_session(self) -> MagicMock: # Added self
@@ -32,7 +34,12 @@ def tool_details(self) -> dict:
3234
tool_name = "test_tool"
3335
params = [
3436
Parameter("arg1", Parameter.POSITIONAL_OR_KEYWORD, annotation=str),
35-
Parameter("opt_arg", Parameter.POSITIONAL_OR_KEYWORD, default=123, annotation=Optional[int]),
37+
Parameter(
38+
"opt_arg",
39+
Parameter.POSITIONAL_OR_KEYWORD,
40+
default=123,
41+
annotation=Optional[int],
42+
),
3643
]
3744
return {
3845
"base_url": base_url,
@@ -63,10 +70,13 @@ def _configure(json_data: Any, status: int = 200):
6370
mock_resp.__aenter__.return_value = mock_resp
6471
mock_resp.__aexit__.return_value = None
6572
mock_session.post.return_value = mock_resp
73+
6674
return _configure
6775

6876
@pytest.mark.asyncio
69-
async def test_initialization_and_introspection(self, tool: ToolboxTool, tool_details: dict):
77+
async def test_initialization_and_introspection(
78+
self, tool: ToolboxTool, tool_details: dict
79+
):
7080
"""Verify attributes are set correctly during initialization."""
7181
assert tool.__name__ == tool_details["name"]
7282
assert tool.__doc__ == tool_details["desc"]
@@ -82,7 +92,7 @@ async def test_call_success(
8292
tool: ToolboxTool,
8393
mock_session: MagicMock,
8494
tool_details: dict,
85-
configure_mock_response: Callable
95+
configure_mock_response: Callable,
8696
):
8797
expected_result = "Operation successful!"
8898
configure_mock_response({"result": expected_result})
@@ -104,7 +114,7 @@ async def test_call_success_with_defaults(
104114
tool: ToolboxTool,
105115
mock_session: MagicMock,
106116
tool_details: dict,
107-
configure_mock_response: Callable
117+
configure_mock_response: Callable,
108118
):
109119
expected_result = "Default success!"
110120
configure_mock_response({"result": expected_result})
@@ -126,7 +136,7 @@ async def test_call_api_error(
126136
tool: ToolboxTool,
127137
mock_session: MagicMock,
128138
tool_details: dict,
129-
configure_mock_response: Callable
139+
configure_mock_response: Callable,
130140
):
131141
error_message = "Tool execution failed on server"
132142
configure_mock_response({"error": error_message})
@@ -148,7 +158,7 @@ async def test_call_missing_result_key(
148158
tool: ToolboxTool,
149159
mock_session: MagicMock,
150160
tool_details: dict,
151-
configure_mock_response: Callable
161+
configure_mock_response: Callable,
152162
):
153163
fallback_response = {"status": "completed", "details": "some info"}
154164
configure_mock_response(fallback_response)
@@ -165,9 +175,7 @@ async def test_call_missing_result_key(
165175

166176
@pytest.mark.asyncio
167177
async def test_call_invalid_arguments_type_error(
168-
self,
169-
tool: ToolboxTool,
170-
mock_session: MagicMock
178+
self, tool: ToolboxTool, mock_session: MagicMock
171179
):
172180
with pytest.raises(TypeError):
173181
await tool("val1", 2, 3)
@@ -178,4 +186,4 @@ async def test_call_invalid_arguments_type_error(
178186
with pytest.raises(TypeError):
179187
await tool(opt_arg=500)
180188

181-
mock_session.post.assert_not_called()
189+
mock_session.post.assert_not_called()

0 commit comments

Comments
 (0)