Skip to content

Commit 25ae3a7

Browse files
authored
Merge pull request #47 from winzamark123/update/web_search_response
Update/web search response
2 parents 2617cbc + 8b80d3f commit 25ae3a7

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

jigsawstack/search.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ class SearchResponse(TypedDict):
1919

2020
spell_fixed: str
2121

22+
geo_results: List[Any]
23+
24+
image_urls: List[str]
25+
26+
links: List[str]
27+
2228

2329
class SearchSuggestionsResponse(TypedDict):
2430
success: bool

tests/test_search.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,35 @@
33
from jigsawstack.exceptions import JigsawStackError
44
import jigsawstack
55
import pytest
6+
import asyncio
7+
import logging
68

7-
# flake8: noq
9+
logging.basicConfig(level=logging.INFO)
10+
logger = logging.getLogger(__name__)
811

912
jigsaw = jigsawstack.JigsawStack()
13+
async_jigsaw = jigsawstack.AsyncJigsawStack()
1014

1115

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()
1719
try:
18-
result = jigsaw.search.suggestion(params)
20+
result = await client.web.search({"query": "Where is San Francisco"})
1921
assert result["success"] == True
2022
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())
2226

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()
2531
try:
26-
result = jigsaw.search.ai_search(params)
32+
result = await client.web.search({"query": "Where is San Francisco"})
2733
assert result["success"] == True
2834
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())

tests/test_web.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def test_dns_success_response(self) -> None:
4242
result = client.web.dns(params)
4343
assert result["success"] == True
4444
except JigsawStackError as e:
45-
assert e.message == "Failed to parse API response. Please try again."
45+
assert e.message == "Failed to parse API response. Please try again."

0 commit comments

Comments
 (0)