Skip to content

Commit e906fb5

Browse files
committed
Fix tests
1 parent d8dd729 commit e906fb5

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

tests/test_app_config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ async def test_app_config_user_upload_bad_openai_config(monkeypatch, minimal_env
264264
monkeypatch.setenv("USE_USER_UPLOAD", "true")
265265
monkeypatch.setenv("OPENAI_HOST", "openai")
266266
quart_app = app.create_app()
267-
with pytest.raises(
268-
quart.testing.app.LifespanError, match="OpenAI key is required when using the non-Azure OpenAI API"
269-
):
267+
with pytest.raises(quart.testing.app.LifespanError, match="OPENAI_API_KEY is required for public OpenAI host"):
270268
async with quart_app.test_app() as test_app:
271269
test_app.test_client()
272270

tests/test_pdfparser.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ def test_table_to_html_with_spans():
112112
@pytest.mark.asyncio
113113
async def test_process_figure_without_bounding_regions():
114114
figure = DocumentFigure(id="1", caption=None, bounding_regions=None)
115-
result = await DocumentAnalysisParser.process_figure(None, figure)
115+
result = await DocumentAnalysisParser.figure_to_image(None, figure)
116116

117117
assert isinstance(result, ImageOnPage)
118-
assert result.description == ""
118+
assert result.description is None
119119
assert result.title == ""
120120
assert result.figure_id == "1"
121121
assert result.page_num == 0
@@ -143,10 +143,10 @@ def mock_crop_image_from_pdf_page(doc, page_number, bounding_box):
143143
monkeypatch.setattr(DocumentAnalysisParser, "crop_image_from_pdf_page", mock_crop_image_from_pdf_page)
144144

145145
with caplog.at_level(logging.WARNING):
146-
result = await DocumentAnalysisParser.process_figure(doc, figure)
146+
result = await DocumentAnalysisParser.figure_to_image(doc, figure)
147147

148148
assert isinstance(result, ImageOnPage)
149-
assert result.description == ""
149+
assert result.description is None
150150
assert result.title == "Logo"
151151
assert result.bytes == b"image_bytes"
152152
assert result.page_num == 0
@@ -294,8 +294,7 @@ async def mock_poller_result():
294294
monkeypatch.setattr(mock_poller, "result", mock_poller_result)
295295

296296
parser = DocumentAnalysisParser(
297-
endpoint="https://example.com",
298-
credential=MockAzureCredential(),
297+
endpoint="https://example.com", credential=MockAzureCredential(), process_figures=True
299298
)
300299

301300
with open(TEST_DATA_DIR / "Simple Figure.pdf", "rb") as f:
@@ -357,14 +356,13 @@ async def mock_poller_result():
357356
monkeypatch.setattr(mock_poller, "result", mock_poller_result)
358357

359358
parser = DocumentAnalysisParser(
360-
endpoint="https://example.com",
361-
credential=MockAzureCredential(),
359+
endpoint="https://example.com", credential=MockAzureCredential(), process_figures=True
362360
)
363361
content = io.BytesIO(b"pdf content bytes")
364362
content.name = "test.docx"
365363
with caplog.at_level(logging.ERROR):
366364
pages = [page async for page in parser.parse(content)]
367-
assert "does not support high-resolution figure extraction" in caplog.text
365+
assert "does not support media description." in caplog.text
368366

369367
assert len(pages) == 1
370368
assert pages[0].page_num == 0

0 commit comments

Comments
 (0)