From 43223cb32458c5bb27c591b1dd8b98070c382d8f Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Mon, 23 Aug 2021 11:45:59 +0200 Subject: [PATCH] use tms count from morecantile --- CHANGES.md | 10 ++++++++++ src/titiler/application/tests/routes/test_tms.py | 8 +++++++- src/titiler/application/titiler/application/custom.py | 4 ++-- src/titiler/core/tests/test_factories.py | 4 +++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bb43586a0..be9245497 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,15 @@ # Release Notes +## Next (TDB) + +### titiler.core + +- fix morecantile related tests (https://github.com/developmentseed/titiler/issues/358) + +### titiler.application + +- fix morecantile related tests (https://github.com/developmentseed/titiler/issues/358) + ## 0.3.5 (2021-08-17) ### titiler.mosaic diff --git a/src/titiler/application/tests/routes/test_tms.py b/src/titiler/application/tests/routes/test_tms.py index 3cf6408b8..6cdad8d39 100644 --- a/src/titiler/application/tests/routes/test_tms.py +++ b/src/titiler/application/tests/routes/test_tms.py @@ -1,12 +1,18 @@ """test TileMatrixSets endpoints.""" +import morecantile + +NB_DEFAULT_TMS = len(morecantile.tms.list()) + def test_tilematrix(app): """test /tileMatrixSet endpoint.""" response = app.get("/tileMatrixSets") assert response.status_code == 200 body = response.json() - assert len(body["tileMatrixSets"]) == 12 # morecantile has 10 defaults + assert ( + len(body["tileMatrixSets"]) == NB_DEFAULT_TMS + 2 + ) # morecantile defaults + 2 customs tms = list(filter(lambda m: m["id"] == "EPSG3413", body["tileMatrixSets"]))[0] assert tms["links"][0]["href"] == "http://testserver/tileMatrixSets/EPSG3413" diff --git a/src/titiler/application/titiler/application/custom.py b/src/titiler/application/titiler/application/custom.py index 16a9f20d8..fdd88401d 100644 --- a/src/titiler/application/titiler/application/custom.py +++ b/src/titiler/application/titiler/application/custom.py @@ -45,7 +45,7 @@ # CUSTOM TMS for EPSG:3413 EPSG3413 = morecantile.TileMatrixSet.custom( - (-4194300, -4194300, 4194300, 4194300), + [-4194300, -4194300, 4194300, 4194300], CRS.from_epsg(3413), identifier="EPSG3413", matrix_scale=[2, 2], @@ -54,7 +54,7 @@ # CUSTOM TMS for EPSG:6933 # info from https://epsg.io/6933 EPSG6933 = morecantile.TileMatrixSet.custom( - (-17357881.81713629, -7324184.56362408, 17357881.81713629, 7324184.56362408), + [-17357881.81713629, -7324184.56362408, 17357881.81713629, 7324184.56362408], CRS.from_epsg(6933), identifier="EPSG6933", matrix_scale=[1, 1], diff --git a/src/titiler/core/tests/test_factories.py b/src/titiler/core/tests/test_factories.py index 73b33dc4e..32418785f 100644 --- a/src/titiler/core/tests/test_factories.py +++ b/src/titiler/core/tests/test_factories.py @@ -27,6 +27,8 @@ from starlette.testclient import TestClient +NB_DEFAULT_TMS = len(morecantile.tms.list()) + def test_TilerFactory(): """Test TilerFactory class.""" @@ -671,7 +673,7 @@ def test_TMSFactory(): response = client.get("/tms/tileMatrixSets") assert response.status_code == 200 body = response.json() - assert len(body["tileMatrixSets"]) == 10 # morecantile has 10 defaults + assert len(body["tileMatrixSets"]) == NB_DEFAULT_TMS tms = list(filter(lambda m: m["id"] == "WebMercatorQuad", body["tileMatrixSets"]))[ 0 ]