1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 12:29:08 +00:00

Allow removing addon config on uninstall (#4913)

This commit is contained in:
Mike Degatano
2024-02-29 10:24:51 -05:00
committed by GitHub
parent 8b5c808e8c
commit 5126820619
5 changed files with 63 additions and 7 deletions

View File

@@ -220,3 +220,45 @@ async def test_api_addon_rebuild_healthcheck(
assert state_changes == [AddonState.STOPPED, AddonState.STARTUP]
assert install_addon_ssh.state == AddonState.STARTED
assert resp.status == 200
async def test_api_addon_uninstall(
api_client: TestClient,
coresys: CoreSys,
install_addon_example: Addon,
tmp_supervisor_data,
path_extern,
):
"""Test uninstall."""
install_addon_example.data["map"].append(
{"type": "addon_config", "read_only": False}
)
install_addon_example.path_config.mkdir()
(test_file := install_addon_example.path_config / "test.txt").touch()
resp = await api_client.post("/addons/local_example/uninstall")
assert resp.status == 200
assert not coresys.addons.get("local_example", local_only=True)
assert test_file.exists()
async def test_api_addon_uninstall_remove_config(
api_client: TestClient,
coresys: CoreSys,
install_addon_example: Addon,
tmp_supervisor_data,
path_extern,
):
"""Test uninstall and remove config."""
install_addon_example.data["map"].append(
{"type": "addon_config", "read_only": False}
)
(test_folder := install_addon_example.path_config).mkdir()
(install_addon_example.path_config / "test.txt").touch()
resp = await api_client.post(
"/addons/local_example/uninstall", json={"remove_config": True}
)
assert resp.status == 200
assert not coresys.addons.get("local_example", local_only=True)
assert not test_folder.exists()