Skip to content

Commit

Permalink
Treat 'hamlet' location as a 'city' (#512)
Browse files Browse the repository at this point in the history
* Add parsing to close #511 with unit test

* Fix reference error in unit test

---------

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Apr 18, 2024
1 parent 2cc9925 commit 1cdff51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion neon_utils/location_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def get_location(lat, lng) -> (str, str, str, str):
LOG.debug(f"{location.raw.get('address')}")
city = location.raw.get('address').get('city') or \
location.raw.get('address').get('town') or \
location.raw.get('address').get('village')
location.raw.get('address').get('village') or \
location.raw.get('address').get('hamlet')
county = location.raw.get('address').get('county')
state = location.raw.get('address').get('state')
country = location.raw.get('address').get('country')
Expand Down
4 changes: 4 additions & 0 deletions tests/location_util_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def test_get_location_from_coords(self):
self.assertEqual(location, ("Seattle", "King County", "Washington",
"United States"))

# Test 'hamlet' location
location = get_location(34.46433387046654, -81.99487538579375)
self.assertIsInstance(location[0], str)

def test_get_timezone_from_coords(self):
from neon_utils.location_utils import get_timezone
lat = 47.6038321
Expand Down

0 comments on commit 1cdff51

Please sign in to comment.