forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve buienradar tests (home-assistant#50101)
- Loading branch information
1 parent
44383f2
commit 2b46107
Showing
3 changed files
with
25 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
"""The tests for the Buienradar sensor platform.""" | ||
from unittest.mock import patch | ||
|
||
from homeassistant.components.buienradar.const import DOMAIN | ||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE | ||
from homeassistant.helpers.entity_registry import async_get | ||
|
||
from tests.common import MockConfigEntry | ||
|
||
TEST_LONGITUDE = 51.5288504 | ||
TEST_LATITUDE = 5.4002156 | ||
|
||
CONDITIONS = ["stationname", "temperature"] | ||
TEST_CFG_DATA = {CONF_LATITUDE: 51.5288504, CONF_LONGITUDE: 5.4002156} | ||
TEST_CFG_DATA = {CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE} | ||
|
||
|
||
async def test_smoke_test_setup_component(hass): | ||
async def test_smoke_test_setup_component(aioclient_mock, hass): | ||
"""Smoke test for successfully set-up with default config.""" | ||
mock_entry = MockConfigEntry(domain=DOMAIN, unique_id="TEST_ID", data=TEST_CFG_DATA) | ||
|
||
mock_entry.add_to_hass(hass) | ||
|
||
with patch( | ||
"homeassistant.components.buienradar.sensor.BrSensor.entity_registry_enabled_default" | ||
) as enabled_by_default_mock: | ||
enabled_by_default_mock.return_value = True | ||
|
||
await hass.config_entries.async_setup(mock_entry.entry_id) | ||
await hass.async_block_till_done() | ||
entity_registry = async_get(hass) | ||
for cond in CONDITIONS: | ||
entity_registry.async_get_or_create( | ||
domain="sensor", | ||
platform="buienradar", | ||
unique_id=f"{TEST_LATITUDE:2.6f}{TEST_LONGITUDE:2.6f}{cond}", | ||
config_entry=mock_entry, | ||
original_name=f"Buienradar {cond}", | ||
) | ||
await hass.async_block_till_done() | ||
|
||
await hass.config_entries.async_setup(mock_entry.entry_id) | ||
await hass.async_block_till_done() | ||
|
||
for cond in CONDITIONS: | ||
state = hass.states.get(f"sensor.buienradar_{cond}") | ||
state = hass.states.get(f"sensor.buienradar_5_40021651_528850{cond}") | ||
assert state.state == "unknown" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters