hass-core/tests/components/local_ip/test_init.py
Issac 3f570245aa Add local_ip component (#29973)
* Added localip component

* Split config and core logic, and migrate to sensor platform (requested by @MartinHjelmare)
Also allow overriding the sensor name via the config

* Tweak docstring

Co-Authored-By: Fabian Affolter <mail@fabian-affolter.ch>

* Initial support for config entries

* Rename localip to local_ip (1/2)

* Rename localip to local_ip (2/2)

* Add test for config_flow

* Split and rename tests

* Remove unneeded code from config_flow

* Implement configuration as config entry import.  Other misc requested changes from code review.

* Fix tests

* minor code review fixes

* remove unneeded code

Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>
2019-12-31 14:34:53 +01:00

22 lines
697 B
Python

"""Tests for the local_ip component."""
import pytest
from homeassistant.components.local_ip import DOMAIN
from homeassistant.setup import async_setup_component
from homeassistant.util import get_local_ip
@pytest.fixture(name="config")
def config_fixture():
"""Create hass config fixture."""
return {DOMAIN: {"name": "test"}}
async def test_basic_setup(hass, config):
"""Test component setup creates entry from config."""
assert await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
local_ip = await hass.async_add_executor_job(get_local_ip)
state = hass.states.get("sensor.test")
assert state
assert state.state == local_ip