|
1 | | -"""Test titiler.stacapi Item endpoints.""" |
| 1 | +"""Test titiler.stacapi collections endpoints.""" |
2 | 2 |
|
3 | 3 | import json |
4 | 4 | import os |
@@ -42,3 +42,39 @@ def test_stac_collections(rio, get_assets, app): |
42 | 42 | assert resp["minzoom"] == 12 |
43 | 43 | assert resp["maxzoom"] == 14 |
44 | 44 | assert "?assets=cog" in resp["tiles"][0] |
| 45 | + |
| 46 | + |
| 47 | +@patch("titiler.stacapi.backend.ItemSearch") |
| 48 | +def test_stac_collections_filter(items_search, app): |
| 49 | + """test arguments passed to ItemSearch.""" |
| 50 | + |
| 51 | + class ItemSearch: |
| 52 | + def __init__(self, *args, **kwargs): |
| 53 | + pass |
| 54 | + |
| 55 | + def items_as_dicts(self): |
| 56 | + return [{}] |
| 57 | + |
| 58 | + items_search.return_value = ItemSearch() |
| 59 | + _ = app.get( |
| 60 | + "/collections/noaa-emergency-response/tiles/WebMercatorQuad/0/0/0/assets", |
| 61 | + params={ |
| 62 | + "filter": json.dumps({"op": "=", "args": [{"property": "value"}, "1"]}), |
| 63 | + "filter-lang": "cql2-json", |
| 64 | + }, |
| 65 | + ) |
| 66 | + assert items_search.call_args[1]["filter"] == { |
| 67 | + "op": "=", |
| 68 | + "args": [{"property": "value"}, "1"], |
| 69 | + } |
| 70 | + assert items_search.call_args[1]["filter_lang"] == "cql2-json" |
| 71 | + |
| 72 | + _ = app.get( |
| 73 | + "/collections/noaa-emergency-response/tiles/WebMercatorQuad/0/0/0/assets", |
| 74 | + params={ |
| 75 | + "filter": "(value = '1')", |
| 76 | + "filter-lang": "cql2-text", |
| 77 | + }, |
| 78 | + ) |
| 79 | + assert items_search.call_args[1]["filter"] == "(value = '1')" |
| 80 | + assert items_search.call_args[1]["filter_lang"] == "cql2-text" |
0 commit comments