From abedd03d051cd31201bac2ab46b925ed8684e360 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 14 Sep 2023 09:19:49 +0200 Subject: [PATCH] API - fix tests --- .../tests/workouts/test_utils/test_maps.py | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/fittrackee/tests/workouts/test_utils/test_maps.py b/fittrackee/tests/workouts/test_utils/test_maps.py index 7dc952f0..6b696f1d 100644 --- a/fittrackee/tests/workouts/test_utils/test_maps.py +++ b/fittrackee/tests/workouts/test_utils/test_maps.py @@ -11,16 +11,7 @@ class TestGetStaticMapTileServerUrl: 'input_tile_server_subdomains,' 'expected_tile_server_url', [ - ( - 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - '', - 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - ), - ( - 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - 'a', - 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', - ), + # tile server without subdomain ( 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', '', @@ -31,6 +22,21 @@ class TestGetStaticMapTileServerUrl: 'a', 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', ), + # tile server with subdomain + ( + 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/' + '{z}/{x}/{y}.png', + 'a', + 'https://a.tile-cyclosm.openstreetmap.fr/cyclosm/' + '{z}/{x}/{y}.png', + ), + ( + 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/' + '{z}/{x}/{y}.png', + '', + 'https://tile-cyclosm.openstreetmap.fr/cyclosm/' + '{z}/{x}/{y}.png', + ), ], ) def test_it_returns_tile_server_url( @@ -52,12 +58,15 @@ class TestGetStaticMapTileServerUrl: def test_it_returns_tile_server_url_with_random_subdomain(self) -> None: """in case multiple subdomains are provided""" tile_config = { - 'URL': 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + 'URL': ( + 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/' + '{z}/{x}/{y}.png' + ), 'STATICMAP_SUBDOMAINS': 'a,b,c', } with patch('random.choice', return_value='b'): - assert ( - get_static_map_tile_server_url(tile_config) - == 'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png' + assert get_static_map_tile_server_url(tile_config) == ( + 'https://b.tile-cyclosm.openstreetmap.fr/cyclosm/' + '{z}/{x}/{y}.png' )