Beispiel #1
0
async def test_setting_unique_id(
    hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_luftdaten: MagicMock
) -> None:
    """Test we set unique ID if not set yet."""
    mock_config_entry.unique_id = None
    mock_config_entry.add_to_hass(hass)

    await hass.config_entries.async_setup(mock_config_entry.entry_id)
    await hass.async_block_till_done()

    assert mock_config_entry.unique_id == "12345"
async def test_update_config_entry_unique_id(
    hass: HomeAssistant,
    mock_config_entry: MockConfigEntry,
    mock_twentemilieu: AsyncMock,
) -> None:
    """Test the we update old config entries with an unique ID."""
    mock_config_entry.unique_id = None
    mock_config_entry.add_to_hass(hass)

    await hass.config_entries.async_setup(mock_config_entry.entry_id)
    await hass.async_block_till_done()

    assert mock_config_entry.unique_id == "12345"