Add currency to location data (#53575)
This commit is contained in:
parent
127c9fc877
commit
85c1614204
7 changed files with 32 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
"""Test Home Assistant location util methods."""
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import aiohttp
|
||||
import pytest
|
||||
|
@ -76,11 +76,15 @@ async def test_detect_location_info_whoami(aioclient_mock, session):
|
|||
"""Test detect location info using whoami.home-assistant.io."""
|
||||
aioclient_mock.get(location_util.WHOAMI_URL, text=load_fixture("whoami.json"))
|
||||
|
||||
info = await location_util.async_detect_location_info(session, _test_real=True)
|
||||
with patch("homeassistant.util.location.HA_VERSION", "1.0"):
|
||||
info = await location_util.async_detect_location_info(session, _test_real=True)
|
||||
|
||||
assert str(aioclient_mock.mock_calls[-1][1]) == location_util.WHOAMI_URL
|
||||
|
||||
assert info is not None
|
||||
assert info.ip == "1.2.3.4"
|
||||
assert info.country_code == "XX"
|
||||
assert info.currency == "XXX"
|
||||
assert info.region_code == "00"
|
||||
assert info.city == "Gotham"
|
||||
assert info.zip_code == "12345"
|
||||
|
@ -90,6 +94,17 @@ async def test_detect_location_info_whoami(aioclient_mock, session):
|
|||
assert info.use_metric
|
||||
|
||||
|
||||
async def test_dev_url(aioclient_mock, session):
|
||||
"""Test usage of dev URL."""
|
||||
aioclient_mock.get(location_util.WHOAMI_URL_DEV, text=load_fixture("whoami.json"))
|
||||
with patch("homeassistant.util.location.HA_VERSION", "1.0.dev0"):
|
||||
info = await location_util.async_detect_location_info(session, _test_real=True)
|
||||
|
||||
assert str(aioclient_mock.mock_calls[-1][1]) == location_util.WHOAMI_URL_DEV
|
||||
|
||||
assert info.currency == "XXX"
|
||||
|
||||
|
||||
async def test_whoami_query_raises(raising_session):
|
||||
"""Test whoami query when the request to API fails."""
|
||||
info = await location_util._get_whoami(raising_session)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue