mirror of
https://github.com/langgenius/dify.git
synced 2026-06-26 14:51:13 +08:00
Merge 4e99a98c23 into bb921bcc45
This commit is contained in:
commit
6e8e6091c3
@ -146,8 +146,8 @@ class IndexingEstimatePayload(BaseModel):
|
||||
|
||||
|
||||
class ConsoleDatasetListQuery(BaseModel):
|
||||
page: int = Field(default=1, description="Page number")
|
||||
limit: int = Field(default=20, description="Number of items per page")
|
||||
page: int = Field(default=1, ge=1, description="Page number")
|
||||
limit: int = Field(default=20, ge=1, description="Number of items per page")
|
||||
keyword: str | None = Field(default=None, description="Search keyword")
|
||||
include_all: bool = Field(default=False, description="Include all datasets")
|
||||
ids: list[str] = Field(default_factory=list, description="Filter by dataset IDs")
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from controllers.console.datasets.datasets import ConsoleDatasetListQuery
|
||||
|
||||
|
||||
def test_dataset_list_query_defaults() -> None:
|
||||
query = ConsoleDatasetListQuery()
|
||||
assert query.page == 1
|
||||
assert query.limit == 20
|
||||
|
||||
|
||||
def test_dataset_list_query_accepts_valid_pagination() -> None:
|
||||
query = ConsoleDatasetListQuery(page=3, limit=50)
|
||||
assert query.page == 3
|
||||
assert query.limit == 50
|
||||
|
||||
|
||||
def test_dataset_list_query_rejects_non_positive_page() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
ConsoleDatasetListQuery(page=0)
|
||||
with pytest.raises(ValidationError):
|
||||
ConsoleDatasetListQuery(page=-1)
|
||||
|
||||
|
||||
def test_dataset_list_query_rejects_non_positive_limit() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
ConsoleDatasetListQuery(limit=0)
|
||||
with pytest.raises(ValidationError):
|
||||
ConsoleDatasetListQuery(limit=-5)
|
||||
Loading…
Reference in New Issue
Block a user