test(e2e): add shared binary fixture loader for connector fakes

This commit is contained in:
Anish Sarkar 2026-05-09 05:02:23 +05:30
parent 523563b948
commit fc32ab0cf3

View file

@ -0,0 +1,23 @@
"""Helpers for serving text and binary fixture file bodies."""
from __future__ import annotations
from pathlib import Path
from typing import Any
def _resolve_file_bytes(
fixture: dict[str, Any], key: str | None, fixtures_dir: Path
) -> bytes | None:
"""Resolve a fake file body, preferring binary fixture files over text."""
if not key:
return None
binary_path = fixture.get("_file_binary_paths", {}).get(key)
if binary_path is not None:
return (fixtures_dir / binary_path).read_bytes()
content = fixture.get("_file_contents", {}).get(key)
if content is None:
return None
return content.encode("utf-8")