async def test_setup_starts_discovery( hass: HomeAssistant, mock_ufp_config_entry: ConfigEntry, mock_client ): """Test setting up will start discovery.""" with _patch_discovery(), patch( "homeassistant.components.unifiprotect.ProtectApiClient" ) as mock_api: mock_ufp_config_entry.add_to_hass(hass) mock_api.return_value = mock_client mock_entry = MockEntityFixture(mock_ufp_config_entry, mock_client) await hass.config_entries.async_setup(mock_entry.entry.entry_id) await hass.async_block_till_done() assert mock_entry.entry.state == ConfigEntryState.LOADED await hass.async_block_till_done() assert len(hass.config_entries.flow.async_progress_by_handler(DOMAIN)) == 1
async def get_mock_hap( hass: HomeAssistantType, mock_connection, hmip_config_entry: config_entries.ConfigEntry, ) -> HomematicipHAP: """Create a mocked homematic access point.""" home_name = hmip_config_entry.data["name"] mock_home = (HomeTemplate( connection=mock_connection, home_name=home_name).init_home().get_async_home_mock()) hmip_config_entry.add_to_hass(hass) with patch( "homeassistant.components.homematicip_cloud.hap.HomematicipHAP.get_hap", return_value=mock_home, ): assert await async_setup_component(hass, HMIPC_DOMAIN, {}) is True await hass.async_block_till_done() hap = hass.data[HMIPC_DOMAIN][HAPID] mock_home.on_update(hap.async_update) mock_home.on_create(hap.async_create_entity) return hap