From 92ef8a0042ecf4522d3f119588df2a18bd8f2211 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 6 Jul 2025 07:25:18 +0000 Subject: [PATCH 1/7] Initial plan From 6b9d77a4e5324c99d04437fdaece84a7b3558d77 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 6 Jul 2025 07:35:47 +0000 Subject: [PATCH 2/7] Fix HACS unresponsive issue with null safety and unload fixes Co-authored-by: ludeeus <15093472+ludeeus@users.noreply.github.com> --- custom_components/hacs/__init__.py | 9 +++---- custom_components/hacs/switch.py | 6 ++++- custom_components/hacs/update.py | 6 ++++- .../hacs/websocket/repositories.py | 24 +++++++++++++++++++ 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/custom_components/hacs/__init__.py b/custom_components/hacs/__init__.py index 6af3f8fc839..07622b8fdd9 100644 --- a/custom_components/hacs/__init__.py +++ b/custom_components/hacs/__init__.py @@ -214,10 +214,11 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> unload_ok = await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS) - hacs.set_stage(None) - hacs.disable_hacs(HacsDisabledReason.REMOVED) - - hass.data.pop(DOMAIN, None) + # Only clean up if unload was successful + if unload_ok: + hacs.set_stage(None) + hacs.disable_hacs(HacsDisabledReason.REMOVED) + hass.data.pop(DOMAIN, None) return unload_ok diff --git a/custom_components/hacs/switch.py b/custom_components/hacs/switch.py index 4fa43d4e35f..80f18ce5276 100644 --- a/custom_components/hacs/switch.py +++ b/custom_components/hacs/switch.py @@ -22,7 +22,11 @@ async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Setup switch platform.""" - hacs: HacsBase = hass.data[DOMAIN] + hacs: HacsBase = hass.data.get(DOMAIN) + if hacs is None: + # HACS is not properly initialized + return + async_add_entities( HacsRepositoryPreReleaseSwitchEntity(hacs=hacs, repository=repository) for repository in hacs.repositories.list_downloaded diff --git a/custom_components/hacs/update.py b/custom_components/hacs/update.py index ec4014302db..bfcf832589b 100644 --- a/custom_components/hacs/update.py +++ b/custom_components/hacs/update.py @@ -21,7 +21,11 @@ async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: """Setup update platform.""" - hacs: HacsBase = hass.data[DOMAIN] + hacs: HacsBase = hass.data.get(DOMAIN) + if hacs is None: + # HACS is not properly initialized + return + async_add_entities( HacsRepositoryUpdateEntity(hacs=hacs, repository=repository) for repository in hacs.repositories.list_downloaded diff --git a/custom_components/hacs/websocket/repositories.py b/custom_components/hacs/websocket/repositories.py index 879f68af8da..4d5dc6b3d57 100644 --- a/custom_components/hacs/websocket/repositories.py +++ b/custom_components/hacs/websocket/repositories.py @@ -35,6 +35,11 @@ async def hacs_repositories_list( ) -> None: """List repositories.""" hacs: HacsBase = hass.data.get(DOMAIN) + if hacs is None: + # HACS is not properly initialized, return empty list + connection.send_message(websocket_api.result_message(msg["id"], [])) + return + connection.send_message( websocket_api.result_message( msg["id"], @@ -92,6 +97,10 @@ async def hacs_repositories_clear_new( ) -> None: """Clear new repositories for specific categories.""" hacs: HacsBase = hass.data.get(DOMAIN) + if hacs is None: + # HACS is not properly initialized + connection.send_message(websocket_api.result_message(msg["id"])) + return if repo := msg.get("repository"): repository = hacs.repositories.get_by_id(repo) @@ -124,6 +133,11 @@ async def hacs_repositories_removed( ) -> None: """Get information about removed repositories.""" hacs: HacsBase = hass.data.get(DOMAIN) + if hacs is None: + # HACS is not properly initialized, return empty list + connection.send_message(websocket_api.result_message(msg["id"], [])) + return + content = [] for repo in hacs.repositories.list_removed: if repo.repository not in hacs.common.ignored_repositories: @@ -147,6 +161,11 @@ async def hacs_repositories_add( ) -> None: """Add custom repositoriy.""" hacs: HacsBase = hass.data.get(DOMAIN) + if hacs is None: + # HACS is not properly initialized + connection.send_message(websocket_api.result_message(msg["id"], {})) + return + repository = regex.extract_repository_from_url(msg["repository"]) category = msg["category"] @@ -208,6 +227,11 @@ async def hacs_repositories_remove( ) -> None: """Remove custom repositoriy.""" hacs: HacsBase = hass.data.get(DOMAIN) + if hacs is None: + # HACS is not properly initialized + connection.send_message(websocket_api.result_message(msg["id"], {})) + return + repository = hacs.repositories.get_by_id(msg["repository"]) repository.remove() From de5a2c18b13de900afb14dea1c1855fe47ae911b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 6 Jul 2025 08:55:59 +0000 Subject: [PATCH 3/7] Use walrus operator for HACS null checks Co-authored-by: ludeeus <15093472+ludeeus@users.noreply.github.com> --- custom_components/hacs/switch.py | 3 +-- custom_components/hacs/update.py | 3 +-- custom_components/hacs/websocket/repositories.py | 15 +++++---------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/custom_components/hacs/switch.py b/custom_components/hacs/switch.py index 80f18ce5276..074097267a9 100644 --- a/custom_components/hacs/switch.py +++ b/custom_components/hacs/switch.py @@ -22,8 +22,7 @@ async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Setup switch platform.""" - hacs: HacsBase = hass.data.get(DOMAIN) - if hacs is None: + if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized return diff --git a/custom_components/hacs/update.py b/custom_components/hacs/update.py index bfcf832589b..4b5ef6747a3 100644 --- a/custom_components/hacs/update.py +++ b/custom_components/hacs/update.py @@ -21,8 +21,7 @@ async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: """Setup update platform.""" - hacs: HacsBase = hass.data.get(DOMAIN) - if hacs is None: + if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized return diff --git a/custom_components/hacs/websocket/repositories.py b/custom_components/hacs/websocket/repositories.py index 4d5dc6b3d57..49290414482 100644 --- a/custom_components/hacs/websocket/repositories.py +++ b/custom_components/hacs/websocket/repositories.py @@ -34,8 +34,7 @@ async def hacs_repositories_list( msg: dict[str, Any], ) -> None: """List repositories.""" - hacs: HacsBase = hass.data.get(DOMAIN) - if hacs is None: + if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized, return empty list connection.send_message(websocket_api.result_message(msg["id"], [])) return @@ -96,8 +95,7 @@ async def hacs_repositories_clear_new( msg: dict[str, Any], ) -> None: """Clear new repositories for specific categories.""" - hacs: HacsBase = hass.data.get(DOMAIN) - if hacs is None: + if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized connection.send_message(websocket_api.result_message(msg["id"])) return @@ -132,8 +130,7 @@ async def hacs_repositories_removed( msg: dict[str, Any], ) -> None: """Get information about removed repositories.""" - hacs: HacsBase = hass.data.get(DOMAIN) - if hacs is None: + if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized, return empty list connection.send_message(websocket_api.result_message(msg["id"], [])) return @@ -160,8 +157,7 @@ async def hacs_repositories_add( msg: dict[str, Any], ) -> None: """Add custom repositoriy.""" - hacs: HacsBase = hass.data.get(DOMAIN) - if hacs is None: + if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized connection.send_message(websocket_api.result_message(msg["id"], {})) return @@ -226,8 +222,7 @@ async def hacs_repositories_remove( msg: dict[str, Any], ) -> None: """Remove custom repositoriy.""" - hacs: HacsBase = hass.data.get(DOMAIN) - if hacs is None: + if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized connection.send_message(websocket_api.result_message(msg["id"], {})) return From d280f759a577a23d3a8e8d24d68e63e940877fb8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 6 Jul 2025 09:04:43 +0000 Subject: [PATCH 4/7] Send websocket errors instead of empty responses when HACS not initialized Co-authored-by: ludeeus <15093472+ludeeus@users.noreply.github.com> --- custom_components/hacs/websocket/repositories.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/custom_components/hacs/websocket/repositories.py b/custom_components/hacs/websocket/repositories.py index 49290414482..654c0147cf3 100644 --- a/custom_components/hacs/websocket/repositories.py +++ b/custom_components/hacs/websocket/repositories.py @@ -35,8 +35,8 @@ async def hacs_repositories_list( ) -> None: """List repositories.""" if (hacs := hass.data.get(DOMAIN)) is None: - # HACS is not properly initialized, return empty list - connection.send_message(websocket_api.result_message(msg["id"], [])) + # HACS is not properly initialized + connection.send_error(msg["id"], "hacs_not_initialized", "HACS is not properly initialized") return connection.send_message( @@ -97,7 +97,7 @@ async def hacs_repositories_clear_new( """Clear new repositories for specific categories.""" if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized - connection.send_message(websocket_api.result_message(msg["id"])) + connection.send_error(msg["id"], "hacs_not_initialized", "HACS is not properly initialized") return if repo := msg.get("repository"): @@ -131,8 +131,8 @@ async def hacs_repositories_removed( ) -> None: """Get information about removed repositories.""" if (hacs := hass.data.get(DOMAIN)) is None: - # HACS is not properly initialized, return empty list - connection.send_message(websocket_api.result_message(msg["id"], [])) + # HACS is not properly initialized + connection.send_error(msg["id"], "hacs_not_initialized", "HACS is not properly initialized") return content = [] @@ -159,7 +159,7 @@ async def hacs_repositories_add( """Add custom repositoriy.""" if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized - connection.send_message(websocket_api.result_message(msg["id"], {})) + connection.send_error(msg["id"], "hacs_not_initialized", "HACS is not properly initialized") return repository = regex.extract_repository_from_url(msg["repository"]) @@ -224,7 +224,7 @@ async def hacs_repositories_remove( """Remove custom repositoriy.""" if (hacs := hass.data.get(DOMAIN)) is None: # HACS is not properly initialized - connection.send_message(websocket_api.result_message(msg["id"], {})) + connection.send_error(msg["id"], "hacs_not_initialized", "HACS is not properly initialized") return repository = hacs.repositories.get_by_id(msg["repository"]) From 091e19c152b6e5b115ac908060f3a3c13a47452e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 6 Jul 2025 09:44:51 +0000 Subject: [PATCH 5/7] Add comprehensive tests for websocket repositories commands when HACS not initialized Co-authored-by: ludeeus <15093472+ludeeus@users.noreply.github.com> --- tests/websocket/__init__.py | 1 + .../test_repositories_not_initialized.py | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 tests/websocket/__init__.py create mode 100644 tests/websocket/test_repositories_not_initialized.py diff --git a/tests/websocket/__init__.py b/tests/websocket/__init__.py new file mode 100644 index 00000000000..779b4c6eefd --- /dev/null +++ b/tests/websocket/__init__.py @@ -0,0 +1 @@ +"""Tests for websocket when HACS is not initialized.""" \ No newline at end of file diff --git a/tests/websocket/test_repositories_not_initialized.py b/tests/websocket/test_repositories_not_initialized.py new file mode 100644 index 00000000000..b3fd5911f15 --- /dev/null +++ b/tests/websocket/test_repositories_not_initialized.py @@ -0,0 +1,61 @@ +"""Tests for websocket repositories commands when HACS is not initialized.""" + +from collections.abc import Generator + +from homeassistant.core import HomeAssistant +import pytest + +from custom_components.hacs.const import DOMAIN + +from tests.common import WSClient, get_hacs + + +@pytest.mark.parametrize( + "command,payload", + [ + ("hacs/repositories/list", {}), + ("hacs/repositories/list", {"categories": ["integration"]}), + ("hacs/repositories/clear_new", {}), + ("hacs/repositories/clear_new", {"categories": ["plugin"]}), + ("hacs/repositories/clear_new", {"repository": "test/repo"}), + ("hacs/repositories/removed", {}), + ("hacs/repositories/add", {"repository": "test/repo", "category": "integration"}), + ("hacs/repositories/remove", {"repository": "123"}), + ], +) +async def test_websocket_repositories_commands_hacs_not_initialized( + hass: HomeAssistant, + ws_client: WSClient, + command: str, + payload: dict, +): + """Test that websocket repository commands return proper errors when HACS is not initialized.""" + # Ensure HACS is not in hass.data (not initialized) + hass.data.pop(DOMAIN, None) + + # Send websocket command + response = await ws_client.send_and_receive_json(command, payload) + + # Verify error response + assert response["success"] is False + assert response["error"]["code"] == "hacs_not_initialized" + assert response["error"]["message"] == "HACS is not properly initialized" + + +async def test_websocket_repositories_list_with_hacs_initialized( + hass: HomeAssistant, + setup_integration: Generator, # This sets up HACS properly + ws_client: WSClient, +): + """Test that websocket works normally when HACS is properly initialized.""" + # Verify HACS is properly initialized + hacs = get_hacs(hass) + assert hacs is not None + + # Send websocket command - should work normally + response = await ws_client.send_and_receive_json("hacs/repositories/list", {}) + + # Verify successful response (should be a list, not an error) + assert response["success"] is True + assert "result" in response + assert isinstance(response["result"], list) \ No newline at end of file From 4719b3cd9a9af93f5821763afa552b1556282702 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 6 Jul 2025 18:34:33 +0000 Subject: [PATCH 6/7] lint --- tests/websocket/__init__.py | 2 +- tests/websocket/test_repositories_not_initialized.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/websocket/__init__.py b/tests/websocket/__init__.py index 779b4c6eefd..4a2523bdf36 100644 --- a/tests/websocket/__init__.py +++ b/tests/websocket/__init__.py @@ -1 +1 @@ -"""Tests for websocket when HACS is not initialized.""" \ No newline at end of file +"""Tests for websocket when HACS is not initialized.""" diff --git a/tests/websocket/test_repositories_not_initialized.py b/tests/websocket/test_repositories_not_initialized.py index b3fd5911f15..eca7a0ac1eb 100644 --- a/tests/websocket/test_repositories_not_initialized.py +++ b/tests/websocket/test_repositories_not_initialized.py @@ -32,10 +32,10 @@ async def test_websocket_repositories_commands_hacs_not_initialized( """Test that websocket repository commands return proper errors when HACS is not initialized.""" # Ensure HACS is not in hass.data (not initialized) hass.data.pop(DOMAIN, None) - + # Send websocket command response = await ws_client.send_and_receive_json(command, payload) - + # Verify error response assert response["success"] is False assert response["error"]["code"] == "hacs_not_initialized" @@ -51,11 +51,11 @@ async def test_websocket_repositories_list_with_hacs_initialized( # Verify HACS is properly initialized hacs = get_hacs(hass) assert hacs is not None - + # Send websocket command - should work normally response = await ws_client.send_and_receive_json("hacs/repositories/list", {}) - + # Verify successful response (should be a list, not an error) assert response["success"] is True assert "result" in response - assert isinstance(response["result"], list) \ No newline at end of file + assert isinstance(response["result"], list) From a018177a2296215937ae687d73603fa642d1d2d9 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 6 Jul 2025 18:54:17 +0000 Subject: [PATCH 7/7] Fix test --- ...s-not-initialized-hacs-repositories-add-payload6.json | 9 +++++++++ ...initialized-hacs-repositories-clear-new-payload2.json | 9 +++++++++ ...initialized-hacs-repositories-clear-new-payload3.json | 9 +++++++++ ...initialized-hacs-repositories-clear-new-payload4.json | 9 +++++++++ ...-not-initialized-hacs-repositories-list-payload0.json | 9 +++++++++ ...-not-initialized-hacs-repositories-list-payload1.json | 9 +++++++++ ...ot-initialized-hacs-repositories-remove-payload7.json | 9 +++++++++ ...t-initialized-hacs-repositories-removed-payload5.json | 9 +++++++++ ...ebsocket-repositories-list-with-hacs-initialized.json | 9 +++++++++ tests/websocket/test_repositories_not_initialized.py | 1 + 10 files changed, 82 insertions(+) create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-add-payload6.json create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload2.json create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload3.json create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload4.json create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-list-payload0.json create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-list-payload1.json create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-remove-payload7.json create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-removed-payload5.json create mode 100644 tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-list-with-hacs-initialized.json diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-add-payload6.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-add-payload6.json new file mode 100644 index 00000000000..2f33378e257 --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-add-payload6.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_commands_hacs_not_initialized[hacs/repositories/add-payload6]": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload2.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload2.json new file mode 100644 index 00000000000..3d692793a2a --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload2.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_commands_hacs_not_initialized[hacs/repositories/clear_new-payload2]": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload3.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload3.json new file mode 100644 index 00000000000..37955416cb0 --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload3.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_commands_hacs_not_initialized[hacs/repositories/clear_new-payload3]": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload4.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload4.json new file mode 100644 index 00000000000..75a371d0951 --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-clear-new-payload4.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_commands_hacs_not_initialized[hacs/repositories/clear_new-payload4]": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-list-payload0.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-list-payload0.json new file mode 100644 index 00000000000..29cd6df6af0 --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-list-payload0.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_commands_hacs_not_initialized[hacs/repositories/list-payload0]": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-list-payload1.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-list-payload1.json new file mode 100644 index 00000000000..51724ba2f52 --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-list-payload1.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_commands_hacs_not_initialized[hacs/repositories/list-payload1]": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-remove-payload7.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-remove-payload7.json new file mode 100644 index 00000000000..8994eec4a1b --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-remove-payload7.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_commands_hacs_not_initialized[hacs/repositories/remove-payload7]": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-removed-payload5.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-removed-payload5.json new file mode 100644 index 00000000000..3d3d5acc590 --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-commands-hacs-not-initialized-hacs-repositories-removed-payload5.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_commands_hacs_not_initialized[hacs/repositories/removed-payload5]": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-list-with-hacs-initialized.json b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-list-with-hacs-initialized.json new file mode 100644 index 00000000000..aece5f4f773 --- /dev/null +++ b/tests/snapshots/api-usage/tests/websocket/test_repositories_not_initializedtest-websocket-repositories-list-with-hacs-initialized.json @@ -0,0 +1,9 @@ +{ + "tests/websocket/test_repositories_not_initialized.py::test_websocket_repositories_list_with_hacs_initialized": { + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1, + "https://api.github.com/repos/hacs/integration/contents/hacs.json": 1, + "https://api.github.com/repos/hacs/integration/git/trees/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1 + } +} \ No newline at end of file diff --git a/tests/websocket/test_repositories_not_initialized.py b/tests/websocket/test_repositories_not_initialized.py index eca7a0ac1eb..23262dc1528 100644 --- a/tests/websocket/test_repositories_not_initialized.py +++ b/tests/websocket/test_repositories_not_initialized.py @@ -25,6 +25,7 @@ ) async def test_websocket_repositories_commands_hacs_not_initialized( hass: HomeAssistant, + setup_integration: Generator, # Need this to register websocket commands ws_client: WSClient, command: str, payload: dict,