Skip to content

Commit

Permalink
Add test with no query params of new pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed Jan 9, 2025
1 parent 54f7907 commit ee054f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import base64
import operator
from typing import Any
from typing import Any, Optional

import pydantic
from fastapi import HTTPException
Expand Down Expand Up @@ -159,7 +159,7 @@ def paginate(

class CursorPaginatedArgs(pydantic.BaseModel):
limit: int
order: str
order: Optional[str] = None
sort_by: list[str]

@pydantic.field_validator("sort_by")
Expand Down
19 changes: 19 additions & 0 deletions conda-store-server/tests/_internal/server/views/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,3 +1158,22 @@ def test_api_list_environments_by_namespace_name(
)
assert [env.name for env in sorted_envs] == env_names
assert [env.namespace.name for env in sorted_envs] == namespace_names


def test_api_list_environments_no_qparam(
conda_store_server,
testclient,
seed_conda_store_big,
authenticate,
):
"""Test the REST API lists the paginated envs when sorting by namespace."""
response = testclient.get("api/v1/environment/")
response.raise_for_status()

model = schema.APIListEnvironment.model_validate(response.json())
assert model.status == schema.APIStatus.OK

env_ids = [env.id for env in model.data]

# Check that the environments are sorted by ID
assert sorted(env_ids) == env_ids

0 comments on commit ee054f0

Please sign in to comment.