Skip to content

Commit 4471241

Browse files
committed
Remove deprecated fields and options from Supervisor API
1 parent 3c5f492 commit 4471241

File tree

2 files changed

+1
-112
lines changed

2 files changed

+1
-112
lines changed

supervisor/api/supervisor.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import voluptuous as vol
1010

1111
from ..const import (
12-
ATTR_ADDONS,
1312
ATTR_ADDONS_REPOSITORIES,
1413
ATTR_ARCH,
1514
ATTR_AUTO_UPDATE,
@@ -25,18 +24,13 @@
2524
ATTR_DIAGNOSTICS,
2625
ATTR_FORCE_SECURITY,
2726
ATTR_HEALTHY,
28-
ATTR_ICON,
2927
ATTR_IP_ADDRESS,
3028
ATTR_LOGGING,
3129
ATTR_MEMORY_LIMIT,
3230
ATTR_MEMORY_PERCENT,
3331
ATTR_MEMORY_USAGE,
34-
ATTR_NAME,
3532
ATTR_NETWORK_RX,
3633
ATTR_NETWORK_TX,
37-
ATTR_REPOSITORY,
38-
ATTR_SLUG,
39-
ATTR_STATE,
4034
ATTR_SUPPORTED,
4135
ATTR_TIMEZONE,
4236
ATTR_UPDATE_AVAILABLE,
@@ -108,25 +102,6 @@ async def info(self, request: web.Request) -> dict[str, Any]:
108102
ATTR_AUTO_UPDATE: self.sys_updater.auto_update,
109103
ATTR_DETECT_BLOCKING_IO: BlockBusterManager.is_enabled(),
110104
ATTR_COUNTRY: self.sys_config.country,
111-
# Depricated
112-
ATTR_WAIT_BOOT: self.sys_config.wait_boot,
113-
ATTR_ADDONS: [
114-
{
115-
ATTR_NAME: addon.name,
116-
ATTR_SLUG: addon.slug,
117-
ATTR_VERSION: addon.version,
118-
ATTR_VERSION_LATEST: addon.latest_version,
119-
ATTR_UPDATE_AVAILABLE: addon.need_update,
120-
ATTR_STATE: addon.state,
121-
ATTR_REPOSITORY: addon.repository,
122-
ATTR_ICON: addon.with_icon,
123-
}
124-
for addon in self.sys_addons.local.values()
125-
],
126-
ATTR_ADDONS_REPOSITORIES: [
127-
{ATTR_NAME: store.name, ATTR_SLUG: store.slug}
128-
for store in self.sys_store.all
129-
],
130105
}
131106

132107
@api_process
@@ -182,20 +157,10 @@ async def options(self, request: web.Request) -> None:
182157
self.sys_config.detect_blocking_io = False
183158
BlockBusterManager.deactivate()
184159

185-
# Deprecated
186-
if ATTR_WAIT_BOOT in body:
187-
self.sys_config.wait_boot = body[ATTR_WAIT_BOOT]
188-
189160
# Save changes before processing addons in case of errors
190161
await self.sys_updater.save_data()
191162
await self.sys_config.save_data()
192163

193-
# Remove: 2022.9
194-
if ATTR_ADDONS_REPOSITORIES in body:
195-
await asyncio.shield(
196-
self.sys_store.update_repositories(set(body[ATTR_ADDONS_REPOSITORIES]))
197-
)
198-
199164
await self.sys_resolution.evaluate.evaluate_system()
200165

201166
@api_process

tests/api/test_supervisor.py

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import pytest
1010

1111
from supervisor.coresys import CoreSys
12-
from supervisor.exceptions import HassioError, HostNotSupportedError, StoreGitError
13-
from supervisor.store.repository import Repository
12+
from supervisor.exceptions import HassioError, HostNotSupportedError
1413

1514
from tests.api import common_test_api_advanced_logs
1615
from tests.dbus_service_mocks.base import DBusServiceMock
@@ -28,81 +27,6 @@ async def test_api_supervisor_options_debug(api_client: TestClient, coresys: Cor
2827
assert coresys.config.debug
2928

3029

31-
async def test_api_supervisor_options_add_repository(
32-
api_client: TestClient, coresys: CoreSys, supervisor_internet: AsyncMock
33-
):
34-
"""Test add a repository via POST /supervisor/options REST API."""
35-
assert REPO_URL not in coresys.store.repository_urls
36-
37-
with (
38-
patch("supervisor.store.repository.RepositoryGit.load", return_value=None),
39-
patch("supervisor.store.repository.RepositoryGit.validate", return_value=True),
40-
):
41-
response = await api_client.post(
42-
"/supervisor/options", json={"addons_repositories": [REPO_URL]}
43-
)
44-
45-
assert response.status == 200
46-
assert REPO_URL in coresys.store.repository_urls
47-
48-
49-
async def test_api_supervisor_options_remove_repository(
50-
api_client: TestClient, coresys: CoreSys, test_repository: Repository
51-
):
52-
"""Test remove a repository via POST /supervisor/options REST API."""
53-
assert test_repository.source in coresys.store.repository_urls
54-
assert test_repository.slug in coresys.store.repositories
55-
56-
response = await api_client.post(
57-
"/supervisor/options", json={"addons_repositories": []}
58-
)
59-
60-
assert response.status == 200
61-
assert test_repository.source not in coresys.store.repository_urls
62-
assert test_repository.slug not in coresys.store.repositories
63-
64-
65-
@pytest.mark.parametrize("git_error", [None, StoreGitError()])
66-
async def test_api_supervisor_options_repositories_skipped_on_error(
67-
api_client: TestClient, coresys: CoreSys, git_error: StoreGitError
68-
):
69-
"""Test repositories skipped on error via POST /supervisor/options REST API."""
70-
with (
71-
patch("supervisor.store.repository.RepositoryGit.load", side_effect=git_error),
72-
patch("supervisor.store.repository.RepositoryGit.validate", return_value=False),
73-
patch("supervisor.store.repository.RepositoryCustom.remove"),
74-
):
75-
response = await api_client.post(
76-
"/supervisor/options", json={"addons_repositories": [REPO_URL]}
77-
)
78-
79-
assert response.status == 400
80-
assert len(coresys.resolution.suggestions) == 0
81-
assert REPO_URL not in coresys.store.repository_urls
82-
83-
84-
async def test_api_supervisor_options_repo_error_with_config_change(
85-
api_client: TestClient, coresys: CoreSys
86-
):
87-
"""Test config change with add repository error via POST /supervisor/options REST API."""
88-
assert not coresys.config.debug
89-
90-
with patch(
91-
"supervisor.store.repository.RepositoryGit.load", side_effect=StoreGitError()
92-
):
93-
response = await api_client.post(
94-
"/supervisor/options",
95-
json={"debug": True, "addons_repositories": [REPO_URL]},
96-
)
97-
98-
assert response.status == 400
99-
assert REPO_URL not in coresys.store.repository_urls
100-
101-
assert coresys.config.debug
102-
coresys.updater.save_data.assert_called_once()
103-
coresys.config.save_data.assert_called_once()
104-
105-
10630
async def test_api_supervisor_options_auto_update(
10731
api_client: TestClient, coresys: CoreSys
10832
):

0 commit comments

Comments
 (0)