Skip to content

Commit 755d3e9

Browse files
committed
clean up docstring
1 parent 16e38e9 commit 755d3e9

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

packages/toolbox-core/tests/test_e2e.py

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
"""End-to-end tests for the toolbox SDK interacting with the toolbox server.
16-
17-
This file covers the following test cases:
18-
19-
1. Loading a tool.
20-
2. Loading a specific toolset.
21-
3. Loading the default toolset (contains all tools).
22-
4. Running a tool with
23-
a. Missing params.
24-
b. Wrong param type.
25-
5. Running a tool with no required auth, with auth provided.
26-
6. Running a tool with required auth:
27-
a. No auth provided.
28-
b. Wrong auth provided: The tool requires a different authentication
29-
than the one provided.
30-
c. Correct auth provided.
31-
7. Running a tool with a parameter that requires auth:
32-
a. No auth provided.
33-
b. Correct auth provided.
34-
c. Auth provided does not contain the required claim.
35-
8. Bind params to a tool
36-
a. Static param
37-
b. Callable param value
38-
"""
3914
import pytest
4015
import pytest_asyncio
4116

@@ -56,6 +31,7 @@ async def toolbox(self):
5631

5732
@pytest_asyncio.fixture(scope="function")
5833
async def get_n_rows_tool(self, toolbox: ToolboxClient) -> ToolboxTool:
34+
"""Load a tool."""
5935
tool = await toolbox.load_tool("get-n-rows")
6036
assert tool.__name__ == "get-n-rows"
6137
return tool
@@ -75,12 +51,14 @@ async def test_load_toolset_specific(
7551
expected_length: int,
7652
expected_tools: list[str],
7753
):
54+
"""Load a specific toolset"""
7855
toolset = await toolbox.load_toolset(toolset_name)
7956
assert len(toolset) == expected_length
8057
tool_names = {tool.__name__ for tool in toolset}
8158
assert tool_names == set(expected_tools)
8259

8360
async def test_run_tool(self, get_n_rows_tool: ToolboxTool):
61+
"""Invoke a tool."""
8462
response = await get_n_rows_tool(num_rows="2")
8563

8664
assert isinstance(response, str)
@@ -89,10 +67,12 @@ async def test_run_tool(self, get_n_rows_tool: ToolboxTool):
8967
assert "row3" not in response
9068

9169
async def test_run_tool_missing_params(self, get_n_rows_tool):
70+
"""Invoke a tool with missing params."""
9271
with pytest.raises(TypeError, match="missing a required argument: 'num_rows'"):
9372
await get_n_rows_tool()
9473

9574
async def test_run_tool_wrong_param_type(self, get_n_rows_tool: ToolboxTool):
75+
"""Invoke a tool with wrong param type."""
9676
with pytest.raises(
9777
Exception,
9878
match='provided parameters were invalid: unable to parse value for "num_rows": .* not type "string"',
@@ -101,6 +81,7 @@ async def test_run_tool_wrong_param_type(self, get_n_rows_tool: ToolboxTool):
10181

10282
##### Bind param tests
10383
async def test_bind_params(self, toolbox, get_n_rows_tool):
84+
"""Bind a param to an existing tool."""
10485
new_tool = get_n_rows_tool.bind_parameters({"num_rows": "3"})
10586
response = await new_tool()
10687

@@ -111,6 +92,7 @@ async def test_bind_params(self, toolbox, get_n_rows_tool):
11192
assert "row4" not in response
11293

11394
async def test_bind_params_callable(self, toolbox, get_n_rows_tool):
95+
"""Bind a callable param to an existing tool."""
11496
new_tool = get_n_rows_tool.bind_parameters({"num_rows": lambda: "3"})
11597
response = await new_tool()
11698

@@ -141,7 +123,8 @@ async def test_run_tool_no_auth(self, toolbox):
141123
await tool(id="2")
142124

143125
async def test_run_tool_wrong_auth(self, toolbox, auth_token2):
144-
"""Tests running a tool with incorrect auth."""
126+
"""Tests running a tool with incorrect auth. The tool
127+
requires a different authentication than the one provided."""
145128
tool = await toolbox.load_tool(
146129
"get-row-by-id-auth",
147130
)

0 commit comments

Comments
 (0)