fix: update document cleanup logic and mock Celery task in tests

This commit is contained in:
Anish Sarkar 2026-03-11 12:27:32 +05:30
parent f73c1d83a8
commit 851856a54b

View file

@ -183,7 +183,7 @@ async def _cleanup_documents(
for doc_id in cleanup_doc_ids:
try:
resp = await delete_document(client, headers, doc_id)
if resp.status_code == 409:
if resp.status_code != 200:
remaining_ids.append(doc_id)
except Exception:
remaining_ids.append(doc_id)
@ -274,6 +274,15 @@ def _mock_external_apis(monkeypatch):
)
@pytest.fixture(autouse=True)
def _mock_celery_delete_task(monkeypatch):
"""Mock Celery delete dispatch — no broker is available in CI."""
monkeypatch.setattr(
"app.tasks.celery_tasks.document_tasks.delete_document_task.delay",
lambda *args, **kwargs: None,
)
@pytest.fixture(autouse=True)
def _mock_redis_heartbeat(monkeypatch):
"""Mock Redis heartbeat — Redis is an external infrastructure boundary."""