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

Don't remove add-on repos if add-on is installed (#3364)

This commit is contained in:
Joakim Sørensen
2021-12-14 21:04:31 +01:00
committed by GitHub
parent eadc629cd9
commit 5503f93a75
3 changed files with 29 additions and 3 deletions

View File

@@ -1,10 +1,13 @@
{
"advanced": false,
"arch": ["amd64"],
"arch": [
"amd64"
],
"slug": "test",
"description": "Test add-on",
"location": "tmp_path",
"name": "Test Add-on",
"repository": "https://github.com/awesome-developer/awesome-repo",
"repository": "a474bbd1",
"stage": "stable",
"version": "1.0.0"
}

View File

@@ -4,6 +4,8 @@ from unittest.mock import patch
import pytest
from supervisor.addons.addon import Addon
from supervisor.exceptions import StoreError
from supervisor.resolution.const import SuggestionType
from supervisor.store import BUILTIN_REPOSITORIES
@@ -72,3 +74,17 @@ async def test_preinstall_valid_repository(coresys, store_manager):
await store_manager.update_repositories(BUILTIN_REPOSITORIES)
assert store_manager.get("core").validate()
assert store_manager.get("local").validate()
@pytest.mark.asyncio
async def test_remove_used_repository(coresys, store_manager, store_addon):
"""Test removing used custom repository."""
coresys.addons.data.install(store_addon)
addon = Addon(coresys, store_addon.slug)
coresys.addons.local[addon.slug] = addon
with pytest.raises(
StoreError,
match="Can't remove 'https://github.com/awesome-developer/awesome-repo'. It's used by installed add-ons",
):
await store_manager.update_repositories([])