Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Jul 23, 2024
1 parent 3ce69fb commit 7fb7103
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion stac_fastapi/types/tests/test_limit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
from pydantic import ValidationError

from stac_fastapi.types.search import BaseSearchPostRequest
from stac_fastapi.types.search import BaseSearchGetRequest, BaseSearchPostRequest


@pytest.mark.parametrize("value", [0, -1])
Expand All @@ -20,3 +22,34 @@ def test_limit(value):
def test_limit_le(value):
search = BaseSearchPostRequest(limit=value)
assert search.limit == 10_000


def test_limit_get_request():
"""test GET model."""

app = FastAPI()

@app.get("/test")
def route(model=Depends(BaseSearchGetRequest)):
return model

with TestClient(app) as client:
resp = client.get(
"/test",
params={
"limit": 10,
},
)
assert resp.status_code == 200
response_dict = resp.json()
assert response_dict["limit"] == 10

resp = client.get(
"/test",
params={
"limit": 100_000,
},
)
assert resp.status_code == 200
response_dict = resp.json()
assert response_dict["limit"] == 10_000

0 comments on commit 7fb7103

Please sign in to comment.