mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
WUnderground unique ids (#13311)
* WUnderground unique_id * Remove async_generate_entity_id * Lint * Address comment
This commit is contained in:
committed by
Paulus Schoutsen
parent
ce98dfe395
commit
14c7fa8882
@@ -148,10 +148,11 @@ def test_invalid_data(hass, aioclient_mock):
|
||||
async def test_entity_id_with_multiple_stations(hass, aioclient_mock):
|
||||
"""Test not generating duplicate entity ids with multiple stations."""
|
||||
aioclient_mock.get(URL, text=load_fixture('wunderground-valid.json'))
|
||||
aioclient_mock.get(PWS_URL, text=load_fixture('wunderground-valid.json'))
|
||||
|
||||
config = [
|
||||
VALID_CONFIG,
|
||||
{**VALID_CONFIG, 'entity_namespace': 'hi'}
|
||||
{**VALID_CONFIG_PWS, 'entity_namespace': 'hi'}
|
||||
]
|
||||
await async_setup_component(hass, 'sensor', {'sensor': config})
|
||||
await hass.async_block_till_done()
|
||||
@@ -160,6 +161,25 @@ async def test_entity_id_with_multiple_stations(hass, aioclient_mock):
|
||||
assert state is not None
|
||||
assert state.state == 'Clear'
|
||||
|
||||
state = hass.states.get('sensor.hi_weather')
|
||||
state = hass.states.get('sensor.hi_pws_weather')
|
||||
assert state is not None
|
||||
assert state.state == 'Clear'
|
||||
|
||||
|
||||
async def test_fails_because_of_unique_id(hass, aioclient_mock):
|
||||
"""Test same config twice fails because of unique_id."""
|
||||
aioclient_mock.get(URL, text=load_fixture('wunderground-valid.json'))
|
||||
aioclient_mock.get(PWS_URL, text=load_fixture('wunderground-valid.json'))
|
||||
|
||||
config = [
|
||||
VALID_CONFIG,
|
||||
{**VALID_CONFIG, 'entity_namespace': 'hi'},
|
||||
VALID_CONFIG_PWS
|
||||
]
|
||||
await async_setup_component(hass, 'sensor', {'sensor': config})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
states = hass.states.async_all()
|
||||
expected = len(VALID_CONFIG['monitored_conditions']) + \
|
||||
len(VALID_CONFIG_PWS['monitored_conditions'])
|
||||
assert len(states) == expected
|
||||
|
||||
Reference in New Issue
Block a user