Skip to content

Commit c0d1750

Browse files
Extract Text test: Fix expected fields
Assisted-by: Codex
1 parent 1bed8c0 commit c0d1750

1 file changed

Lines changed: 29 additions & 8 deletions

File tree

tests/test_extract_text.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,16 @@ def test_extract_text_json_success(monkeypatch: pytest.MonkeyPatch) -> None:
4242
monkeypatch.delenv("PDFREST_API_KEY", raising=False)
4343
input_file = make_pdf_file(PdfRestFileID.generate(1))
4444
payload_dump = ExtractTextPayload.model_validate(
45-
{"files": [input_file], "pages": ["1-3"], "output": "text"}
45+
{
46+
"files": [input_file],
47+
"pages": ["1-3"],
48+
"output": "text",
49+
"full_text": "document",
50+
"preserve_line_breaks": "off",
51+
"word_style": "off",
52+
"word_coordinates": "off",
53+
"output_type": "json",
54+
}
4655
).model_dump(mode="json", by_alias=True, exclude_none=True, exclude_unset=True)
4756

4857
seen: dict[str, int] = {"post": 0}
@@ -55,7 +64,7 @@ def handler(request: httpx.Request) -> httpx.Response:
5564
return httpx.Response(
5665
200,
5766
json={
58-
"text": "Example extracted text",
67+
"fullText": "Example extracted text",
5968
"inputId": str(input_file.id),
6069
},
6170
)
@@ -84,7 +93,15 @@ def test_extract_text_request_customization(
8493
monkeypatch.delenv("PDFREST_API_KEY", raising=False)
8594
input_file = make_pdf_file(PdfRestFileID.generate(1))
8695
payload_dump = ExtractTextPayload.model_validate(
87-
{"files": [input_file], "output": "file-output"}
96+
{
97+
"files": [input_file],
98+
"output": "file-output",
99+
"full_text": "document",
100+
"preserve_line_breaks": "off",
101+
"word_style": "off",
102+
"word_coordinates": "off",
103+
"output_type": "json",
104+
}
88105
).model_dump(mode="json", by_alias=True, exclude_none=True, exclude_unset=True)
89106
output_id = str(PdfRestFileID.generate())
90107
captured_timeout: dict[str, float | dict[str, float] | None] = {}
@@ -138,7 +155,14 @@ async def test_async_extract_text_success(
138155
monkeypatch.delenv("PDFREST_API_KEY", raising=False)
139156
input_file = make_pdf_file(PdfRestFileID.generate(2))
140157
payload_dump = ExtractTextPayload.model_validate(
141-
{"files": [input_file]}
158+
{
159+
"files": [input_file],
160+
"full_text": "document",
161+
"preserve_line_breaks": "off",
162+
"word_style": "off",
163+
"word_coordinates": "off",
164+
"output_type": "json",
165+
}
142166
).model_dump(mode="json", by_alias=True, exclude_none=True, exclude_unset=True)
143167

144168
seen: dict[str, int] = {"post": 0}
@@ -150,10 +174,7 @@ def handler(request: httpx.Request) -> httpx.Response:
150174
assert payload == payload_dump
151175
return httpx.Response(
152176
200,
153-
json={
154-
"text": "Async text",
155-
"inputId": str(input_file.id),
156-
},
177+
json={"fullText": "Async text", "inputId": str(input_file.id)},
157178
)
158179
msg = f"Unexpected request {request.method} {request.url}"
159180
raise AssertionError(msg)

0 commit comments

Comments
 (0)