mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
refactor: use EnumText for dataset and replace string literals 4 (#33606)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -32,6 +32,7 @@ from controllers.service_api.dataset.segment import (
|
||||
SegmentListQuery,
|
||||
)
|
||||
from models.dataset import ChildChunk, Dataset, Document, DocumentSegment
|
||||
from models.enums import IndexingStatus
|
||||
from services.dataset_service import DocumentService, SegmentService
|
||||
|
||||
|
||||
@ -657,12 +658,27 @@ class TestSegmentIndexingRequirements:
|
||||
dataset.indexing_technique = technique
|
||||
assert dataset.indexing_technique in ["high_quality", "economy"]
|
||||
|
||||
@pytest.mark.parametrize("status", ["waiting", "parsing", "indexing", "completed", "error"])
|
||||
@pytest.mark.parametrize(
|
||||
"status",
|
||||
[
|
||||
IndexingStatus.WAITING,
|
||||
IndexingStatus.PARSING,
|
||||
IndexingStatus.INDEXING,
|
||||
IndexingStatus.COMPLETED,
|
||||
IndexingStatus.ERROR,
|
||||
],
|
||||
)
|
||||
def test_valid_indexing_statuses(self, status):
|
||||
"""Test valid document indexing statuses."""
|
||||
document = Mock(spec=Document)
|
||||
document.indexing_status = status
|
||||
assert document.indexing_status in ["waiting", "parsing", "indexing", "completed", "error"]
|
||||
assert document.indexing_status in {
|
||||
IndexingStatus.WAITING,
|
||||
IndexingStatus.PARSING,
|
||||
IndexingStatus.INDEXING,
|
||||
IndexingStatus.COMPLETED,
|
||||
IndexingStatus.ERROR,
|
||||
}
|
||||
|
||||
def test_completed_status_required_for_segments(self):
|
||||
"""Test that completed status is required for segment operations."""
|
||||
|
||||
@ -35,6 +35,7 @@ from controllers.service_api.dataset.document import (
|
||||
InvalidMetadataError,
|
||||
)
|
||||
from controllers.service_api.dataset.error import ArchivedDocumentImmutableError
|
||||
from models.enums import IndexingStatus
|
||||
from services.dataset_service import DocumentService
|
||||
from services.entities.knowledge_entities.knowledge_entities import ProcessRule, RetrievalModel
|
||||
|
||||
@ -244,23 +245,26 @@ class TestDocumentService:
|
||||
class TestDocumentIndexingStatus:
|
||||
"""Test document indexing status values."""
|
||||
|
||||
_VALID_STATUSES = {
|
||||
IndexingStatus.WAITING,
|
||||
IndexingStatus.PARSING,
|
||||
IndexingStatus.INDEXING,
|
||||
IndexingStatus.COMPLETED,
|
||||
IndexingStatus.ERROR,
|
||||
IndexingStatus.PAUSED,
|
||||
}
|
||||
|
||||
def test_completed_status(self):
|
||||
"""Test completed status."""
|
||||
status = "completed"
|
||||
valid_statuses = ["waiting", "parsing", "indexing", "completed", "error", "paused"]
|
||||
assert status in valid_statuses
|
||||
assert IndexingStatus.COMPLETED in self._VALID_STATUSES
|
||||
|
||||
def test_indexing_status(self):
|
||||
"""Test indexing status."""
|
||||
status = "indexing"
|
||||
valid_statuses = ["waiting", "parsing", "indexing", "completed", "error", "paused"]
|
||||
assert status in valid_statuses
|
||||
assert IndexingStatus.INDEXING in self._VALID_STATUSES
|
||||
|
||||
def test_error_status(self):
|
||||
"""Test error status."""
|
||||
status = "error"
|
||||
valid_statuses = ["waiting", "parsing", "indexing", "completed", "error", "paused"]
|
||||
assert status in valid_statuses
|
||||
assert IndexingStatus.ERROR in self._VALID_STATUSES
|
||||
|
||||
|
||||
class TestDocumentDocForm:
|
||||
|
||||
Reference in New Issue
Block a user