1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-27 20:23:58 +01:00

Add custom integrations to analytics (#48753)

This commit is contained in:
Joakim Sørensen
2021-04-07 04:33:08 +02:00
committed by GitHub
parent 89f2f458d2
commit 191c01a611
3 changed files with 30 additions and 3 deletions

View File

@@ -14,8 +14,9 @@ from homeassistant.components.analytics.const import (
ATTR_USAGE,
)
from homeassistant.components.api import ATTR_UUID
from homeassistant.const import __version__ as HA_VERSION
from homeassistant.const import ATTR_DOMAIN, __version__ as HA_VERSION
from homeassistant.loader import IntegrationNotFound
from homeassistant.setup import async_setup_component
MOCK_UUID = "abcdefg"
@@ -319,3 +320,16 @@ async def test_reusing_uuid(hass, aioclient_mock):
await analytics.send_analytics()
assert analytics.uuid == "NOT_MOCK_UUID"
async def test_custom_integrations(hass, aioclient_mock):
"""Test sending custom integrations."""
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
analytics = Analytics(hass)
assert await async_setup_component(hass, "test_package", {"test_package": {}})
await analytics.save_preferences({ATTR_BASE: True, ATTR_USAGE: True})
await analytics.send_analytics()
payload = aioclient_mock.mock_calls[0][2]
assert payload["custom_integrations"][0][ATTR_DOMAIN] == "test_package"