From 99faae790957b46b9087823a433c519c74260d1d Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Mon, 27 Nov 2023 13:59:41 -0800 Subject: [PATCH] Annotate known public Nominatim servers (#488) Update tests to avoid hitting rate limits Co-authored-by: Daniel McKnight --- neon_utils/location_utils.py | 1 + tests/location_util_tests.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/neon_utils/location_utils.py b/neon_utils/location_utils.py index d052999a..6cbb721a 100644 --- a/neon_utils/location_utils.py +++ b/neon_utils/location_utils.py @@ -38,6 +38,7 @@ from ovos_utils.log import LOG +# geocode.maps.co nominatim.openstreetmap.org _NOMINATIM_DOMAIN = "geocode.maps.co" diff --git a/tests/location_util_tests.py b/tests/location_util_tests.py index dd2898eb..aeb641b9 100644 --- a/tests/location_util_tests.py +++ b/tests/location_util_tests.py @@ -29,6 +29,8 @@ import unittest from datetime import datetime +from time import sleep + from dateutil.tz import gettz, tzlocal @@ -41,23 +43,27 @@ def test_get_coordinates_complete(self): "country": "United States"}) self.assertIsInstance(coords[0], float) self.assertIsInstance(coords[1], float) + sleep(1) # maps.co rate-limit # No city specified coords = get_coordinates({"state": "Washington", "country": "United States"}) self.assertIsInstance(coords[0], float) self.assertIsInstance(coords[1], float) + sleep(1) # maps.co rate-limit # No state specified coords = get_coordinates({"city": "Seattle", "country": "United States"}) self.assertIsInstance(coords[0], float) self.assertIsInstance(coords[1], float) + sleep(1) # maps.co rate-limit # No country specified coords = get_coordinates({"state": "Washington", "city": "Renton"}) self.assertIsInstance(coords[0], float) self.assertIsInstance(coords[1], float) + sleep(1) # maps.co rate-limit def test_get_location_from_coords(self): from neon_utils.location_utils import get_location @@ -106,6 +112,7 @@ def test_get_full_location(self): self.assertEqual(location_en['address']['state'], "Washington") self.assertEqual(location_en['address']['country'], "United States") self.assertEqual(location_en['address']['country_code'], "us") + sleep(1) # maps.co rate-limit location_es = get_full_location("Seattle, Washington", "es") self.assertEqual(location_es['lat'], location_en['lat']) @@ -113,6 +120,7 @@ def test_get_full_location(self): self.assertEqual(location_es['address']['country'], "Estados Unidos de América") self.assertEqual(location_en['address']['country_code'], "us") + sleep(1) # maps.co rate-limit location_from_coords = get_full_location((location_en['lat'], location_en['lon']))