Repository: home-assistant/core
File: tests/components/hassio/test_init.py (Python)

Code before:
) -> None:
    """Test reload_mount with unknown device ID."""
    await mount_reload_test_setup(hass, device_registry, supervisor_client)
    with pytest.raises(ServiceValidationError) as exc:
        await hass.services.async_call(
            "hassio", "mount_reload", {"device_id": "1234"}, blocking=True
        )
    assert str(exc.value) == "Device ID not found: 1234"


async def test_mount_reload_unnamed_device(
    hass: HomeAssistant,
    device_registry: dr.DeviceRegistry,
    supervisor_client: AsyncMock,
) -> None:
    """Test reload_mount with unnamed device."""
    device = await mount_reload_test_setup(hass, device_registry, supervisor_client)
    device_registry.async_update_device(device.id, name=None)
    with pytest.raises(ServiceValidationError) as exc:
        await hass.services.async_call(
            "hassio", "mount_reload", {"device_id": device.id}, blocking=True
        )
    assert str(exc.value) == f"Device is unnamed: {device.id}"


async def test_mount_reload_selector_not_translated(
    hass: HomeAssistant,
    device_registry: dr.DeviceRegistry,
    supervisor_client: AsyncMock,
) -> None:
    """Test that the model name in the selector of mount reload is valid."""
    device = await mount_reload_test_setup(hass, device_registry, supervisor_client)
    services = load_yaml_dict(f"{hassio.__path__[0]}/services.yaml")
    assert (
        services["mount_reload"]["fields"]["device_id"]["selector"]["device"]["filter"][
            "model"
        ]
        == device.model
    )


Review comment (suggestion):
```suggestion
async def test_mount_reload_selector_matches_device_name(
```

Code after:
async def test_mount_reload_unknown_device_id(
    hass: HomeAssistant,
    device_registry: dr.DeviceRegistry,
    supervisor_client: AsyncMock,
) -> None:
    """Test reload_mount with unknown device ID."""
    await mount_reload_test_setup(hass, device_registry, supervisor_client)
    with pytest.raises(ServiceValidationError) as exc:
        await hass.services.async_call(
            "hassio", "mount_reload", {"device_id": "1234"}, blocking=True
        )
    assert str(exc.value) == "Device ID not found"


async def test_mount_reload_no_name(
    hass: HomeAssistant,
    device_registry: dr.DeviceRegistry,
    supervisor_client: AsyncMock,
) -> None:
    """Test reload_mount with an unnamed device."""
    device = await mount_reload_test_setup(hass, device_registry, supervisor_client)
    device_registry.async_update_device(device.id, name=None)
    with pytest.raises(ServiceValidationError) as exc:
        await hass.services.async_call(
            "hassio", "mount_reload", {"device_id": device.id}, blocking=True
        )
    assert str(exc.value) == "Device is not a supervisor mount point"


async def test_mount_reload_invalid_model(
    hass: HomeAssistant,
    device_registry: dr.DeviceRegistry,
    supervisor_client: AsyncMock,
) -> None:
    """Test reload_mount with an invalid model."""
    device = await mount_reload_test_setup(hass, device_registry, supervisor_client)
    device_registry.async_update_device(device.id, model=None)
    with pytest.raises(ServiceValidationError) as exc:
        await hass.services.async_call(
            "hassio", "mount_reload", {"device_id": device.id}, blocking=True
        )
    assert str(exc.value) == "Device is not a supervisor mount point"


async def test_mount_reload_not_supervisor_device(
    hass: HomeAssistant,
    device_registry: dr.DeviceRegistry,
    supervisor_client: AsyncMock,
) -> None:
    """Test reload_mount with a device not belonging to the supervisor."""
    device = await mount_reload_test_setup(hass, device_registry, supervisor_client)