@@ -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