mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Remove unused function otbr.async_get_active_dataset_tlvs (#124210)
This commit is contained in:
parent
8907b7e911
commit
96edaebdd3
@ -81,16 +81,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
"""Handle an options update."""
|
"""Handle an options update."""
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
await hass.config_entries.async_reload(entry.entry_id)
|
||||||
|
|
||||||
|
|
||||||
async def async_get_active_dataset_tlvs(hass: HomeAssistant) -> bytes | None:
|
|
||||||
"""Get current active operational dataset in TLVS format, or None.
|
|
||||||
|
|
||||||
Returns None if there is no active operational dataset.
|
|
||||||
Raises if the http status is 400 or higher or if the response is invalid.
|
|
||||||
"""
|
|
||||||
if DOMAIN not in hass.data:
|
|
||||||
raise HomeAssistantError("OTBR API not available")
|
|
||||||
|
|
||||||
data: OTBRData = hass.data[DOMAIN]
|
|
||||||
return await data.get_active_dataset_tlvs()
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""Test the Open Thread Border Router integration."""
|
"""Test the Open Thread Border Router integration."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from http import HTTPStatus
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import ANY, AsyncMock, MagicMock, patch
|
from unittest.mock import ANY, AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
@ -13,7 +12,6 @@ from zeroconf.asyncio import AsyncServiceInfo
|
|||||||
from homeassistant.components import otbr, thread
|
from homeassistant.components import otbr, thread
|
||||||
from homeassistant.components.thread import discovery
|
from homeassistant.components.thread import discovery
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
|
||||||
from homeassistant.helpers import issue_registry as ir
|
from homeassistant.helpers import issue_registry as ir
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
@ -346,78 +344,9 @@ async def test_remove_entry(
|
|||||||
|
|
||||||
aioclient_mock.get(f"{BASE_URL}/node/dataset/active", text="0E")
|
aioclient_mock.get(f"{BASE_URL}/node/dataset/active", text="0E")
|
||||||
|
|
||||||
assert await otbr.async_get_active_dataset_tlvs(hass) == bytes.fromhex("0E")
|
|
||||||
|
|
||||||
config_entry = hass.config_entries.async_entries(otbr.DOMAIN)[0]
|
config_entry = hass.config_entries.async_entries(otbr.DOMAIN)[0]
|
||||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
|
||||||
assert await otbr.async_get_active_dataset_tlvs(hass)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_get_active_dataset_tlvs(
|
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, otbr_config_entry_multipan
|
|
||||||
) -> None:
|
|
||||||
"""Test async_get_active_dataset_tlvs."""
|
|
||||||
|
|
||||||
mock_response = (
|
|
||||||
"0E080000000000010000000300001035060004001FFFE00208F642646DA209B1C00708FDF57B5A"
|
|
||||||
"0FE2AAF60510DE98B5BA1A528FEE049D4B4B01835375030D4F70656E5468726561642048410102"
|
|
||||||
"25A40410F5DD18371BFD29E1A601EF6FFAD94C030C0402A0F7F8"
|
|
||||||
)
|
|
||||||
|
|
||||||
aioclient_mock.get(f"{BASE_URL}/node/dataset/active", text=mock_response)
|
|
||||||
|
|
||||||
assert await otbr.async_get_active_dataset_tlvs(hass) == bytes.fromhex(
|
|
||||||
mock_response
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_get_active_dataset_tlvs_empty(
|
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, otbr_config_entry_multipan
|
|
||||||
) -> None:
|
|
||||||
"""Test async_get_active_dataset_tlvs."""
|
|
||||||
|
|
||||||
aioclient_mock.get(f"{BASE_URL}/node/dataset/active", status=HTTPStatus.NO_CONTENT)
|
|
||||||
assert await otbr.async_get_active_dataset_tlvs(hass) is None
|
|
||||||
|
|
||||||
|
|
||||||
async def test_get_active_dataset_tlvs_addon_not_installed(hass: HomeAssistant) -> None:
|
|
||||||
"""Test async_get_active_dataset_tlvs when the multi-PAN addon is not installed."""
|
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
|
||||||
await otbr.async_get_active_dataset_tlvs(hass)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_get_active_dataset_tlvs_404(
|
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, otbr_config_entry_multipan
|
|
||||||
) -> None:
|
|
||||||
"""Test async_get_active_dataset_tlvs with error."""
|
|
||||||
|
|
||||||
aioclient_mock.get(f"{BASE_URL}/node/dataset/active", status=HTTPStatus.NOT_FOUND)
|
|
||||||
with pytest.raises(HomeAssistantError):
|
|
||||||
await otbr.async_get_active_dataset_tlvs(hass)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_get_active_dataset_tlvs_201(
|
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, otbr_config_entry_multipan
|
|
||||||
) -> None:
|
|
||||||
"""Test async_get_active_dataset_tlvs with error."""
|
|
||||||
|
|
||||||
aioclient_mock.get(f"{BASE_URL}/node/dataset/active", status=HTTPStatus.CREATED)
|
|
||||||
with pytest.raises(HomeAssistantError):
|
|
||||||
assert await otbr.async_get_active_dataset_tlvs(hass)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_get_active_dataset_tlvs_invalid(
|
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, otbr_config_entry_multipan
|
|
||||||
) -> None:
|
|
||||||
"""Test async_get_active_dataset_tlvs with error."""
|
|
||||||
|
|
||||||
aioclient_mock.get(f"{BASE_URL}/node/dataset/active", text="unexpected")
|
|
||||||
with pytest.raises(HomeAssistantError):
|
|
||||||
assert await otbr.async_get_active_dataset_tlvs(hass)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_remove_extra_entries(
|
async def test_remove_extra_entries(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||||
|
Loading…
x
Reference in New Issue
Block a user