core/tests/components/version/test_sensor.py

27 lines
731 B
Python
Raw Normal View History

"""The test for the version sensor platform."""
2021-01-01 21:31:56 +00:00
from unittest.mock import patch
2021-01-01 21:31:56 +00:00
from homeassistant.setup import async_setup_component
2019-07-31 19:25:30 +00:00
MOCK_VERSION = "10.0"
async def test_version_sensor(hass):
"""Test the Version sensor."""
config = {"sensor": {"platform": "version"}}
assert await async_setup_component(hass, "sensor", config)
async def test_version(hass):
"""Test the Version sensor."""
config = {"sensor": {"platform": "version", "name": "test"}}
2019-07-31 19:25:30 +00:00
with patch("homeassistant.const.__version__", MOCK_VERSION):
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
state = hass.states.get("sensor.test")
assert state.state == "10.0"