Skip to content

Update/web search response #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jigsawstack/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class SearchResponse(TypedDict):

spell_fixed: str

geo_results: List[Any]

image_urls: List[str]

links: List[str]


class SearchSuggestionsResponse(TypedDict):
success: bool
Expand Down
32 changes: 20 additions & 12 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,35 @@
from jigsawstack.exceptions import JigsawStackError
import jigsawstack
import pytest
import asyncio
import logging

# flake8: noq
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

jigsaw = jigsawstack.JigsawStack()
async_jigsaw = jigsawstack.AsyncJigsawStack()


@pytest.mark.skip(reason="Skipping TestWebAPI class for now")
class TestSearchAPI(unittest.TestCase):

def test_search_suggestion_response_success(self) -> None:
params = {"query": "Time Square New Yor"}
def test_search_suggestion_response():
async def _test():
client = jigsawstack.AsyncJigsawStack()
try:
result = jigsaw.search.suggestion(params)
result = await client.web.search({"query": "Where is San Francisco"})
assert result["success"] == True
except JigsawStackError as e:
assert e.message == "Failed to parse API response. Please try again."
pytest.fail(f"Unexpected JigsawStackError: {e}")

asyncio.run(_test())

def test_ai_search_response_success(self) -> None:
params = {"query": "Time Square New Yor"}

def test_ai_search_response():
async def _test():
client = jigsawstack.AsyncJigsawStack()
try:
result = jigsaw.search.ai_search(params)
result = await client.web.search({"query": "Where is San Francisco"})
assert result["success"] == True
except JigsawStackError as e:
assert e.message == "Failed to parse API response. Please try again."
pytest.fail(f"Unexpected JigsawStackError: {e}")

asyncio.run(_test())
2 changes: 1 addition & 1 deletion tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def test_dns_success_response(self) -> None:
result = client.web.dns(params)
assert result["success"] == True
except JigsawStackError as e:
assert e.message == "Failed to parse API response. Please try again."
assert e.message == "Failed to parse API response. Please try again."