Livrare LOT 1 - Didi
This commit is contained in:
commit
5380c3fc63
990 changed files with 133308 additions and 0 deletions
50
ai_platform/modules/cloak/tests/test_schemas.py
Normal file
50
ai_platform/modules/cloak/tests/test_schemas.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
"""Quick schema validation tests — run with `pytest tests/`."""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from cloak.schemas import SearchRequest, SearchResponse, EngineStats, SearchResult
|
||||
|
||||
|
||||
def test_search_request_minimal():
|
||||
req = SearchRequest(queries=["BNR confiscare"])
|
||||
assert req.queries == ["BNR confiscare"]
|
||||
assert req.engines == ["google", "bing", "ddg"]
|
||||
assert req.max_results_per_engine == 10
|
||||
|
||||
|
||||
def test_search_request_rejects_unknown_engine():
|
||||
with pytest.raises(ValidationError):
|
||||
SearchRequest(queries=["x"], engines=["yahoo"])
|
||||
|
||||
|
||||
def test_search_request_rejects_empty_queries():
|
||||
with pytest.raises(ValidationError):
|
||||
SearchRequest(queries=[])
|
||||
|
||||
|
||||
def test_search_response_round_trip():
|
||||
resp = SearchResponse(
|
||||
results=[
|
||||
SearchResult(
|
||||
url="https://example.com",
|
||||
title="Example",
|
||||
snippet="...",
|
||||
engine="google",
|
||||
query="test",
|
||||
rank=1,
|
||||
),
|
||||
],
|
||||
stats=[
|
||||
EngineStats(
|
||||
engine="google", query="test",
|
||||
results_count=1, elapsed_ms=2000,
|
||||
),
|
||||
],
|
||||
total_elapsed_ms=2050,
|
||||
)
|
||||
j = resp.model_dump_json()
|
||||
parsed = SearchResponse.model_validate_json(j)
|
||||
assert len(parsed.results) == 1
|
||||
assert parsed.stats[0].engine == "google"
|
||||
Loading…
Add table
Add a link
Reference in a new issue