36 lines
1 KiB
Python
36 lines
1 KiB
Python
"""Tests for method web.py"""
|
|
|
|
import logging
|
|
|
|
import pytest
|
|
from modules.methods.method_web import MethodWeb
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_method_web_search_live():
|
|
"""Tests method web search with live API calls."""
|
|
|
|
method_web = MethodWeb(serviceCenter=None)
|
|
|
|
# Actual request
|
|
action_result = await method_web.search(
|
|
{"query": "How old is the earth", "maxResults": 5}
|
|
)
|
|
|
|
# Evaluate results
|
|
assert action_result.success
|
|
assert len(action_result.documents) > 0
|
|
|
|
logger.info("=" * 20)
|
|
logger.info(f"Action result success status: {action_result.success}")
|
|
logger.info(f"Action result error: {action_result.error}")
|
|
logger.info(f"Action result label: {action_result.resultLabel}")
|
|
|
|
logger.info("Documents:")
|
|
for doc in action_result.documents:
|
|
logger.info("-" * 10)
|
|
logger.info(f" - Document Name: {doc.documentName}")
|
|
logger.info(f" - Document Mime Type: {doc.mimeType}")
|
|
logger.info(f" - Document Data: {doc.documentData}")
|