Add recorder engine name and version to analytics (#87784)

* Add recorder to analytics

* Add test

* Add recorder to after_dependencies

* Add version

* dialect can not be None
This commit is contained in:
Joakim Sørensen 2023-02-13 09:18:12 +01:00 committed by GitHub
parent 9008556457
commit e842f90767
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 1 deletions

View file

@ -576,3 +576,22 @@ async def test_send_usage_with_certificate(
await analytics.send_analytics()
assert "'certificate': True" in caplog.text
async def test_send_with_recorder(
recorder_mock: AsyncMock,
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Test recorder information."""
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
analytics = Analytics(hass)
hass.http = Mock(ssl_certificate="/some/path/to/cert.pem")
await analytics.save_preferences({ATTR_BASE: True, ATTR_USAGE: True})
with patch("homeassistant.components.analytics.analytics.HA_VERSION", MOCK_VERSION):
await analytics.send_analytics()
postdata = aioclient_mock.mock_calls[-1][2]
assert postdata["recorder"]["engine"] == "sqlite"