From 5aa02b884e73fda116d21e74dec554c06367e1c4 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 4 Feb 2022 09:57:14 -0800 Subject: [PATCH] Call out 3rd party containers more clearly (#65684) --- homeassistant/helpers/system_info.py | 5 ++++- tests/helpers/test_system_info.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/helpers/system_info.py b/homeassistant/helpers/system_info.py index e137d0f673e..a551c6e3b9e 100644 --- a/homeassistant/helpers/system_info.py +++ b/homeassistant/helpers/system_info.py @@ -41,8 +41,11 @@ async def async_get_system_info(hass: HomeAssistant) -> dict[str, Any]: # Determine installation type on current data if info_object["docker"]: - if info_object["user"] == "root": + if info_object["user"] == "root" and os.path.isfile("/OFFICIAL_IMAGE"): info_object["installation_type"] = "Home Assistant Container" + else: + info_object["installation_type"] = "Unsupported Third Party Container" + elif is_virtual_env(): info_object["installation_type"] = "Home Assistant Core" diff --git a/tests/helpers/test_system_info.py b/tests/helpers/test_system_info.py index f4cb70f421a..e4aba5fbb24 100644 --- a/tests/helpers/test_system_info.py +++ b/tests/helpers/test_system_info.py @@ -18,15 +18,15 @@ async def test_container_installationtype(hass): """Test container installation type.""" with patch("platform.system", return_value="Linux"), patch( "os.path.isfile", return_value=True - ): + ), patch("homeassistant.helpers.system_info.getuser", return_value="root"): info = await hass.helpers.system_info.async_get_system_info() assert info["installation_type"] == "Home Assistant Container" with patch("platform.system", return_value="Linux"), patch( - "os.path.isfile", return_value=True + "os.path.isfile", side_effect=lambda file: file == "/.dockerenv" ), patch("homeassistant.helpers.system_info.getuser", return_value="user"): info = await hass.helpers.system_info.async_get_system_info() - assert info["installation_type"] == "Unknown" + assert info["installation_type"] == "Unsupported Third Party Container" async def test_getuser_keyerror(hass):