2017-08-12 06:52:56 +00:00
|
|
|
"""The test for the version sensor platform."""
|
2021-01-01 21:31:56 +00:00
|
|
|
from unittest.mock import patch
|
2017-08-12 06:52:56 +00:00
|
|
|
|
2021-01-01 21:31:56 +00:00
|
|
|
from homeassistant.setup import async_setup_component
|
2020-05-03 18:27:19 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
MOCK_VERSION = "10.0"
|
2017-08-12 06:52:56 +00:00
|
|
|
|
|
|
|
|
2020-04-07 16:36:35 +00:00
|
|
|
async def test_version_sensor(hass):
|
2017-08-12 06:52:56 +00:00
|
|
|
"""Test the Version sensor."""
|
2020-04-07 16:36:35 +00:00
|
|
|
config = {"sensor": {"platform": "version"}}
|
2017-08-12 06:52:56 +00:00
|
|
|
|
2020-04-07 16:36:35 +00:00
|
|
|
assert await async_setup_component(hass, "sensor", config)
|
2017-08-12 06:52:56 +00:00
|
|
|
|
|
|
|
|
2020-04-07 16:36:35 +00:00
|
|
|
async def test_version(hass):
|
|
|
|
"""Test the Version sensor."""
|
|
|
|
config = {"sensor": {"platform": "version", "name": "test"}}
|
2019-07-31 19:25:30 +00:00
|
|
|
|
2020-04-07 16:36:35 +00:00
|
|
|
with patch("homeassistant.const.__version__", MOCK_VERSION):
|
|
|
|
assert await async_setup_component(hass, "sensor", config)
|
|
|
|
await hass.async_block_till_done()
|
2017-08-12 06:52:56 +00:00
|
|
|
|
2020-04-07 16:36:35 +00:00
|
|
|
state = hass.states.get("sensor.test")
|
2017-08-12 06:52:56 +00:00
|
|
|
|
2020-04-07 16:36:35 +00:00
|
|
|
assert state.state == "10.0"
|