This commit is contained in:
Ishaan Jaffer 2025-10-16 18:00:46 -07:00
parent 1c21b2e285
commit 13e895b9b0
2 changed files with 43 additions and 7 deletions

View file

@ -1056,14 +1056,14 @@ class BaseLLMChatTest(ABC):
@pytest.fixture
def pdf_messages(self):
import base64
import os
import requests
# URL of the file
url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
response = requests.get(url)
file_data = response.content
# Use local PDF file instead of external URL to avoid flaky tests
test_dir = os.path.dirname(__file__)
pdf_path = os.path.join(test_dir, "fixtures", "dummy.pdf")
with open(pdf_path, "rb") as f:
file_data = f.read()
encoded_file = base64.b64encode(file_data).decode("utf-8")
url = f"data:application/pdf;base64,{encoded_file}"

View file

@ -0,0 +1,36 @@
%PDF-1.4
1 0 obj
<< /Type /Catalog /Pages 2 0 R >>
endobj
2 0 obj
<< /Type /Pages /Kids [3 0 R] /Count 1 >>
endobj
3 0 obj
<< /Type /Page /Parent 2 0 R /Resources 4 0 R /MediaBox [0 0 612 792] /Contents 5 0 R >>
endobj
4 0 obj
<< /Font << /F1 << /Type /Font /Subtype /Type1 /BaseFont /Helvetica >> >> >>
endobj
5 0 obj
<< /Length 44 >>
stream
BT
/F1 12 Tf
100 700 Td
(Test PDF File) Tj
ET
endstream
endobj
xref
0 6
0000000000 65535 f
0000000009 00000 n
0000000058 00000 n
0000000115 00000 n
0000000214 00000 n
0000000293 00000 n
trailer
<< /Size 6 /Root 1 0 R >>
startxref
385
%%EOF