|
4 | 4 | from copy import deepcopy |
5 | 5 | from unittest.mock import AsyncMock, MagicMock, patch |
6 | 6 |
|
7 | | -from pylamarzocco.const import ModelName |
| 7 | +from pylamarzocco.const import DeviceType, ModelName |
8 | 8 | from pylamarzocco.exceptions import AuthFail, RequestNotSuccessful |
| 9 | +from pylamarzocco.models import Thing |
9 | 10 | import pytest |
10 | 11 |
|
11 | 12 | from homeassistant.components.lamarzocco.config_flow import CONF_MACHINE |
|
35 | 36 | get_bluetooth_service_info, |
36 | 37 | ) |
37 | 38 |
|
38 | | -from tests.common import MockConfigEntry |
| 39 | +from tests.common import MockConfigEntry, async_load_json_object_fixture |
39 | 40 |
|
40 | 41 |
|
41 | 42 | @pytest.fixture(autouse=True) |
@@ -197,6 +198,30 @@ async def test_form_no_machines( |
197 | 198 | await __do_sucessful_machine_selection_step(hass, result) |
198 | 199 |
|
199 | 200 |
|
| 201 | +async def test_grinders_not_configurable( |
| 202 | + hass: HomeAssistant, |
| 203 | + mock_cloud_client: MagicMock, |
| 204 | +) -> None: |
| 205 | + """Test that grinders are filtered out so only machines can be configured.""" |
| 206 | + grinder = await async_load_json_object_fixture(hass, "thing.json", DOMAIN) |
| 207 | + grinder["type"] = DeviceType.GRINDER |
| 208 | + grinder["serialNumber"] = "GR012345" |
| 209 | + grinder["name"] = "GR012345" |
| 210 | + |
| 211 | + mock_cloud_client.list_things.return_value = [ |
| 212 | + *mock_cloud_client.list_things.return_value, |
| 213 | + Thing.from_dict(grinder), |
| 214 | + ] |
| 215 | + |
| 216 | + result = await hass.config_entries.flow.async_init( |
| 217 | + DOMAIN, context={"source": SOURCE_USER} |
| 218 | + ) |
| 219 | + result = await __do_successful_user_step(hass, result, mock_cloud_client) |
| 220 | + |
| 221 | + options = result["data_schema"].schema[CONF_MACHINE].config["options"] |
| 222 | + assert [option["value"] for option in options] == ["GS012345"] |
| 223 | + |
| 224 | + |
200 | 225 | async def test_reauth_flow( |
201 | 226 | hass: HomeAssistant, |
202 | 227 | mock_cloud_client: MagicMock, |
|
0 commit comments