File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from types import MappingProxyType
22
3+ import asyncio
34import pytest
45
56from 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+
2940def 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 ())
You can’t perform that action at this time.
0 commit comments