from pathlib import Path import sys import pytest SCRIPTS = Path(__file__).resolve().parents[1] / "scripts" sys.path.insert(0, str(SCRIPTS)) from fetch_utils import validate_data_response # noqa: E402 class ResponseStub: def __init__(self, content_type: str, content: bytes) -> None: self.headers = {"content-type": content_type} self.content = content def test_rejects_html_shell_returned_by_data_endpoint(): response = ResponseStub("text/html; charset=utf-8", b"") with pytest.raises(ValueError, match="HTML"): validate_data_response(response)