Beispiel #1
0
async def test_hap_reset_unloads_entry_if_setup():
    """Test calling reset while the entry has been setup."""
    hass = Mock()
    entry = Mock()
    home = Mock()
    home.disable_events = mock_coro_func()
    entry.data = {
        hmipc.HMIPC_HAPID: "ABC123",
        hmipc.HMIPC_AUTHTOKEN: "123",
        hmipc.HMIPC_NAME: "hmip",
    }
    hap = hmipc.HomematicipHAP(hass, entry)
    with patch.object(hap, "get_hap", return_value=mock_coro(home)):
        assert await hap.async_setup()

    assert hap.home is home
    assert not hass.services.async_register.mock_calls
    assert len(hass.config_entries.async_forward_entry_setup.mock_calls) == 8

    hass.config_entries.async_forward_entry_unload.return_value = mock_coro(
        True)
    await hap.async_reset()

    assert len(hass.config_entries.async_forward_entry_unload.mock_calls) == 8