mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-02-21 02:09:44 +00:00
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
"""Test Supervisor API."""
|
|
# pylint: disable=protected-access
|
|
import pytest
|
|
|
|
from supervisor.api.const import ATTR_AVAILABLE_UPDATES
|
|
from supervisor.coresys import CoreSys
|
|
|
|
from tests.const import TEST_ADDON_SLUG
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_api_supervisor_options_debug(api_client, coresys: CoreSys):
|
|
"""Test security options force security."""
|
|
assert not coresys.config.debug
|
|
|
|
await api_client.post("/supervisor/options", json={"debug": True})
|
|
|
|
assert coresys.config.debug
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_api_supervisor_available_updates(
|
|
install_addon_ssh,
|
|
api_client,
|
|
coresys: CoreSys,
|
|
):
|
|
"""Test available_updates."""
|
|
installed_addon = coresys.addons.get(TEST_ADDON_SLUG)
|
|
installed_addon.persist["version"] = "1.2.3"
|
|
|
|
async def available_updates():
|
|
return (await (await api_client.get("/supervisor/available_updates")).json())[
|
|
"data"
|
|
][ATTR_AVAILABLE_UPDATES]
|
|
|
|
updates = await available_updates()
|
|
assert len(updates) == 1
|
|
assert updates[-1] == {
|
|
"icon": None,
|
|
"name": "Terminal & SSH",
|
|
"panel_path": "/update-available/local_ssh",
|
|
"update_type": "addon",
|
|
"version_latest": "9.2.1",
|
|
}
|
|
|
|
coresys.updater._data["hassos"] = "321"
|
|
coresys.os._version = "123"
|
|
updates = await available_updates()
|
|
assert len(updates) == 2
|
|
assert updates[0] == {
|
|
"panel_path": "/update-available/os",
|
|
"update_type": "os",
|
|
"version_latest": "321",
|
|
}
|
|
|
|
coresys.updater._data["homeassistant"] = "321"
|
|
coresys.homeassistant.version = "123"
|
|
updates = await available_updates()
|
|
assert len(updates) == 3
|
|
assert updates[0] == {
|
|
"panel_path": "/update-available/core",
|
|
"update_type": "core",
|
|
"version_latest": "321",
|
|
}
|