mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Only postfix image name for container (#55248)
This commit is contained in:
parent
56246056ce
commit
03d3bbfba1
@ -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
|
||||
):
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user