Only postfix image name for container (#55248)

This commit is contained in:
Joakim Sørensen 2021-08-26 10:54:42 +02:00 committed by GitHub
parent 56246056ce
commit 03d3bbfba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -87,7 +87,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
source = HaVersionSource.CONTAINER
if (
source in (HaVersionSource.SUPERVISOR, HaVersionSource.CONTAINER)
source == HaVersionSource.CONTAINER
and image is not None
and image != DEFAULT_IMAGE
):

View File

@ -98,3 +98,33 @@ async def test_update(hass):
state = hass.states.get("sensor.current_version")
assert state
assert state.state == "1234"
async def test_image_name_container(hass):
"""Test the Version sensor with image name for container."""
config = {
"sensor": {"platform": "version", "source": "docker", "image": "qemux86-64"}
}
with patch("homeassistant.components.version.sensor.HaVersion") as haversion:
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
constructor = haversion.call_args[1]
assert constructor["source"] == "container"
assert constructor["image"] == "qemux86-64-homeassistant"
async def test_image_name_supervisor(hass):
"""Test the Version sensor with image name for supervisor."""
config = {
"sensor": {"platform": "version", "source": "hassio", "image": "qemux86-64"}
}
with patch("homeassistant.components.version.sensor.HaVersion") as haversion:
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
constructor = haversion.call_args[1]
assert constructor["source"] == "supervisor"
assert constructor["image"] == "qemux86-64"