Skip to content

Commit

Permalink
manual_forced to manual_only
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 committed Aug 27, 2024
1 parent 24050f5 commit 1793944
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion supervisor/addons/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def options(self, value: dict[str, Any] | None) -> None:
@property
def boot(self) -> AddonBoot:
"""Return boot config with prio local settings unless config is forced."""
if self.boot_config == AddonBootConfig.MANUAL_FORCED:
if self.boot_config == AddonBootConfig.MANUAL_ONLY:
return super().boot
return self.persist.get(ATTR_BOOT, super().boot)

Expand Down
2 changes: 1 addition & 1 deletion supervisor/api/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async def options(self, request: web.Request) -> None:
if ATTR_OPTIONS in body:
addon.options = body[ATTR_OPTIONS]
if ATTR_BOOT in body:
if addon.boot_config == AddonBootConfig.MANUAL_FORCED:
if addon.boot_config == AddonBootConfig.MANUAL_ONLY:
raise APIError(
f"Addon {addon.slug} boot option is set to {addon.boot_config} so it cannot be changed"
)
Expand Down
4 changes: 2 additions & 2 deletions supervisor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class AddonBootConfig(StrEnum):

AUTO = "auto"
MANUAL = "manual"
MANUAL_FORCED = "manual_forced"
MANUAL_ONLY = "manual_only"


class AddonBoot(StrEnum):
Expand All @@ -399,7 +399,7 @@ class AddonBoot(StrEnum):
@classmethod
def _missing_(cls, value: str) -> Self | None:
"""Convert 'forced' config values to their counterpart."""
if value == AddonBootConfig.MANUAL_FORCED:
if value == AddonBootConfig.MANUAL_ONLY:
return AddonBoot.MANUAL
return None

Expand Down
6 changes: 3 additions & 3 deletions tests/addons/test_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,9 @@ async def test_addon_load_succeeds_with_docker_errors(
assert "Unknown error with test/amd64-addon-ssh:9.2.1" in caplog.text


async def test_addon_manual_forced_boot(coresys: CoreSys, install_addon_example: Addon):
"""Test an addon with manual forced boot mode."""
assert install_addon_example.boot_config == "manual_forced"
async def test_addon_manual_only_boot(coresys: CoreSys, install_addon_example: Addon):
"""Test an addon with manual only boot mode."""
assert install_addon_example.boot_config == "manual_only"
assert install_addon_example.boot == "manual"

# Users cannot change boot mode of an addon with manual forced so changing boot isn't realistic
Expand Down
8 changes: 4 additions & 4 deletions tests/api/test_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,21 @@ async def test_api_addon_system_managed(
assert body["data"]["system_managed_config_entry"] is None


async def test_addon_options_boot_mode_forced_invalid(
async def test_addon_options_boot_mode_manual_only_invalid(
api_client: TestClient, install_addon_example: Addon
):
"""Test changing boot mode is invalid if set to manual forced."""
"""Test changing boot mode is invalid if set to manual only."""
install_addon_example.data["ingress"] = False
resp = await api_client.get("/addons/local_example/info")
assert resp.status == 200
body = await resp.json()
assert body["data"]["boot"] == "manual"
assert body["data"]["boot_config"] == "manual_forced"
assert body["data"]["boot_config"] == "manual_only"

resp = await api_client.post("/addons/local_example/options", json={"boot": "auto"})
assert resp.status == 400
body = await resp.json()
assert (
body["message"]
== "Addon local_example boot option is set to manual_forced so it cannot be changed"
== "Addon local_example boot option is set to manual_only so it cannot be changed"
)
2 changes: 1 addition & 1 deletion tests/fixtures/addons/local/example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ ingress_port: 0
breaking_versions:
- test
- 1.0
boot: manual_forced
boot: manual_only

0 comments on commit 1793944

Please sign in to comment.