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

Code before:
    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_model_not_translated(
    hass: HomeAssistant,
    device_registry: dr.DeviceRegistry,
    supervisor_client: AsyncMock,
) -> None:
    """Test that mount's model is not translated since it's used by services.yaml."""
    device = await mount_reload_test_setup(hass, device_registry, supervisor_client)
    assert str(device.model) == "Home Assistant Mount"


Review comment (suggestion):
I don't think this test really works, at least not as a guard against translations, because language is set to English in CI.

I'd modify the test function name and docstring to convey it guards against changes to the model name.
Also, I think you should load the `services.yaml` file and check like this:

```py
services = yaml.load_yaml_dict(f"{hassio.__path__}/services.yaml")
assert services["mount_reload"]["fields"]["device_id"]["selector"]["device"]["filter"]["model"] == device.model
```



Code after:
    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)
    config_entry = MockConfigEntry()
    config_entry.add_to_hass(hass)
    device2 = device_registry.async_get_or_create(
        config_entry_id=config_entry.entry_id,
        identifiers={("test", "test")},
        name=device.name,