Skip to content

Commit d6cca44

Browse files
committed
fix: update test to match new AdvancedPDFParser-based ingestion pipeline (#561)
1 parent 90a83c2 commit d6cca44

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

backend/app/tasks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def process_document(
4141
doc.status = "processing" # Set explicitly to show UI activity
4242
db.commit()
4343

44-
<<<<<<< HEAD
4544
logger.info("Starting Advanced Layout-Aware Ingestion for document: %s", original_name)
4645

4746
# 2. Trigger your advanced structural parser

backend/tests/test_celery_ingestion.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,14 @@ def test_process_document_ingestion_pipeline(db_session):
2727
mock_session_factory.return_value.__enter__.return_value = db_session
2828
mock_session_factory.return_value = db_session
2929

30-
# Patch the factory globally, and patch ingest_document right where app.tasks calls it
30+
# Patch the factory globally, and patch AdvancedPDFParser to avoid real file I/O
3131
with patch("app.database.SessionLocal", mock_session_factory, create=True), \
32-
patch("app.services.document_ingestion.SessionLocal", mock_session_factory, create=True), \
33-
patch("app.tasks.ingest_document") as mock_ingest:
34-
35-
# Simulate what the underlying service does upon a successful processing run
36-
def simulate_successful_ingestion(*args, **kwargs):
37-
doc = db_session.query(Document).filter_by(id="test-doc-123").first()
38-
if doc:
39-
doc.status = "ready"
40-
db_session.commit()
41-
return {"status": "success"}
42-
43-
mock_ingest.side_effect = simulate_successful_ingestion
32+
patch("app.tasks.AdvancedPDFParser") as mock_parser:
33+
34+
# Return empty chunks so the vectorization loop is a no-op
35+
mock_parser_instance = MagicMock()
36+
mock_parser.return_value = mock_parser_instance
37+
mock_parser_instance.ingest_document.return_value = []
4438

4539
task_result = process_document.apply(
4640
kwargs={
@@ -57,4 +51,4 @@ def simulate_successful_ingestion(*args, **kwargs):
5751
# Query the database to verify the state update
5852
updated_doc = db_session.query(Document).filter_by(id="test-doc-123").first()
5953
assert updated_doc is not None
60-
assert updated_doc.status == "ready"
54+
assert updated_doc.status == "completed"

0 commit comments

Comments
 (0)