@@ -28,6 +28,12 @@ def _make_fake_collection(self, doc_id: str, sample_tree: dict):
2828 col .get_page_content .return_value = []
2929 return col
3030
31+ def _fake_pages (self ):
32+ return [
33+ {"page" : 1 , "content" : "Page one text." , "images" : []},
34+ {"page" : 2 , "content" : "Page two text." , "images" : []},
35+ ]
36+
3137 def test_returns_index_result (self , kb_dir , sample_tree , tmp_path ):
3238 doc_id = "abc-123"
3339 fake_col = self ._make_fake_collection (doc_id , sample_tree )
@@ -38,7 +44,8 @@ def test_returns_index_result(self, kb_dir, sample_tree, tmp_path):
3844 pdf_path = tmp_path / "sample.pdf"
3945 pdf_path .write_bytes (b"%PDF-1.4 fake" )
4046
41- with patch ("openkb.indexer.PageIndexClient" , return_value = fake_client ):
47+ with patch ("openkb.indexer.PageIndexClient" , return_value = fake_client ), \
48+ patch ("openkb.images.convert_pdf_to_pages" , return_value = self ._fake_pages ()):
4249 result = index_long_document (pdf_path , kb_dir )
4350
4451 assert isinstance (result , IndexResult )
@@ -63,7 +70,8 @@ def test_source_page_written_as_json(self, kb_dir, sample_tree, tmp_path):
6370 pdf_path = tmp_path / "sample.pdf"
6471 pdf_path .write_bytes (b"%PDF-1.4 fake" )
6572
66- with patch ("openkb.indexer.PageIndexClient" , return_value = fake_client ):
73+ with patch ("openkb.indexer.PageIndexClient" , return_value = fake_client ), \
74+ patch ("openkb.images.convert_pdf_to_pages" , return_value = self ._fake_pages ()):
6775 index_long_document (pdf_path , kb_dir )
6876
6977 json_file = kb_dir / "wiki" / "sources" / "sample.json"
@@ -84,7 +92,8 @@ def test_summary_page_written(self, kb_dir, sample_tree, tmp_path):
8492 pdf_path = tmp_path / "sample.pdf"
8593 pdf_path .write_bytes (b"%PDF-1.4 fake" )
8694
87- with patch ("openkb.indexer.PageIndexClient" , return_value = fake_client ):
95+ with patch ("openkb.indexer.PageIndexClient" , return_value = fake_client ), \
96+ patch ("openkb.images.convert_pdf_to_pages" , return_value = self ._fake_pages ()):
8897 index_long_document (pdf_path , kb_dir )
8998
9099 summary_file = kb_dir / "wiki" / "summaries" / "sample.md"
@@ -104,7 +113,8 @@ def test_localclient_called_with_index_config(self, kb_dir, sample_tree, tmp_pat
104113 pdf_path = tmp_path / "report.pdf"
105114 pdf_path .write_bytes (b"%PDF-1.4 fake" )
106115
107- with patch ("openkb.indexer.PageIndexClient" , return_value = fake_client ) as mock_cls :
116+ with patch ("openkb.indexer.PageIndexClient" , return_value = fake_client ) as mock_cls , \
117+ patch ("openkb.images.convert_pdf_to_pages" , return_value = self ._fake_pages ()):
108118 index_long_document (pdf_path , kb_dir )
109119
110120 # Verify PageIndexClient was instantiated with correct IndexConfig
0 commit comments