From 9d6a4ca0105db2f4bedab5b844fb7bf33b720dda Mon Sep 17 00:00:00 2001 From: Giovanni Allegri Date: Wed, 18 Oct 2023 10:42:01 +0200 Subject: [PATCH] [Fixes #11610] Make thumbs backgrounds tests run (#11611) * make thumbs bagrounds run * Fix thumbs backgrounds tests --- geonode/thumbs/background.py | 4 ++-- geonode/thumbs/tests/__init__.py | 1 + geonode/thumbs/tests/test_backgrounds.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/geonode/thumbs/background.py b/geonode/thumbs/background.py index 85bceb64159..1df55fc0dbc 100644 --- a/geonode/thumbs/background.py +++ b/geonode/thumbs/background.py @@ -542,8 +542,8 @@ def fetch(self, bbox: typing.List, *args, **kwargs): return background def build_kvp_request(self, baseurl, layer, style, xyz): - return f"{baseurl}?&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&layer={layer}&style={style} \ - &tilematrixset={self.options['tilematrixset']}&TileMatrix={xyz[2]}&TileRow={xyz[1]}&TileCol={xyz[0]}" + return f"{baseurl}?&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&layer={layer}&style={style}\ +&tilematrixset={self.options['tilematrixset']}&TileMatrix={xyz[2]}&TileRow={xyz[1]}&TileCol={xyz[0]}" def build_request(self, xyz): request_encoding = self.options.get("requestencoding", "KVP") diff --git a/geonode/thumbs/tests/__init__.py b/geonode/thumbs/tests/__init__.py index dee8ede78da..0bc5c5d5525 100644 --- a/geonode/thumbs/tests/__init__.py +++ b/geonode/thumbs/tests/__init__.py @@ -19,3 +19,4 @@ from .test_unit import * # noqa: F401, F403 from .test_integration import * # noqa: F401, F403 +from .test_backgrounds import * # noqa: F401, F403 diff --git a/geonode/thumbs/tests/test_backgrounds.py b/geonode/thumbs/tests/test_backgrounds.py index 896ef0685dc..d99adf680ce 100644 --- a/geonode/thumbs/tests/test_backgrounds.py +++ b/geonode/thumbs/tests/test_backgrounds.py @@ -276,7 +276,7 @@ THUMBNAIL_BACKGROUND = { "class": "geonode.thumbs.background.GenericWMTSBackground", "options": { - "url": "myserver.com/WMTS", + "url": "https://myserver.com/WMTS", "layer": "Hosted_basemap_inforac_3857", "style": "default", "tilematrixset": "default028mm", @@ -345,8 +345,8 @@ def test_get_tiles_coords(self, *args): @override_settings(THUMBNAIL_BACKGROUND=THUMBNAIL_BACKGROUND) @patch("geonode.thumbs.background.WMTS_TILEMATRIXSET_LEVELS", WMTS_TILEMATRIX_LEVELS) def test_build_request(self, *args): - expected_imgurl = "https://myserver.com/WMTS?&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png& \ - layer=Hosted_basemap_inforac_3857&style=default&tilematrixset=default028mm&TileMatrix=4&TileRow=5&TileCol=7" + expected_imgurl = "https://myserver.com/WMTS?&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&\ +layer=Hosted_basemap_inforac_3857&style=default&tilematrixset=default028mm&TileMatrix=4&TileRow=5&TileCol=7" background = GenericWMTSBackground(thumbnail_width=500, thumbnail_height=200) imgurl = background.build_request((7, 5, 4)) self.assertEqual(expected_imgurl, imgurl)