hass-core/tests/components/diagnostics/__init__.py
Raman Gupta 8b3fe0a2d9
Add support for device diagnostics (#64344)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-01-19 20:48:32 -08:00

26 lines
931 B
Python

"""Tests for the Diagnostics integration."""
from http import HTTPStatus
from homeassistant.setup import async_setup_component
async def get_diagnostics_for_config_entry(hass, hass_client, config_entry):
"""Return the diagnostics config entry for the specified domain."""
assert await async_setup_component(hass, "diagnostics", {})
client = await hass_client()
response = await client.get(
f"/api/diagnostics/config_entry/{config_entry.entry_id}"
)
assert response.status == HTTPStatus.OK
return await response.json()
async def get_diagnostics_for_device(hass, hass_client, config_entry, device):
"""Return the diagnostics for the specified device."""
client = await hass_client()
response = await client.get(
f"/api/diagnostics/config_entry/{config_entry.entry_id}/device/{device.id}"
)
assert response.status == HTTPStatus.OK
return await response.json()