Hardware integration MVP (#71677)
This commit is contained in:
parent
f166fc009a
commit
2bc093a04d
22 changed files with 535 additions and 3 deletions
57
tests/components/raspberry_pi/test_hardware.py
Normal file
57
tests/components/raspberry_pi/test_hardware.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
"""Test the Raspberry Pi hardware platform."""
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.hassio import DATA_OS_INFO
|
||||
from homeassistant.components.raspberry_pi.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockModule, mock_integration
|
||||
|
||||
|
||||
async def test_hardware_info(hass: HomeAssistant, hass_ws_client) -> None:
|
||||
"""Test we can get the board info."""
|
||||
mock_integration(hass, MockModule("hassio"))
|
||||
hass.data[DATA_OS_INFO] = {"board": "rpi"}
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
client = await hass_ws_client(hass)
|
||||
|
||||
await client.send_json({"id": 1, "type": "hardware/info"})
|
||||
msg = await client.receive_json()
|
||||
|
||||
assert msg["id"] == 1
|
||||
assert msg["success"]
|
||||
assert msg["result"] == {
|
||||
"hardware": [
|
||||
{
|
||||
"board": {
|
||||
"hassio_board_id": "rpi",
|
||||
"manufacturer": "raspberry_pi",
|
||||
"model": "1",
|
||||
"revision": None,
|
||||
},
|
||||
"name": "Raspberry Pi",
|
||||
"url": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("os_info", [None, {"board": None}, {"board": "other"}])
|
||||
async def test_hardware_info_fail(hass: HomeAssistant, hass_ws_client, os_info) -> None:
|
||||
"""Test async_info raises if os_info is not as expected."""
|
||||
mock_integration(hass, MockModule("hassio"))
|
||||
hass.data[DATA_OS_INFO] = os_info
|
||||
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
||||
client = await hass_ws_client(hass)
|
||||
|
||||
await client.send_json({"id": 1, "type": "hardware/info"})
|
||||
msg = await client.receive_json()
|
||||
|
||||
assert msg["id"] == 1
|
||||
assert msg["success"]
|
||||
assert msg["result"] == {"hardware": []}
|
Loading…
Add table
Add a link
Reference in a new issue