Skip to content

Commit f732df1

Browse files
committed
test(indexer): isolate TestIndexLongDocument from a configured PAGEINDEX_API_KEY
These tests drive the LOCAL indexing path with a fake PDF. When a developer has PAGEINDEX_API_KEY set, index_long_document takes the cloud branch and _get_pdf_page_count tries to open the fake PDF and raises (FileDataError). Add a class-scoped autouse fixture that unsets the key by default; the cloud-path tests in the class re-enable it via monkeypatch.setenv.
1 parent 0b93eae commit f732df1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/test_indexer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from unittest.mock import MagicMock, patch
55

6+
import pytest
67

78
from openkb.indexer import IndexResult, _normalize_page_content, index_long_document
89

@@ -37,6 +38,14 @@ def test_rejects_unusable_shapes(self):
3738

3839

3940
class TestIndexLongDocument:
41+
@pytest.fixture(autouse=True)
42+
def _local_path_by_default(self, monkeypatch):
43+
# These tests exercise the LOCAL indexing path; unset PAGEINDEX_API_KEY
44+
# so they are deterministic regardless of a developer's configured key
45+
# (otherwise the cloud branch reads the page count from the fake PDF and
46+
# raises). Cloud-path tests in this class re-enable it via setenv.
47+
monkeypatch.delenv("PAGEINDEX_API_KEY", raising=False)
48+
4049
def _make_fake_collection(self, doc_id: str, sample_tree: dict):
4150
"""Build a mock Collection that returns the sample_tree fixture data."""
4251
col = MagicMock()

0 commit comments

Comments
 (0)