Skip to content

Commit

Permalink
Add music assistant to the builtin repositories (#5128)
Browse files Browse the repository at this point in the history
* Add music assistant to the builtin repositories

* Fix tests

* Fix tests some more

---------

Co-authored-by: Stefan Agner <[email protected]>
  • Loading branch information
pvizeli and agners authored Jun 21, 2024
1 parent ca7f3e8 commit c37b5ef
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
2 changes: 2 additions & 0 deletions supervisor/store/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

URL_COMMUNITY_ADDONS = "https://github.com/hassio-addons/repository"
URL_ESPHOME = "https://github.com/esphome/home-assistant-addon"
URL_MUSIC_ASSISTANT = "https://github.com/music-assistant/home-assistant-addon"
BUILTIN_REPOSITORIES = {
StoreType.CORE,
StoreType.LOCAL,
URL_COMMUNITY_ADDONS,
URL_ESPHOME,
URL_MUSIC_ASSISTANT,
}

# pylint: disable=no-value-for-parameter
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/addons/git/d5369777/repository.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Music Assistant",
"url": "https://github.com/music-assistant/core",
"maintainer": "Music Assistant <[email protected]>"
}
1 change: 1 addition & 0 deletions tests/store/test_custom_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ async def test_preinstall_valid_repository(
assert store_manager.get("local").validate()
assert store_manager.get("a0d7b954").validate()
assert store_manager.get("5c53de3b").validate()
assert store_manager.get("d5369777").validate()


@pytest.mark.parametrize("use_update", [True, False])
Expand Down
29 changes: 21 additions & 8 deletions tests/store/test_store_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,23 @@ async def mock_refresh_cache(obj: AddonStore):
):
await store_manager.load()

assert len(store_manager.all) == 4
assert len(store_manager.all) == 5
assert isinstance(store_manager.get("core"), Repository)
assert isinstance(store_manager.get("local"), Repository)

assert len(store_manager.repository_urls) == 2
assert len(store_manager.repository_urls) == 3
assert (
"https://github.com/hassio-addons/repository" in store_manager.repository_urls
)
assert (
"https://github.com/esphome/home-assistant-addon"
in store_manager.repository_urls
)
assert (
"https://github.com/music-assistant/home-assistant-addon"
in store_manager.repository_urls
)
# NOTE: When adding new stores, make sure to add it to tests/fixtures/addons/git/
assert refresh_cache_calls == {"local_ssh", "local_example", "core_samba"}


Expand All @@ -77,18 +82,22 @@ async def mock_refresh_cache(_):
):
await store_manager.load()

assert len(store_manager.all) == 5
assert len(store_manager.all) == 6
assert isinstance(store_manager.get("core"), Repository)
assert isinstance(store_manager.get("local"), Repository)

assert len(store_manager.repository_urls) == 3
assert len(store_manager.repository_urls) == 4
assert (
"https://github.com/hassio-addons/repository" in store_manager.repository_urls
)
assert (
"https://github.com/esphome/home-assistant-addon"
in store_manager.repository_urls
)
assert (
"https://github.com/music-assistant/home-assistant-addon"
in store_manager.repository_urls
)
assert "http://example.com" in store_manager.repository_urls


Expand All @@ -105,18 +114,22 @@ async def test_load_from_core_config(coresys: CoreSys):
), patch("pathlib.Path.exists", return_value=True):
await coresys.store.load()

assert len(coresys.store.all) == 5
assert len(coresys.store.all) == 6
assert isinstance(coresys.store.get("core"), Repository)
assert isinstance(coresys.store.get("local"), Repository)

assert len(coresys.store.repository_urls) == 3
assert len(coresys.store.repository_urls) == 4
assert (
"https://github.com/hassio-addons/repository" in coresys.store.repository_urls
)
assert (
"https://github.com/esphome/home-assistant-addon"
in coresys.store.repository_urls
)
assert (
"https://github.com/music-assistant/home-assistant-addon"
in coresys.store.repository_urls
)
assert "http://example.com" in coresys.store.repository_urls

assert coresys.config.addons_repositories == []
Expand Down Expand Up @@ -243,12 +256,12 @@ async def test_install_unavailable_addon(
async def test_reload(coresys: CoreSys):
"""Test store reload."""
await coresys.store.load()
assert len(coresys.store.all) == 4
assert len(coresys.store.all) == 5

with patch.object(GitRepo, "pull") as git_pull:
await coresys.store.reload()

assert git_pull.call_count == 3
assert git_pull.call_count == 4


async def test_addon_version_timestamp(coresys: CoreSys, install_addon_example: Addon):
Expand Down
3 changes: 2 additions & 1 deletion tests/store/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ async def test_repository_validate(repo_list: list[str], valid: bool):
"""Test repository list validate."""
if valid:
processed = repositories(repo_list)
assert len(processed) == 4
assert len(processed) == 5
assert set(repositories(repo_list)) == {
"core",
"local",
"https://github.com/hassio-addons/repository",
"https://github.com/esphome/home-assistant-addon",
"https://github.com/music-assistant/home-assistant-addon",
}
else:
with pytest.raises(Invalid):
Expand Down

0 comments on commit c37b5ef

Please sign in to comment.