Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions backend/app/tests/api/routes/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
def test_llm_call_success(
client: TestClient, user_api_key_header: dict[str, str]
) -> None:
"""Test successful LLM call with mocked start_high_priority_job."""
with patch("app.services.llm.jobs.start_high_priority_job") as mock_start_job:
"""Test successful LLM call with mocked start_llm_job."""
with patch("app.services.llm.jobs.start_llm_job") as mock_start_job:
mock_start_job.return_value = "test-task-id"

payload = LLMCallRequest(
Expand Down Expand Up @@ -55,7 +55,7 @@ def test_llm_call_with_kaapi_config(
client: TestClient, user_api_key_header: dict[str, str]
) -> None:
"""Test LLM call with Kaapi abstracted config."""
with patch("app.services.llm.jobs.start_high_priority_job") as mock_start_job:
with patch("app.services.llm.jobs.start_llm_job") as mock_start_job:
mock_start_job.return_value = "test-task-id"

payload = LLMCallRequest(
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_llm_call_with_native_config(
client: TestClient, user_api_key_header: dict[str, str]
) -> None:
"""Test LLM call with native OpenAI config (pass-through mode)."""
with patch("app.services.llm.jobs.start_high_priority_job") as mock_start_job:
with patch("app.services.llm.jobs.start_llm_job") as mock_start_job:
mock_start_job.return_value = "test-task-id"

payload = LLMCallRequest(
Expand Down Expand Up @@ -173,7 +173,7 @@ def test_llm_call_success_with_guardrails(
) -> None:
"""Test successful LLM call when guardrails are enabled (no validators)."""

with patch("app.services.llm.jobs.start_high_priority_job") as mock_start_job:
with patch("app.services.llm.jobs.start_llm_job") as mock_start_job:
mock_start_job.return_value = "test-task-id"

payload = LLMCallRequest(
Expand Down Expand Up @@ -214,7 +214,7 @@ def test_llm_call_guardrails_bypassed_still_succeeds(
) -> None:
"""If guardrails service is unavailable (bypassed), request should still succeed."""

with patch("app.services.llm.jobs.start_high_priority_job") as mock_start_job:
with patch("app.services.llm.jobs.start_llm_job") as mock_start_job:
mock_start_job.return_value = "test-task-id"

payload = LLMCallRequest(
Expand Down
2 changes: 1 addition & 1 deletion backend/app/tests/api/routes/test_stt_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def test_dataset_with_samples(
)
return dataset

@patch("app.api.routes.stt_evaluations.evaluation.start_low_priority_job")
@patch("app.api.routes.stt_evaluations.evaluation.start_stt_batch_submission")
def test_start_stt_evaluation_success(
self,
mock_start_job: MagicMock,
Expand Down
9 changes: 3 additions & 6 deletions backend/app/tests/api/routes/test_tts_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def test_dataset_with_samples(
dataset_metadata={"sample_count": 3},
)

@patch("app.api.routes.tts_evaluations.evaluation.start_low_priority_job")
@patch("app.api.routes.tts_evaluations.evaluation.start_tts_batch_submission")
def test_start_evaluation_success(
self,
mock_start_job: MagicMock,
Expand Down Expand Up @@ -565,14 +565,11 @@ def test_start_evaluation_success(

mock_start_job.assert_called_once()
call_kwargs = mock_start_job.call_args
assert call_kwargs.kwargs["function_path"] == (
"app.services.tts_evaluations.batch_job.execute_batch_submission"
)
assert call_kwargs.kwargs["organization_id"] == user_api_key.organization_id
assert call_kwargs.kwargs["dataset_id"] == dataset.id
assert call_kwargs.kwargs["models"] == ["gemini-2.5-pro-preview-tts"]

@patch("app.api.routes.tts_evaluations.evaluation.start_low_priority_job")
@patch("app.api.routes.tts_evaluations.evaluation.start_tts_batch_submission")
def test_start_evaluation_multiple_models_total_items(
self,
mock_start_job: MagicMock,
Expand Down Expand Up @@ -606,7 +603,7 @@ def test_start_evaluation_multiple_models_total_items(
# 5 samples × 1 model
assert data["total_items"] == 5

@patch("app.api.routes.tts_evaluations.evaluation.start_low_priority_job")
@patch("app.api.routes.tts_evaluations.evaluation.start_tts_batch_submission")
def test_start_evaluation_celery_failure(
self,
mock_start_job: MagicMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_start_job_creates_collection_job_and_schedules_task(db: Session) -> Non
"""
start_job should:
- update an existing CollectionJob (status=PENDING, action=CREATE)
- call start_low_priority_job with the correct kwargs
- call start_create_collection_job with the correct kwargs
- return the job UUID (same one that was passed in)
"""
project = get_project(db)
Expand All @@ -74,7 +74,7 @@ def test_start_job_creates_collection_job_and_schedules_task(db: Session) -> Non
)

with patch(
"app.services.collections.create_collection.start_low_priority_job"
"app.services.collections.create_collection.start_create_collection_job"
) as mock_schedule:
mock_schedule.return_value = "fake-task-id"

Expand All @@ -101,10 +101,6 @@ def test_start_job_creates_collection_job_and_schedules_task(db: Session) -> Non

mock_schedule.assert_called_once()
kwargs = mock_schedule.call_args.kwargs
assert (
kwargs["function_path"]
== "app.services.collections.create_collection.execute_job"
)
assert kwargs["project_id"] == project.id
assert kwargs["organization_id"] == project.organization_id
assert kwargs["job_id"] == str(job_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_start_job_creates_collection_job_and_schedules_task(db: Session) -> Non
req = DeletionRequest(collection_id=created_collection.id)

with patch(
"app.services.collections.delete_collection.start_low_priority_job"
"app.services.collections.delete_collection.start_delete_collection_job"
) as mock_schedule:
mock_schedule.return_value = "fake-task-id"

Expand Down Expand Up @@ -58,10 +58,6 @@ def test_start_job_creates_collection_job_and_schedules_task(db: Session) -> Non

mock_schedule.assert_called_once()
kwargs = mock_schedule.call_args.kwargs
assert (
kwargs["function_path"]
== "app.services.collections.delete_collection.execute_job"
)
assert kwargs["project_id"] == project.id
assert kwargs["organization_id"] == project.organization_id
assert kwargs["job_id"] == str(job.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_execute_job_end_to_end_workflow(
job = job_crud.create(DocTransformJobCreate(source_document_id=document.id))

with patch(
"app.services.doctransform.job.start_low_priority_job",
"app.services.doctransform.job.start_doctransform_job",
return_value="fake-task-id",
), patch("app.services.doctransform.job.Session") as mock_session_class, patch(
"app.services.doctransform.registry.TRANSFORMERS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_start_job_success(
job = self._create_job(db, current_user.project.id, document.id)

with patch(
"app.services.doctransform.job.start_low_priority_job"
"app.services.doctransform.job.start_doctransform_job"
) as mock_schedule:
mock_schedule.return_value = "fake-task-id"

Expand All @@ -66,7 +66,6 @@ def test_start_job_success(

mock_schedule.assert_called_once()
kwargs = mock_schedule.call_args.kwargs
assert kwargs["function_path"] == "app.services.doctransform.job.execute_job"
assert kwargs["project_id"] == current_user.project.id
assert kwargs["job_id"] == str(job.id)
assert kwargs["source_document_id"] == str(job.source_document_id)
Expand All @@ -87,7 +86,7 @@ def test_start_job_with_nonexistent_document(

with pytest.raises(HTTPException):
with patch(
"app.services.doctransform.job.start_low_priority_job"
"app.services.doctransform.job.start_doctransform_job"
) as mock_schedule:
mock_schedule.return_value = "fake-task-id"
start_job(
Expand All @@ -113,7 +112,7 @@ def test_start_job_with_different_formats(
formats = ["markdown", "text", "html"]

with patch(
"app.services.doctransform.job.start_low_priority_job"
"app.services.doctransform.job.start_doctransform_job"
) as mock_schedule:
mock_schedule.return_value = "fake-task-id"

Expand All @@ -137,10 +136,6 @@ def test_start_job_with_different_formats(
# scheduler called with correct kwargs
kwargs = mock_schedule.call_args.kwargs
assert kwargs["target_format"] == target_format
assert (
kwargs["function_path"]
== "app.services.doctransform.job.execute_job"
)
assert kwargs["project_id"] == current_user.project.id
assert kwargs["job_id"] == str(job.id)
assert kwargs["source_document_id"] == str(job.source_document_id)
Expand All @@ -163,7 +158,7 @@ def test_start_job_with_different_transformers(
job = self._create_job(db, current_user.project.id, document.id)

with patch(
"app.services.doctransform.job.start_low_priority_job"
"app.services.doctransform.job.start_doctransform_job"
) as mock_schedule:
mock_schedule.return_value = "fake-task-id"

Expand All @@ -183,7 +178,6 @@ def test_start_job_with_different_transformers(
kwargs = mock_schedule.call_args.kwargs
assert kwargs["transformer_name"] == transformer_name
assert kwargs["target_format"] == "markdown"
assert kwargs["function_path"] == "app.services.doctransform.job.execute_job"
assert kwargs["project_id"] == current_user.project.id
assert kwargs["job_id"] == str(job.id)
assert kwargs["source_document_id"] == str(job.source_document_id)
Expand Down
11 changes: 4 additions & 7 deletions backend/app/tests/services/llm/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_start_job_success(self, db: Session, llm_call_request: LLMCallRequest):
request = llm_call_request
project = get_project(db)

with patch("app.services.llm.jobs.start_high_priority_job") as mock_schedule:
with patch("app.services.llm.jobs.start_llm_job") as mock_schedule:
mock_schedule.return_value = "fake-task-id-123"

job_id = start_job(db, request, project.id, project.organization_id)
Expand All @@ -78,7 +78,6 @@ def test_start_job_success(self, db: Session, llm_call_request: LLMCallRequest):

mock_schedule.assert_called_once()
_, kwargs = mock_schedule.call_args
assert kwargs["function_path"] == "app.services.llm.jobs.execute_job"
assert kwargs["project_id"] == project.id
assert kwargs["organization_id"] == project.organization_id
assert kwargs["job_id"] == str(job_id)
Expand All @@ -90,7 +89,7 @@ def test_start_job_celery_scheduling_fails(
"""Test start_job when Celery task scheduling fails."""
project = get_project(db)

with patch("app.services.llm.jobs.start_high_priority_job") as mock_schedule:
with patch("app.services.llm.jobs.start_llm_job") as mock_schedule:
mock_schedule.side_effect = Exception("Celery connection failed")

with pytest.raises(HTTPException) as exc_info:
Expand Down Expand Up @@ -1190,7 +1189,7 @@ def test_start_chain_job_success(self, db: Session, chain_request):
project = get_project(db)

with (
patch("app.services.llm.jobs.start_high_priority_job") as mock_schedule,
patch("app.services.llm.jobs.start_llm_chain_job") as mock_schedule,
patch("app.services.llm.jobs.JobCrud") as mock_job_crud_class,
):
mock_schedule.return_value = "fake-task-id"
Expand All @@ -1206,14 +1205,12 @@ def test_start_chain_job_success(self, db: Session, chain_request):

assert job_id == mock_job.id
mock_schedule.assert_called_once()
_, kwargs = mock_schedule.call_args
assert kwargs["function_path"] == "app.services.llm.jobs.execute_chain_job"

def test_start_chain_job_celery_failure(self, db: Session, chain_request):
project = get_project(db)

with (
patch("app.services.llm.jobs.start_high_priority_job") as mock_schedule,
patch("app.services.llm.jobs.start_llm_chain_job") as mock_schedule,
patch("app.services.llm.jobs.JobCrud") as mock_job_crud_class,
):
mock_schedule.side_effect = Exception("Celery connection failed")
Expand Down
5 changes: 2 additions & 3 deletions backend/app/tests/services/response/test_jobs_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_start_job(db: Session):

project = get_project(db)
# Patch Celery scheduling
with patch("app.services.response.jobs.start_high_priority_job") as mock_schedule:
with patch("app.services.response.jobs.start_response_job") as mock_schedule:
mock_schedule.return_value = "fake-task-id"

job_id = start_job(db, request, project.id, project.organization_id)
Expand All @@ -33,7 +33,6 @@ def test_start_job(db: Session):
# Validate Celery was called correctly
mock_schedule.assert_called_once()
_, kwargs = mock_schedule.call_args
assert kwargs["function_path"] == "app.services.response.jobs.execute_job"
assert kwargs["project_id"] == project.id
assert kwargs["organization_id"] == project.organization_id
assert kwargs["job_id"] == str(job_id)
Expand All @@ -48,7 +47,7 @@ def test_start_job_celery_exception(db: Session):
)
project = get_project(db)

with patch("app.services.response.jobs.start_high_priority_job") as mock_schedule:
with patch("app.services.response.jobs.start_response_job") as mock_schedule:
mock_schedule.side_effect = Exception("Celery connection failed")

with pytest.raises(HTTPException) as exc_info:
Expand Down
Loading