test(v2-ingestion): harden public-source schema contract and docs

This commit is contained in:
Alfredo Di Stasio
2026-03-20 15:50:59 +01:00
parent 48a82e812a
commit 3f811827de
6 changed files with 131 additions and 29 deletions

View File

@ -16,6 +16,16 @@ def _first_non_empty(record: dict[str, Any], *keys: str) -> Any:
return None
def _first_non_empty_text(record: dict[str, Any], *keys: str) -> str | None:
for key in keys:
value = record.get(key)
if isinstance(value, str):
stripped = value.strip()
if stripped:
return stripped
return None
ESSENTIAL_FIELDS = {
"competition_external_id",
"competition_name",
@ -108,7 +118,9 @@ class BCLSnapshotExtractor(BaseSnapshotExtractor):
team_external_id = _first_non_empty(source_record, "team_external_id", "team_id") or _first_non_empty(
team_obj, "id", "team_id"
)
team_name = _first_non_empty(source_record, "team_name", "team") or _first_non_empty(team_obj, "name")
team_name = _first_non_empty_text(source_record, "team_name", "team") or _first_non_empty_text(
team_obj, "name"
)
normalized = {
"competition_external_id": self.competition_external_id,