Hardware integration MVP (#71677)
This commit is contained in:
parent
f166fc009a
commit
2bc093a04d
22 changed files with 535 additions and 3 deletions
|
@ -20,8 +20,19 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
|||
MOCK_ENVIRON = {"HASSIO": "127.0.0.1", "HASSIO_TOKEN": "abcdefgh"}
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def os_info():
|
||||
"""Mock os/info."""
|
||||
return {
|
||||
"json": {
|
||||
"result": "ok",
|
||||
"data": {"version_latest": "1.0.0", "version": "1.0.0"},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_all(aioclient_mock, request):
|
||||
def mock_all(aioclient_mock, request, os_info):
|
||||
"""Mock all setup requests."""
|
||||
aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"})
|
||||
aioclient_mock.get("http://127.0.0.1/supervisor/ping", json={"result": "ok"})
|
||||
|
@ -64,7 +75,7 @@ def mock_all(aioclient_mock, request):
|
|||
)
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/os/info",
|
||||
json={"result": "ok", "data": {"version_latest": "1.0.0", "version": "1.0.0"}},
|
||||
**os_info,
|
||||
)
|
||||
aioclient_mock.get(
|
||||
"http://127.0.0.1/supervisor/info",
|
||||
|
@ -701,3 +712,29 @@ async def test_coordinator_updates(hass, caplog):
|
|||
)
|
||||
assert refresh_updates_mock.call_count == 1
|
||||
assert "Error on Supervisor API: Unknown" in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"os_info",
|
||||
[
|
||||
{
|
||||
"json": {
|
||||
"result": "ok",
|
||||
"data": {"version_latest": "1.0.0", "version": "1.0.0", "board": "rpi"},
|
||||
}
|
||||
}
|
||||
],
|
||||
)
|
||||
async def test_setup_hardware_integration(hass, aioclient_mock):
|
||||
"""Test setup initiates hardware integration."""
|
||||
|
||||
with patch.dict(os.environ, MOCK_ENVIRON), patch(
|
||||
"homeassistant.components.raspberry_pi.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
result = await async_setup_component(hass, "hassio", {"hassio": {}})
|
||||
assert result
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert aioclient_mock.call_count == 15
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue