3
3
from jigsawstack .exceptions import JigsawStackError
4
4
import jigsawstack
5
5
import pytest
6
+ import asyncio
7
+ import logging
6
8
7
- # flake8: noq
9
+ logging .basicConfig (level = logging .INFO )
10
+ logger = logging .getLogger (__name__ )
8
11
9
12
jigsaw = jigsawstack .JigsawStack ()
13
+ async_jigsaw = jigsawstack .AsyncJigsawStack ()
10
14
11
15
12
- @pytest .mark .skip (reason = "Skipping TestWebAPI class for now" )
13
- class TestSearchAPI (unittest .TestCase ):
14
-
15
- def test_search_suggestion_response_success (self ) -> None :
16
- params = {"query" : "Time Square New Yor" }
16
+ def test_search_suggestion_response ():
17
+ async def _test ():
18
+ client = jigsawstack .AsyncJigsawStack ()
17
19
try :
18
- result = jigsaw . search . suggestion ( params )
20
+ result = await client . web . search ({ "query" : "Where is San Francisco" } )
19
21
assert result ["success" ] == True
20
22
except JigsawStackError as e :
21
- assert e .message == "Failed to parse API response. Please try again."
23
+ pytest .fail (f"Unexpected JigsawStackError: { e } " )
24
+
25
+ asyncio .run (_test ())
22
26
23
- def test_ai_search_response_success (self ) -> None :
24
- params = {"query" : "Time Square New Yor" }
27
+
28
+ def test_ai_search_response ():
29
+ async def _test ():
30
+ client = jigsawstack .AsyncJigsawStack ()
25
31
try :
26
- result = jigsaw . search . ai_search ( params )
32
+ result = await client . web . search ({ "query" : "Where is San Francisco" } )
27
33
assert result ["success" ] == True
28
34
except JigsawStackError as e :
29
- assert e .message == "Failed to parse API response. Please try again."
35
+ pytest .fail (f"Unexpected JigsawStackError: { e } " )
36
+
37
+ asyncio .run (_test ())
0 commit comments