Skip to content

Commit e01de43

Browse files
Add async non-mapping validation coverage for tool wrappers
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 456956a commit e01de43

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_tools_mapping_inputs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from types import MappingProxyType
22

3+
import asyncio
34
import pytest
45

56
from hyperbrowser.exceptions import HyperbrowserError
@@ -26,6 +27,16 @@ def __init__(self):
2627
self.scrape = _ScrapeManager()
2728

2829

30+
class _AsyncScrapeManager:
31+
async def start_and_wait(self, params: StartScrapeJobParams):
32+
return _Response(type("Data", (), {"markdown": "ok"})())
33+
34+
35+
class _AsyncClient:
36+
def __init__(self):
37+
self.scrape = _AsyncScrapeManager()
38+
39+
2940
def test_tool_wrappers_accept_mapping_inputs():
3041
client = _Client()
3142
params = MappingProxyType({"url": "https://example.com"})
@@ -55,3 +66,15 @@ def __init__(self):
5566
client = _ExtractClient()
5667
with pytest.raises(HyperbrowserError, match="tool params must be a mapping"):
5768
WebsiteExtractTool.runnable(client, "bad") # type: ignore[arg-type]
69+
70+
71+
def test_async_tool_wrappers_reject_non_mapping_inputs():
72+
async def run() -> None:
73+
client = _AsyncClient()
74+
with pytest.raises(HyperbrowserError, match="tool params must be a mapping"):
75+
await WebsiteScrapeTool.async_runnable(
76+
client,
77+
["https://example.com"], # type: ignore[arg-type]
78+
)
79+
80+
asyncio.run(run())

0 commit comments

Comments
 (0)