Add more system information from Supervisor (#35560)
This commit is contained in:
1 parent
306f15723d
commit
eddb5c6c3f
8 files changed
+148
-35
No files matched your search
@@ -19,7 +19,7 @@ def hassio_env():
|
||||
"homeassistant.components.hassio.HassIO.is_connected",
|
||||
return_value={"result": "ok", "data": {}},
|
||||
), patch.dict(os.environ, {"HASSIO_TOKEN": "123456"}), patch(
|
||||
"homeassistant.components.hassio.HassIO.get_homeassistant_info",
|
||||
"homeassistant.components.hassio.HassIO.get_info",
|
||||
Mock(side_effect=HassioAPIError()),
|
||||
):
|
||||
yield
|
||||
@@ -35,8 +35,7 @@ def hassio_stubs(hassio_env, hass, hass_client, aioclient_mock):
|
||||
"homeassistant.components.hassio.HassIO.update_hass_timezone",
|
||||
return_value={"result": "ok"},
|
||||
), patch(
|
||||
"homeassistant.components.hassio.HassIO.get_homeassistant_info",
|
||||
side_effect=HassioAPIError(),
|
||||
"homeassistant.components.hassio.HassIO.get_info", side_effect=HassioAPIError(),
|
||||
):
|
||||
hass.state = CoreState.starting
|
||||
hass.loop.run_until_complete(async_setup_component(hass, "hassio", {}))
|
||||
|
||||
@@ -91,7 +91,7 @@ async def test_hassio_discovery_startup_done(hass, aioclient_mock, hassio_client
|
||||
"homeassistant.components.hassio.HassIO.update_hass_api",
|
||||
return_value={"result": "ok"},
|
||||
), patch(
|
||||
"homeassistant.components.hassio.HassIO.get_homeassistant_info",
|
||||
"homeassistant.components.hassio.HassIO.get_info",
|
||||
Mock(side_effect=HassioAPIError()),
|
||||
), patch(
|
||||
"homeassistant.components.mqtt.config_flow.FlowHandler.async_step_hassio",
|
||||
|
||||
@@ -30,26 +30,64 @@ async def test_api_ping_exeption(hassio_handler, aioclient_mock):
|
||||
assert aioclient_mock.call_count == 1
|
||||
|
||||
|
||||
async def test_api_homeassistant_info(hassio_handler, aioclient_mock):
|
||||
"""Test setup with API Home Assistant info."""
|
||||
async def test_api_info(hassio_handler, aioclient_mock):
|
||||
"""Test setup with API generic info."""
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/homeassistant/info",
|
||||
json={"result": "ok", "data": {"last_version": "10.0"}},
|
||||
"http://127.0.0.1/info",
|
||||
json={
|
||||
"result": "ok",
|
||||
"data": {"supervisor": "222", "homeassistant": "0.110.0", "hassos": None},
|
||||
},
|
||||
)
|
||||
|
||||
data = await hassio_handler.get_homeassistant_info()
|
||||
data = await hassio_handler.get_info()
|
||||
assert aioclient_mock.call_count == 1
|
||||
assert data["last_version"] == "10.0"
|
||||
assert data["hassos"] is None
|
||||
assert data["homeassistant"] == "0.110.0"
|
||||
assert data["supervisor"] == "222"
|
||||
|
||||
|
||||
async def test_api_homeassistant_info_error(hassio_handler, aioclient_mock):
|
||||
async def test_api_info_error(hassio_handler, aioclient_mock):
|
||||
"""Test setup with API Home Assistant info error."""
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/homeassistant/info", json={"result": "error", "message": None}
|
||||
"http://127.0.0.1/info", json={"result": "error", "message": None}
|
||||
)
|
||||
|
||||
with pytest.raises(HassioAPIError):
|
||||
await hassio_handler.get_homeassistant_info()
|
||||
await hassio_handler.get_info()
|
||||
|
||||
assert aioclient_mock.call_count == 1
|
||||
|
||||
|
||||
async def test_api_host_info(hassio_handler, aioclient_mock):
|
||||
"""Test setup with API Host info."""
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/host/info",
|
||||
json={
|
||||
"result": "ok",
|
||||
"data": {
|
||||
"chassis": "vm",
|
||||
"operating_system": "Debian GNU/Linux 10 (buster)",
|
||||
"kernel": "4.19.0-6-amd64",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
data = await hassio_handler.get_host_info()
|
||||
assert aioclient_mock.call_count == 1
|
||||
assert data["chassis"] == "vm"
|
||||
assert data["kernel"] == "4.19.0-6-amd64"
|
||||
assert data["operating_system"] == "Debian GNU/Linux 10 (buster)"
|
||||
|
||||
|
||||
async def test_api_host_info_error(hassio_handler, aioclient_mock):
|
||||
"""Test setup with API Home Assistant info error."""
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/host/info", json={"result": "error", "message": None}
|
||||
)
|
||||
|
||||
with pytest.raises(HassioAPIError):
|
||||
await hassio_handler.get_host_info()
|
||||
|
||||
assert aioclient_mock.call_count == 1
|
||||
|
||||
|
||||
@@ -20,8 +20,25 @@ def mock_all(aioclient_mock):
|
||||
aioclient_mock.get("http://127.0.0.1/supervisor/ping", json={"result": "ok"})
|
||||
aioclient_mock.post("http://127.0.0.1/supervisor/options", json={"result": "ok"})
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/homeassistant/info",
|
||||
json={"result": "ok", "data": {"last_version": "10.0"}},
|
||||
"http://127.0.0.1/info",
|
||||
json={
|
||||
"result": "ok",
|
||||
"data": {"supervisor": "222", "homeassistant": "0.110.0", "hassos": None},
|
||||
},
|
||||
)
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/host/info",
|
||||
json={
|
||||
"result": "ok",
|
||||
"data": {
|
||||
"result": "ok",
|
||||
"data": {
|
||||
"chassis": "vm",
|
||||
"operating_system": "Debian GNU/Linux 10 (buster)",
|
||||
"kernel": "4.19.0-6-amd64",
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/ingress/panels", json={"result": "ok", "data": {"panels": {}}}
|
||||
@@ -34,8 +51,8 @@ async def test_setup_api_ping(hass, aioclient_mock):
|
||||
result = await async_setup_component(hass, "hassio", {})
|
||||
assert result
|
||||
|
||||
assert aioclient_mock.call_count == 5
|
||||
assert hass.components.hassio.get_homeassistant_version() == "10.0"
|
||||
assert aioclient_mock.call_count == 6
|
||||
assert hass.components.hassio.get_homeassistant_version() == "0.110.0"
|
||||
assert hass.components.hassio.is_hassio()
|
||||
|
||||
|
||||
@@ -73,7 +90,7 @@ async def test_setup_api_push_api_data(hass, aioclient_mock):
|
||||
)
|
||||
assert result
|
||||
|
||||
assert aioclient_mock.call_count == 5
|
||||
assert aioclient_mock.call_count == 6
|
||||
assert not aioclient_mock.mock_calls[1][2]["ssl"]
|
||||
assert aioclient_mock.mock_calls[1][2]["port"] == 9999
|
||||
assert aioclient_mock.mock_calls[1][2]["watchdog"]
|
||||
@@ -89,7 +106,7 @@ async def test_setup_api_push_api_data_server_host(hass, aioclient_mock):
|
||||
)
|
||||
assert result
|
||||
|
||||
assert aioclient_mock.call_count == 5
|
||||
assert aioclient_mock.call_count == 6
|
||||
assert not aioclient_mock.mock_calls[1][2]["ssl"]
|
||||
assert aioclient_mock.mock_calls[1][2]["port"] == 9999
|
||||
assert not aioclient_mock.mock_calls[1][2]["watchdog"]
|
||||
@@ -101,7 +118,7 @@ async def test_setup_api_push_api_data_default(hass, aioclient_mock, hass_storag
|
||||
result = await async_setup_component(hass, "hassio", {"http": {}, "hassio": {}})
|
||||
assert result
|
||||
|
||||
assert aioclient_mock.call_count == 5
|
||||
assert aioclient_mock.call_count == 6
|
||||
assert not aioclient_mock.mock_calls[1][2]["ssl"]
|
||||
assert aioclient_mock.mock_calls[1][2]["port"] == 8123
|
||||
refresh_token = aioclient_mock.mock_calls[1][2]["refresh_token"]
|
||||
@@ -148,7 +165,7 @@ async def test_setup_api_existing_hassio_user(hass, aioclient_mock, hass_storage
|
||||
result = await async_setup_component(hass, "hassio", {"http": {}, "hassio": {}})
|
||||
assert result
|
||||
|
||||
assert aioclient_mock.call_count == 5
|
||||
assert aioclient_mock.call_count == 6
|
||||
assert not aioclient_mock.mock_calls[1][2]["ssl"]
|
||||
assert aioclient_mock.mock_calls[1][2]["port"] == 8123
|
||||
assert aioclient_mock.mock_calls[1][2]["refresh_token"] == token.token
|
||||
@@ -162,7 +179,7 @@ async def test_setup_core_push_timezone(hass, aioclient_mock):
|
||||
result = await async_setup_component(hass, "hassio", {"hassio": {}})
|
||||
assert result
|
||||
|
||||
assert aioclient_mock.call_count == 5
|
||||
assert aioclient_mock.call_count == 6
|
||||
assert aioclient_mock.mock_calls[2][2]["timezone"] == "testzone"
|
||||
|
||||
await hass.config.async_update(time_zone="America/New_York")
|
||||
@@ -178,7 +195,7 @@ async def test_setup_hassio_no_additional_data(hass, aioclient_mock):
|
||||
result = await async_setup_component(hass, "hassio", {"hassio": {}})
|
||||
assert result
|
||||
|
||||
assert aioclient_mock.call_count == 5
|
||||
assert aioclient_mock.call_count == 6
|
||||
assert aioclient_mock.mock_calls[-1][3]["X-Hassio-Key"] == "123456"
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +154,12 @@ async def test_new_version_shows_entity_after_hour_hassio(
|
||||
"""Test if binary sensor gets updated if new version is available / Hass.io."""
|
||||
mock_get_uuid.return_value = MOCK_HUUID
|
||||
mock_component(hass, "hassio")
|
||||
hass.data["hassio_hass_version"] = "999.0"
|
||||
hass.data["hassio_info"] = {"hassos": None, "homeassistant": "999.0"}
|
||||
hass.data["hassio_host"] = {
|
||||
"supervisor": "222",
|
||||
"chassis": "vm",
|
||||
"operating_system": "HassOS 4.6",
|
||||
}
|
||||
|
||||
assert await async_setup_component(hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
||||
|
||||
|
||||
Reference in new issue
Block a user