Add comprehensive unit tests for DocumentIndexingTaskProxy #20636

Closed
opened 2026-02-21 20:08:16 -05:00 by yindo · 0 comments
Owner

Originally created by @SmartDever02 on GitHub (Nov 27, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.

Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Add comprehensive unit tests for DocumentIndexingTaskProxy service. This service handles critical document indexing task scheduling, queuing, and tenant isolation logic. Currently, there are basic tests, but we need comprehensive coverage for:

  • Task scheduling and queuing (direct vs tenant-isolated queues)
  • Priority vs normal task routing based on billing plans
  • Tenant isolation using TenantIsolatedTaskQueue
  • Batch indexing operations with multiple document IDs
  • Error handling and retry logic through queue management
  • All dispatch scenarios (billing enabled/disabled, different CloudPlan types)

The test suite should cover all methods:

  • __init__ - initialization with tenant_id, dataset_id, document_ids
  • features - cached property for FeatureService integration
  • _send_to_direct_queue - direct queue routing
  • _send_to_tenant_queue - tenant queue routing with task key management
  • _send_to_default_tenant_queue - default tenant queue routing
  • _send_to_priority_tenant_queue - priority tenant queue routing
  • _send_to_priority_direct_queue - priority direct queue routing
  • _dispatch - dispatch logic based on billing configuration
  • delay - public method for task scheduling

2. Additional context or comments

Branch name: feat/test-document-indexing-task-proxy

File name: document_indexing_task_proxy.py (without 'test' prefix)

Related files:

  • api/services/document_indexing_task_proxy.py (implementation)
  • api/tasks/document_indexing_task.py (task functions)
  • api/core/rag/pipeline/queue.py (TenantIsolatedTaskQueue)
  • api/services/feature_service.py (FeatureService)
  • api/core/entities/document_task.py (DocumentTask entity)
  • api/enums/cloud_plan.py (CloudPlan enum)

Test requirements:

  • Comprehensive test coverage for all methods and scenarios
  • Test data factory for mock object creation
  • Extensive comments and documentation
  • Proper mocking of dependencies (FeatureService, TenantIsolatedTaskQueue, Celery tasks)
  • Edge case coverage (empty document_ids, None plans, error conditions)
  • Follow existing test patterns and conventions

3. Can you help us with this feature?

Yes, I am interested in contributing to this feature.

Originally created by @SmartDever02 on GitHub (Nov 27, 2025). ## Self Checks - [x] I have read the Contributing Guide and Language Policy. - [x] I have searched for existing issues, including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. Please do not modify this template :) and fill in all the required fields. ## 1. Is this request related to a challenge you're experiencing? Tell me about your story. Add comprehensive unit tests for `DocumentIndexingTaskProxy` service. This service handles critical document indexing task scheduling, queuing, and tenant isolation logic. Currently, there are basic tests, but we need comprehensive coverage for: - Task scheduling and queuing (direct vs tenant-isolated queues) - Priority vs normal task routing based on billing plans - Tenant isolation using `TenantIsolatedTaskQueue` - Batch indexing operations with multiple document IDs - Error handling and retry logic through queue management - All dispatch scenarios (billing enabled/disabled, different CloudPlan types) The test suite should cover all methods: - `__init__` - initialization with tenant_id, dataset_id, document_ids - `features` - cached property for FeatureService integration - `_send_to_direct_queue` - direct queue routing - `_send_to_tenant_queue` - tenant queue routing with task key management - `_send_to_default_tenant_queue` - default tenant queue routing - `_send_to_priority_tenant_queue` - priority tenant queue routing - `_send_to_priority_direct_queue` - priority direct queue routing - `_dispatch` - dispatch logic based on billing configuration - `delay` - public method for task scheduling ## 2. Additional context or comments **Branch name**: `feat/test-document-indexing-task-proxy` **File name**: `document_indexing_task_proxy.py` (without 'test' prefix) **Related files**: - `api/services/document_indexing_task_proxy.py` (implementation) - `api/tasks/document_indexing_task.py` (task functions) - `api/core/rag/pipeline/queue.py` (TenantIsolatedTaskQueue) - `api/services/feature_service.py` (FeatureService) - `api/core/entities/document_task.py` (DocumentTask entity) - `api/enums/cloud_plan.py` (CloudPlan enum) **Test requirements**: - Comprehensive test coverage for all methods and scenarios - Test data factory for mock object creation - Extensive comments and documentation - Proper mocking of dependencies (FeatureService, TenantIsolatedTaskQueue, Celery tasks) - Edge case coverage (empty document_ids, None plans, error conditions) - Follow existing test patterns and conventions ## 3. Can you help us with this feature? Yes, I am interested in contributing to this feature.
yindo closed this issue 2026-02-21 20:08:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20636