diff --git a/tests/common.py b/tests/common.py index 8b33fe4c67d..78a4d9dbcfc 100644 --- a/tests/common.py +++ b/tests/common.py @@ -60,6 +60,7 @@ class CategoryTestData(TypedDict): + id: str repository: str category: str files: list[str] @@ -69,14 +70,15 @@ class CategoryTestData(TypedDict): _CATEGORY_TEST_DATA: tuple[CategoryTestData] = ( CategoryTestData( + id="1296265", category=HacsCategory.APPDAEMON, repository="hacs-test-org/appdaemon-basic", - id="appdaemon", files=["__init__.py", "example.py"], version_base="1.0.0", version_update="2.0.0", ), CategoryTestData( + id="1296269", category=HacsCategory.INTEGRATION, repository="hacs-test-org/integration-basic", files=["__init__.py", "manifest.json", "module/__init__.py"], @@ -84,6 +86,7 @@ class CategoryTestData(TypedDict): version_update="2.0.0", ), CategoryTestData( + id="1296267", category=HacsCategory.PLUGIN, repository="hacs-test-org/plugin-basic", files=["example.js", "example.js.gz"], @@ -91,6 +94,7 @@ class CategoryTestData(TypedDict): version_update="2.0.0", ), CategoryTestData( + id="1296262", category=HacsCategory.PYTHON_SCRIPT, repository="hacs-test-org/python_script-basic", files=["example.py"], @@ -98,6 +102,7 @@ class CategoryTestData(TypedDict): version_update="2.0.0", ), CategoryTestData( + id="1296268", category=HacsCategory.TEMPLATE, repository="hacs-test-org/template-basic", files=["example.jinja"], @@ -105,6 +110,7 @@ class CategoryTestData(TypedDict): version_update="2.0.0", ), CategoryTestData( + id="1296266", category=HacsCategory.THEME, repository="hacs-test-org/theme-basic", files=["example.yaml"], @@ -117,6 +123,7 @@ class CategoryTestData(TypedDict): def category_test_data_parametrized( *, xfail_categories: list[HacsCategory] | None = None, + categories: Iterable[HacsCategory] = [entry["category"] for entry in _CATEGORY_TEST_DATA], **kwargs, ): return ( @@ -128,6 +135,7 @@ def category_test_data_parametrized( id=entry["repository"], ) for entry in _CATEGORY_TEST_DATA + if entry["category"] in categories ) @@ -176,7 +184,8 @@ def _sort_list(entry): returndata[key] = value elif isinstance(value, dict): returndata[key] = recursive_remove_key( - {k: value[k] for k in sorted(value.keys())}, to_remove, + {k: value[k] for k in sorted(value.keys())}, + to_remove, ) elif isinstance(value, (list, set)): returndata[key] = [recursive_remove_key(item, to_remove) for item in _sort_list(value)] @@ -199,7 +208,8 @@ def fixture(filename, asjson=True): return json_func.loads(fptr.read()) return fptr.read() except OSError as err: - raise OSError(f"Missing fixture for {path.split('fixtures/')[1]}") from err + raise OSError(f"Missing fixture for { + path.split('fixtures/')[1]}") from err def dummy_repository_base(hacs, repository=None): @@ -590,18 +600,22 @@ async def mock_remove(store): """Remove data.""" data.pop(store.key, None) - with patch( - "homeassistant.helpers.storage.Store._async_load", - side_effect=mock_async_load, - autospec=True, - ), patch( - "homeassistant.helpers.storage.Store._write_data", - side_effect=mock_write_data, - autospec=True, - ), patch( - "homeassistant.helpers.storage.Store.async_remove", - side_effect=mock_remove, - autospec=True, + with ( + patch( + "homeassistant.helpers.storage.Store._async_load", + side_effect=mock_async_load, + autospec=True, + ), + patch( + "homeassistant.helpers.storage.Store._write_data", + side_effect=mock_write_data, + autospec=True, + ), + patch( + "homeassistant.helpers.storage.Store.async_remove", + side_effect=mock_remove, + autospec=True, + ), ): yield data @@ -665,7 +679,9 @@ async def _async_close_websession(event: ha.Event) -> None: self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_close_websession) self.client = await clientsession.ws_connect( - "ws://localhost:8123/api/websocket", timeout=1, autoclose=True, + "ws://localhost:8123/api/websocket", + timeout=1, + autoclose=True, ) auth_response = await self.client.receive_json() assert auth_response["type"] == "auth_required" @@ -735,7 +751,8 @@ def add(self, url: str, response: MockedResponse) -> None: def get(self, url: str, *args, **kwargs) -> MockedResponse: data = {"url": url, "args": list(args), "kwargs": kwargs} if (request := REQUEST_CONTEXT.get()) is not None: - data["_test_caller"] = f"{request.node.location[0]}::{request.node.name}" + data["_test_caller"] = f"{ + request.node.location[0]}::{request.node.name}" data["_uses_setup_integration"] = request.node.name != "test_integration_setup" and ( "setup_integration" in request.fixturenames or "hacs" in request.fixturenames ) @@ -760,7 +777,8 @@ async def _request(self, method: str, str_or_url: StrOrURL, *args, **kwargs): return resp url = URL(str_or_url) - fixture_file = f"fixtures/proxy/{url.host}{url.path}{'.json' if url.host in ('api.github.com', 'data-v2.hacs.xyz') and not url.path.endswith('.json') else ''}" + fixture_file = f"fixtures/proxy/{url.host}{url.path}{'.json' if url.host in ( + 'api.github.com', 'data-v2.hacs.xyz') and not url.path.endswith('.json') else ''}" fp = os.path.join( os.path.dirname(__file__), fixture_file, @@ -813,7 +831,8 @@ async def _request(method: str, str_or_url: StrOrURL, *args, **kwargs): return resp url = URL(str_or_url) - fixture_file = f"fixtures/proxy/{url.host}{url.path}{'.json' if url.host in ('api.github.com', 'data-v2.hacs.xyz') and not url.path.endswith('.json') else ''}" + fixture_file = f"fixtures/proxy/{url.host}{url.path}{'.json' if url.host in ( + 'api.github.com', 'data-v2.hacs.xyz') and not url.path.endswith('.json') else ''}" fp = os.path.join( os.path.dirname(__file__), fixture_file, @@ -851,7 +870,8 @@ async def json(**kwargs): def create_config_entry( - data: dict[str, Any] = None, options: dict[str, Any] = None, + data: dict[str, Any] = None, + options: dict[str, Any] = None, ) -> MockConfigEntry: return MockConfigEntry( version=1, @@ -868,7 +888,8 @@ def create_config_entry( async def setup_integration(hass: ha.HomeAssistant, config_entry: MockConfigEntry) -> None: mock_session = await client_session_proxy(hass) with patch( - "homeassistant.helpers.aiohttp_client.async_get_clientsession", return_value=mock_session, + "homeassistant.helpers.aiohttp_client.async_get_clientsession", + return_value=mock_session, ): hass.data.pop("custom_components", None) config_entry.add_to_hass(hass) diff --git a/tests/scripts/data/test_generate_category_data.py b/tests/scripts/data/test_generate_category_data.py index 1ac5ff4cffc..ea87f017a4d 100644 --- a/tests/scripts/data/test_generate_category_data.py +++ b/tests/scripts/data/test_generate_category_data.py @@ -1,5 +1,8 @@ """Test generate category data.""" + +import asyncio import json +from typing import Any from homeassistant.core import HomeAssistant import pytest @@ -25,6 +28,24 @@ } +def get_generated_category_data(category: str) -> dict[str, Any]: + """Get the generated data.""" + compare = {} + + with open(f"{OUTPUT_DIR}/{category}/data.json", encoding="utf-8") as file: + compare["data"] = recursive_remove_key( + json.loads(file.read()), ("last_fetched",)) + + with open(f"{OUTPUT_DIR}/{category}/repositories.json", encoding="utf-8") as file: + compare["repositories"] = recursive_remove_key( + json.loads(file.read()), ()) + + with open(f"{OUTPUT_DIR}/summary.json", encoding="utf-8") as file: + compare["summary"] = recursive_remove_key(json.loads(file.read()), ()) + + return compare + + @pytest.mark.parametrize("category_test_data", category_test_data_parametrized()) async def test_generate_category_data_single_repository( hass: HomeAssistant, @@ -105,3 +126,125 @@ async def test_generate_category_data( f"scripts/data/generate_category_data/{ category_test_data['category']}/summary.json", ) + + +@pytest.mark.parametrize("category_test_data", category_test_data_parametrized()) +async def test_generate_category_data_with_prior_content( + hass: HomeAssistant, + response_mocker: ResponseMocker, + snapshots: SnapshotFixture, + category_test_data: CategoryTestData, +): + """Test behaviour with prior content.""" + category_data = { + "integration": { + "domain": "example", + "manifest": {"name": "Proxy manifest"}, + "manifest_name": "Proxy manifest", + } + } + response_mocker.add( + f"https://data-v2.hacs.xyz/{category_test_data['category']}/data.json", + MockedResponse( + content={ + category_test_data["id"]: { + "description": "This your first repo!", + "downloads": 0, + "etag_repository": "321", + "full_name": category_test_data["repository"], + "last_updated": "2011-01-26T19:06:43Z", + "last_version": category_test_data["version_base"], + "stargazers_count": 0, + "topics": ["api", "atom", "electron", "octocat"], + **category_data.get(category_test_data["category"], {}), + } + } + ), + ) + + await generate_category_data(category_test_data["category"]) + + snapshots.assert_match( + safe_json_dumps(get_generated_category_data( + category_test_data["category"])), + f"scripts/data/test_generate_category_data_with_prior_content/{ + category_test_data['category']}.json", + ) + + +@pytest.mark.parametrize( + "category_test_data", category_test_data_parametrized( + categories=["integration"]) +) +@pytest.mark.parametrize("error", (asyncio.CancelledError, asyncio.TimeoutError, Exception("base"))) +async def test_generate_category_data_errors_release( + hass: HomeAssistant, + response_mocker: ResponseMocker, + snapshots: SnapshotFixture, + category_test_data: CategoryTestData, + error: Exception, + request: pytest.FixtureRequest, +): + """Test behaviour if single repository.""" + response_mocker.add( + f"https://api.github.com/repos/{ + category_test_data['repository']}/releases/latest", + MockedResponse(exception=error), + ) + await generate_category_data(category_test_data["category"]) + + snapshots.assert_match( + safe_json_dumps(get_generated_category_data( + category_test_data["category"])), + f"scripts/data/test_generate_category_data_errors_release/{ + category_test_data['category']}/{request.node.callspec.id.split("-")[0]}.json", + ) + + +@pytest.mark.parametrize( + "category_test_data", category_test_data_parametrized( + categories=["integration"]) +) +@pytest.mark.parametrize("status", (304, 404)) +async def test_generate_category_data_error_status_release( + hass: HomeAssistant, + response_mocker: ResponseMocker, + snapshots: SnapshotFixture, + category_test_data: CategoryTestData, + status: int, +): + """Test behaviour with error status and existing content.""" + response_mocker.add( + f"https://data-v2.hacs.xyz/{category_test_data['category']}/data.json", + MockedResponse( + content={ + category_test_data["id"]: { + "description": "This your first repo!", + "downloads": 0, + "etag_repository": "321", + "full_name": category_test_data["repository"], + "last_updated": "2011-01-26T19:06:43Z", + "last_version": category_test_data["version_base"], + "stargazers_count": 0, + "topics": ["api", "atom", "electron", "octocat"], + "domain": "example", + "manifest": {"name": "Proxy manifest"}, + "manifest_name": "Proxy manifest", + } + } + ), + ) + + response_mocker.add( + f"https://api.github.com/repos/{ + category_test_data['repository']}/releases/latest", + MockedResponse(status=status, content={}), + ) + await generate_category_data(category_test_data["category"]) + + snapshots.assert_match( + safe_json_dumps(get_generated_category_data( + category_test_data["category"])), + f"scripts/data/test_generate_category_data_error_status_release/{ + category_test_data['category']}/{status}.json", + ) diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-error-status-release-304-hacs-test-org-integration-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-error-status-release-304-hacs-test-org-integration-basic.json new file mode 100644 index 00000000000..b305d245f04 --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-error-status-release-304-hacs-test-org-integration-basic.json @@ -0,0 +1,19 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_error_status_release[304-hacs-test-org/integration-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/custom_components/example/manifest.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/hacs.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/integration": 1, + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/branches/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1, + "https://data-v2.hacs.xyz/integration/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-error-status-release-404-hacs-test-org-integration-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-error-status-release-404-hacs-test-org-integration-basic.json new file mode 100644 index 00000000000..7e83f52215a --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-error-status-release-404-hacs-test-org-integration-basic.json @@ -0,0 +1,20 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_error_status_release[404-hacs-test-org/integration-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/custom_components/example/manifest.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/hacs.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/integration": 1, + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/branches/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1, + "https://data-v2.hacs.xyz/integration/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-cancellederror-hacs-test-org-integration-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-cancellederror-hacs-test-org-integration-basic.json new file mode 100644 index 00000000000..d27b16a56ba --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-cancellederror-hacs-test-org-integration-basic.json @@ -0,0 +1,20 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_errors_release[CancelledError-hacs-test-org/integration-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/custom_components/example/manifest.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/hacs.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/integration": 1, + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/branches/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1, + "https://data-v2.hacs.xyz/integration/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-error2-hacs-test-org-integration-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-error2-hacs-test-org-integration-basic.json new file mode 100644 index 00000000000..0ee83cef143 --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-error2-hacs-test-org-integration-basic.json @@ -0,0 +1,20 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_errors_release[error2-hacs-test-org/integration-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/custom_components/example/manifest.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/hacs.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/integration": 1, + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/branches/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1, + "https://data-v2.hacs.xyz/integration/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-timeouterror-hacs-test-org-integration-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-timeouterror-hacs-test-org-integration-basic.json new file mode 100644 index 00000000000..5dd8713b70b --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-errors-release-timeouterror-hacs-test-org-integration-basic.json @@ -0,0 +1,20 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_errors_release[TimeoutError-hacs-test-org/integration-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/custom_components/example/manifest.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/hacs.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/integration": 1, + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/branches/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1, + "https://data-v2.hacs.xyz/integration/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-appdaemon-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-appdaemon-basic.json new file mode 100644 index 00000000000..2226c348df8 --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-appdaemon-basic.json @@ -0,0 +1,12 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_with_prior_content[hacs-test-org/appdaemon-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/appdaemon-basic": 1, + "https://api.github.com/repos/hacs-test-org/appdaemon-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/appdaemon-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/appdaemon-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/appdaemon": 1, + "https://data-v2.hacs.xyz/appdaemon/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-integration-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-integration-basic.json new file mode 100644 index 00000000000..45c7beb5fd5 --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-integration-basic.json @@ -0,0 +1,20 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_with_prior_content[hacs-test-org/integration-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/custom_components/example/manifest.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/contents/hacs.json": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic-custom/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/integration-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/integration": 1, + "https://api.github.com/repos/hacs/integration": 1, + "https://api.github.com/repos/hacs/integration/branches/main": 1, + "https://api.github.com/repos/hacs/integration/releases": 1, + "https://data-v2.hacs.xyz/integration/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-plugin-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-plugin-basic.json new file mode 100644 index 00000000000..29538ad9fc5 --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-plugin-basic.json @@ -0,0 +1,12 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_with_prior_content[hacs-test-org/plugin-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/plugin-basic": 1, + "https://api.github.com/repos/hacs-test-org/plugin-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/plugin-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/plugin-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/plugin": 1, + "https://data-v2.hacs.xyz/plugin/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-python-script-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-python-script-basic.json new file mode 100644 index 00000000000..72b87308af6 --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-python-script-basic.json @@ -0,0 +1,12 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_with_prior_content[hacs-test-org/python_script-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/python_script-basic": 1, + "https://api.github.com/repos/hacs-test-org/python_script-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/python_script-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/python_script-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/python_script": 1, + "https://data-v2.hacs.xyz/python_script/data.json": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-template-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-template-basic.json new file mode 100644 index 00000000000..2e085f9bf79 --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-template-basic.json @@ -0,0 +1,12 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_with_prior_content[hacs-test-org/template-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/template-basic": 1, + "https://api.github.com/repos/hacs-test-org/template-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/template-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/template-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/template": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1, + "https://data-v2.hacs.xyz/template/data.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-theme-basic.json b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-theme-basic.json new file mode 100644 index 00000000000..2d0be1e5d57 --- /dev/null +++ b/tests/snapshots/api-usage/tests/scripts/data/test_generate_category_datatest-generate-category-data-with-prior-content-hacs-test-org-theme-basic.json @@ -0,0 +1,12 @@ +{ + "tests/scripts/data/test_generate_category_data.py::test_generate_category_data_with_prior_content[hacs-test-org/theme-basic]": { + "https://api.github.com/rate_limit": 1, + "https://api.github.com/repos/hacs-test-org/theme-basic": 1, + "https://api.github.com/repos/hacs-test-org/theme-basic/git/trees/1.0.0": 1, + "https://api.github.com/repos/hacs-test-org/theme-basic/releases": 1, + "https://api.github.com/repos/hacs-test-org/theme-basic/releases/latest": 1, + "https://api.github.com/repos/hacs/default/contents/theme": 1, + "https://data-v2.hacs.xyz/removed/repositories.json": 1, + "https://data-v2.hacs.xyz/theme/data.json": 1 + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_error_status_release/integration/304.json b/tests/snapshots/scripts/data/test_generate_category_data_error_status_release/integration/304.json new file mode 100644 index 00000000000..8bb5ad3bd48 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_error_status_release/integration/304.json @@ -0,0 +1,66 @@ +{ + "data": { + "1296269": { + "description": "This your first repo!", + "domain": "example", + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + }, + "91296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic-custom", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/integration-basic", + "hacs-test-org/integration-basic-custom" + ], + "summary": { + "changed": 2, + "changed_pct": 100, + "current_count": 1, + "diff": 1, + "new_count": 2, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_error_status_release/integration/404.json b/tests/snapshots/scripts/data/test_generate_category_data_error_status_release/integration/404.json new file mode 100644 index 00000000000..9ca0e93dbf4 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_error_status_release/integration/404.json @@ -0,0 +1,67 @@ +{ + "data": { + "1296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + }, + "91296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic-custom", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/integration-basic", + "hacs-test-org/integration-basic-custom" + ], + "summary": { + "changed": 2, + "changed_pct": 100, + "current_count": 1, + "diff": 1, + "new_count": 2, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/CancelledError.json b/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/CancelledError.json new file mode 100644 index 00000000000..e7a7a634049 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/CancelledError.json @@ -0,0 +1,65 @@ +{ + "data": { + "1296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic", + "last_updated": "2020-01-20T09:34:52Z", + "last_version": "1.0.0", + "manifest": {}, + "manifest_name": "Basic integration", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + }, + "91296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic-custom", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/integration-basic", + "hacs-test-org/integration-basic-custom" + ], + "summary": { + "changed": 2, + "changed_pct": 100, + "current_count": 1, + "diff": 1, + "new_count": 2, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/TimeoutError.json b/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/TimeoutError.json new file mode 100644 index 00000000000..e7a7a634049 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/TimeoutError.json @@ -0,0 +1,65 @@ +{ + "data": { + "1296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic", + "last_updated": "2020-01-20T09:34:52Z", + "last_version": "1.0.0", + "manifest": {}, + "manifest_name": "Basic integration", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + }, + "91296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic-custom", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/integration-basic", + "hacs-test-org/integration-basic-custom" + ], + "summary": { + "changed": 2, + "changed_pct": 100, + "current_count": 1, + "diff": 1, + "new_count": 2, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/error2.json b/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/error2.json new file mode 100644 index 00000000000..e7a7a634049 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_errors_release/integration/error2.json @@ -0,0 +1,65 @@ +{ + "data": { + "1296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic", + "last_updated": "2020-01-20T09:34:52Z", + "last_version": "1.0.0", + "manifest": {}, + "manifest_name": "Basic integration", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + }, + "91296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic-custom", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/integration-basic", + "hacs-test-org/integration-basic-custom" + ], + "summary": { + "changed": 2, + "changed_pct": 100, + "current_count": 1, + "diff": 1, + "new_count": 2, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/appdaemon.json b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/appdaemon.json new file mode 100644 index 00000000000..f13f98e8854 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/appdaemon.json @@ -0,0 +1,41 @@ +{ + "data": { + "1296265": { + "description": "This your first repo!", + "etag_repository": "321", + "full_name": "hacs-test-org/appdaemon-basic", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": {}, + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/appdaemon-basic" + ], + "summary": { + "changed": 1, + "changed_pct": 100, + "current_count": 1, + "diff": 0, + "new_count": 1, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/integration.json b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/integration.json new file mode 100644 index 00000000000..9ca0e93dbf4 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/integration.json @@ -0,0 +1,67 @@ +{ + "data": { + "1296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + }, + "91296269": { + "description": "This your first repo!", + "domain": "example", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/integration-basic-custom", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": { + "name": "Proxy manifest" + }, + "manifest_name": "Proxy manifest", + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/integration-basic", + "hacs-test-org/integration-basic-custom" + ], + "summary": { + "changed": 2, + "changed_pct": 100, + "current_count": 1, + "diff": 1, + "new_count": 2, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/plugin.json b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/plugin.json new file mode 100644 index 00000000000..e3fb365d14b --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/plugin.json @@ -0,0 +1,41 @@ +{ + "data": { + "1296267": { + "description": "This your first repo!", + "etag_repository": "321", + "full_name": "hacs-test-org/plugin-basic", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": {}, + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/plugin-basic" + ], + "summary": { + "changed": 1, + "changed_pct": 100, + "current_count": 1, + "diff": 0, + "new_count": 1, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/python_script.json b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/python_script.json new file mode 100644 index 00000000000..678d01863d8 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/python_script.json @@ -0,0 +1,41 @@ +{ + "data": { + "1296262": { + "description": "This your first repo!", + "etag_repository": "321", + "full_name": "hacs-test-org/python_script-basic", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": {}, + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/python_script-basic" + ], + "summary": { + "changed": 1, + "changed_pct": 100, + "current_count": 1, + "diff": 0, + "new_count": 1, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/template.json b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/template.json new file mode 100644 index 00000000000..b8385e63a73 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/template.json @@ -0,0 +1,42 @@ +{ + "data": { + "1296268": { + "description": "This your first repo!", + "downloads": 42, + "etag_repository": "321", + "full_name": "hacs-test-org/template-basic", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": {}, + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/template-basic" + ], + "summary": { + "changed": 1, + "changed_pct": 100, + "current_count": 1, + "diff": 0, + "new_count": 1, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file diff --git a/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/theme.json b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/theme.json new file mode 100644 index 00000000000..3d5a47b8ac8 --- /dev/null +++ b/tests/snapshots/scripts/data/test_generate_category_data_with_prior_content/theme.json @@ -0,0 +1,41 @@ +{ + "data": { + "1296266": { + "description": "This your first repo!", + "etag_repository": "321", + "full_name": "hacs-test-org/theme-basic", + "last_updated": "2011-01-26T19:06:43Z", + "last_version": "1.0.0", + "manifest": {}, + "stargazers_count": 80, + "topics": [ + "api", + "atom", + "electron", + "octocat" + ] + } + }, + "repositories": [ + "hacs-test-org/theme-basic" + ], + "summary": { + "changed": 1, + "changed_pct": 100, + "current_count": 1, + "diff": 0, + "new_count": 1, + "rate_limit": { + "core": { + "limit": 5000, + "reset": 1691591363, + "used": 1 + }, + "graphql": { + "limit": 5000, + "reset": 1691593228, + "used": 7 + } + } + } +} \ No newline at end of file