Spaces:
Sleeping
Sleeping
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| from claim_validation.schemas import ( | |
| SourceAbstract, | |
| ValidateClaimsRequest, | |
| ) | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def test_source_abstract_accepts_pubmed_eng() -> None: | |
| source = SourceAbstract( | |
| pmid="29389474", | |
| abstract="A real PubMed abstract.", | |
| language="eng", | |
| ) | |
| assert source.language == "en" | |
| def test_validate_claims_request_normalizes_eng() -> None: | |
| payload = json.loads( | |
| ( | |
| ROOT | |
| / "contracts" | |
| / "validate-claims.request.example.json" | |
| ).read_text(encoding="utf-8") | |
| ) | |
| payload["source_abstracts"][0]["language"] = "eng" | |
| parsed = ValidateClaimsRequest.model_validate( | |
| payload | |
| ) | |
| assert ( | |
| parsed.source_abstracts[0].language | |
| == "en" | |
| ) | |