Add Buienradar camera for Belgium (#30399)
* Buienradar Camera for Belgium * Voluptuous check for country code * Black formatting * Testing for Buienradar Belgium * Changed MULTIPLE CHOICE variable name * Changes from frenck review
This commit is contained in:
1 parent
b4f3415eb9
commit
6ff572d1dd
2 files changed
+42
-8
No files matched your search
@@ -10,11 +10,9 @@ from homeassistant.util import dt as dt_util
|
||||
EPSILON_DELTA = 0.0000000001
|
||||
|
||||
|
||||
def radar_map_url(dim: int = 512) -> str:
|
||||
def radar_map_url(dim: int = 512, country_code: str = "NL") -> str:
|
||||
"""Build map url, defaulting to 512 wide (as in component)."""
|
||||
return ("https://api.buienradar.nl/image/1.0/RadarMapNL?w={dim}&h={dim}").format(
|
||||
dim=dim
|
||||
)
|
||||
return f"https://api.buienradar.nl/image/1.0/RadarMap{country_code}?w={dim}&h={dim}"
|
||||
|
||||
|
||||
async def test_fetching_url_and_caching(aioclient_mock, hass, hass_client):
|
||||
@@ -110,6 +108,29 @@ async def test_dimension(aioclient_mock, hass, hass_client):
|
||||
assert aioclient_mock.call_count == 1
|
||||
|
||||
|
||||
async def test_belgium_country(aioclient_mock, hass, hass_client):
|
||||
"""Test that it actually adheres to another country like Belgium."""
|
||||
aioclient_mock.get(radar_map_url(country_code="BE"), text="hello world")
|
||||
|
||||
await async_setup_component(
|
||||
hass,
|
||||
"camera",
|
||||
{
|
||||
"camera": {
|
||||
"name": "config_test",
|
||||
"platform": "buienradar",
|
||||
"country_code": "BE",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
client = await hass_client()
|
||||
|
||||
await client.get("/api/camera_proxy/camera.config_test")
|
||||
|
||||
assert aioclient_mock.call_count == 1
|
||||
|
||||
|
||||
async def test_failure_response_not_cached(aioclient_mock, hass, hass_client):
|
||||
"""Test that it does not cache a failure response."""
|
||||
aioclient_mock.get(radar_map_url(), text="hello world", status=401)
|
||||
|
||||
Reference in new issue
Block a user