2019-12-31 13:34:53 +00:00
|
|
|
"""Tests for the local_ip component."""
|
|
|
|
from homeassistant.components.local_ip import DOMAIN
|
2021-07-22 18:12:33 +00:00
|
|
|
from homeassistant.components.network import async_get_source_ip
|
|
|
|
from homeassistant.components.zeroconf import MDNS_TARGET_IP
|
2019-12-31 13:34:53 +00:00
|
|
|
|
2021-05-15 11:45:10 +00:00
|
|
|
from tests.common import MockConfigEntry
|
2019-12-31 13:34:53 +00:00
|
|
|
|
|
|
|
|
2021-10-04 13:33:13 +00:00
|
|
|
async def test_basic_setup(hass, mock_get_source_ip):
|
2019-12-31 13:34:53 +00:00
|
|
|
"""Test component setup creates entry from config."""
|
2021-05-15 11:45:10 +00:00
|
|
|
entry = MockConfigEntry(domain=DOMAIN, data={})
|
|
|
|
entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
await hass.config_entries.async_setup(entry.entry_id)
|
2019-12-31 13:34:53 +00:00
|
|
|
await hass.async_block_till_done()
|
2021-05-15 11:45:10 +00:00
|
|
|
|
2021-07-22 18:12:33 +00:00
|
|
|
local_ip = await async_get_source_ip(hass, target_ip=MDNS_TARGET_IP)
|
2020-04-09 14:06:01 +00:00
|
|
|
state = hass.states.get(f"sensor.{DOMAIN}")
|
2019-12-31 13:34:53 +00:00
|
|
|
assert state
|
|
|
|
assert state.state == local_ip
|