hass-core/tests/components/diagnostics/__init__.py
Raman Gupta 11d0dcf7ac
Add zwave_js device diagnostics (#64504)
* Add zwave_js device diagnostics

* Add diagnostics as a dependency in manifest

* Add failure scenario test

* fix device diagnostics helper and remove dependency

* tweak
2022-01-20 11:49:24 +01:00

28 lines
996 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."""
assert await async_setup_component(hass, "diagnostics", {})
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()