Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added endpoints to generate legends from colormap or registered classmaps [#17](https://github.com/microsoft/planetary-computer-apis/pull/17)
- Configuration for chloris-biomass, nrcan-landcover, noaa-c-cap
- Configuration for io-lulc-9-class [#34](https://github.com/microsoft/planetary-computer-apis/pull/34)
- Configuration for gnatsgo [#36](https://github.com/microsoft/planetary-computer-apis/pull/36)

### Fixed

- Updated search limit constraints to avoid 500s [#15](https://github.com/microsoft/planetary-computer-apis/pull/15)
- Fixed STAC `describedby` and `preview` links [#33](https://github.com/microsoft/planetary-computer-apis/pull/33)
- Default search limit restored to 250 [#36](https://github.com/microsoft/planetary-computer-apis/pull/36)
9 changes: 9 additions & 0 deletions pccommon/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ def should_add_item_links(self) -> bool:
requires_token=False,
minzoom=5,
),
"gnatsgo-rasters": DefaultRenderConfig(
create_links=False,
assets=["aws0_100"],
render_params={"colormap_name": "cividis"},
mosaic_preview_zoom=6,
mosaic_preview_coords=[44.1454, -112.6404],
requires_token=True,
minzoom=4,
),
"goes-mcmip": DefaultRenderConfig(
create_links=True, # Issues with colormap size, rendering
assets=["data"],
Expand Down
6 changes: 4 additions & 2 deletions pcstac/pcstac/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from pcstac.client import PCClient
from pcstac.config import API_DESCRIPTION, API_TITLE, API_VERSION, get_settings
from pcstac.errors import PC_DEFAULT_STATUS_CODES
from pcstac.search import PCSearch
from pcstac.search import PCSearch, PCSearchGetRequest

DEBUG: bool = os.getenv("DEBUG") == "TRUE" or False

Expand Down Expand Up @@ -79,7 +79,9 @@

extra_conformance_classes = cql_conformance_classes + collections_conformance_classes

search_get_request_model = create_get_request_model(extensions)
search_get_request_model = create_get_request_model(
extensions, base_model=PCSearchGetRequest
)
search_post_request_model = create_post_request_model(extensions, base_model=PCSearch)

api = PCStacApi(
Expand Down
6 changes: 4 additions & 2 deletions pcstac/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from pcstac.api import PCStacApi
from pcstac.client import PCClient
from pcstac.search import PCSearch
from pcstac.search import PCSearch, PCSearchGetRequest

DATA_DIR = os.path.join(os.path.dirname(__file__), "data")

Expand Down Expand Up @@ -68,7 +68,9 @@ def api_client(pqe_pg):
TokenPaginationExtension(),
ContextExtension(),
]
search_get_request_model = create_get_request_model(extensions)
search_get_request_model = create_get_request_model(
extensions, base_model=PCSearchGetRequest
)
search_post_request_model = create_post_request_model(
extensions, base_model=PCSearch
)
Expand Down
28 changes: 27 additions & 1 deletion pcstac/tests/resources/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ async def test_item_search_get_query_extension(app_client):
)
resp = await app_client.get("/search", params=params)
resp_json = resp.json()
assert len(resp_json["features"]) == 10
assert len(resp_json["features"]) == 12
assert (
resp_json["features"][0]["properties"]["proj:epsg"]
== first_item["properties"]["proj:epsg"]
Expand Down Expand Up @@ -534,3 +534,29 @@ async def test_search_bbox_errors(app_client):
params = {"bbox": "100.0,0.0,0.0,105.0"}
resp = await app_client.get("/search", params=params)
assert resp.status_code == 400


@pytest.mark.asyncio
async def test_items_page_limits(app_client):
resp = await app_client.get("/collections/naip/items")
assert resp.status_code == 200
resp_json = resp.json()
assert len(resp_json["features"]) == 10


@pytest.mark.asyncio
async def test_search_get_page_limits(app_client):
resp = await app_client.get("/search?collection=naip")
assert resp.status_code == 200
resp_json = resp.json()
assert len(resp_json["features"]) == 12


@pytest.mark.asyncio
async def test_search_post_page_limits(app_client):
params = {"op": "=", "args": [{"property": "collection"}, "naip"]}

resp = await app_client.post("/search", json=params)
assert resp.status_code == 200
resp_json = resp.json()
assert len(resp_json["features"]) == 12
58 changes: 46 additions & 12 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,58 @@ if [[ "${CI}" ]]; then
fi

function usage() {
if [[ "${1}" ]]; then
echo "${1}"
fi
echo -n \
"Usage: $(basename "$0") [--dev, --db, --migrations, --deploy]
"Usage: $(basename "$0") [OPTIONS]
Runs tests for the project.

Options
--stac
Only test pcstac
--tiler
Only test pctiler
"
}

# Parse args
while [[ $# -gt 0 ]]; do case $1 in
--stac)
STAC_ONLY="1"
shift
;;
--tiler)
TILER_ONLY="1"
shift
;;
--help)
usage
exit 0
shift
;;
*)
usage "Unknown parameter passed: $1"
exit 1
;;
esac done

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
docker-compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
tiler-dev scripts/bin/test-tiler

docker-compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
stac-dev scripts/bin/test-stac
if [ -z ${STAC_ONLY} ]; then
docker-compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
tiler-dev scripts/bin/test-tiler
fi

if [ -z ${TILER_ONLY} ]; then

docker-compose \
-f docker-compose.yml \
-f docker-compose.dev.yml \
run --rm \
stac-dev scripts/bin/test-stac
fi

fi