Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
mcantelon committed May 1, 2024
1 parent 173d21d commit 781b504
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions AIPscan/Aggregator/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,34 +462,6 @@ def test_store_fetch_job_error_during_workflow_coordinator(
index_task_obj = index_tasks.query.filter_by(fetch_job_id=fetch_job.id).first()
assert index_task_obj is None


def test_index_task(app_instance, enable_typesense, mocker):
"""Test index task."""
# Create test fetch job
storage_service = test_helpers.create_test_storage_service()

fetch_job = test_helpers.create_test_fetch_job(
storage_service_id=storage_service.id
)

# Mock call to index initialize function
mocker.patch("AIPscan.typesense_helpers.initialize_index")

# Create test index tasks object and test index task with fake Celery task ID
task_id = celery.uuid()
test_helpers.create_test_index_tasks(fetch_job.id, task_id)

# Mock call to finish bulk document creation function
mock_finish_bulk_doc = mocker.patch(
"AIPscan.typesense_helpers.finish_bulk_document_creation"
)

# Start index task
index_task.apply((fetch_job.id,), task_id=task_id)

# Make sure finish bulk document creation function got called
mock_finish_bulk_doc.assert_called()

# Make sure no fetch job errors exist for test fetch job
fetch_job_error = FetchJobError.query.filter_by(fetch_job_id=fetch_job.id).first()

Expand Down Expand Up @@ -530,3 +502,31 @@ class MockPackageListsRequestAsyncResult:
assert fetch_job_error is not None
assert fetch_job_error.message == "workflow_coordinator: Task error"
assert fetch_job_error.fetch_job_id == fetch_job.id


def test_index_task(app_instance, enable_typesense, mocker):
"""Test index task."""
# Create test fetch job
storage_service = test_helpers.create_test_storage_service()

fetch_job = test_helpers.create_test_fetch_job(
storage_service_id=storage_service.id
)

# Mock call to index initialize function
mocker.patch("AIPscan.typesense_helpers.initialize_index")

# Create test index tasks object and test index task with fake Celery task ID
task_id = celery.uuid()
test_helpers.create_test_index_tasks(fetch_job.id, task_id)

# Mock call to finish bulk document creation function
mock_finish_bulk_doc = mocker.patch(
"AIPscan.typesense_helpers.finish_bulk_document_creation"
)

# Start index task
index_task.apply((fetch_job.id,), task_id=task_id)

# Make sure finish bulk document creation function got called
mock_finish_bulk_doc.assert_called()

0 comments on commit 781b504

Please sign in to comment.