async def test_flow_aborts_configuration_updated(hass, aioclient_mock):
    'Test config flow aborts since a connected config entry already exists.'
    entry = MockConfigEntry(domain=UNIFI_DOMAIN, data={'controller': {'host': '1.2.3.4', 'site': 'office'}})
    entry.add_to_hass(hass)
    entry = MockConfigEntry(domain=UNIFI_DOMAIN, data={'controller': {'host': '1.2.3.4', 'site': 'site_id'}})
    entry.add_to_hass(hass)
    result = (await hass.config_entries.flow.async_init(UNIFI_DOMAIN, context={'source': 'user'}))
    assert (result['type'] == data_entry_flow.RESULT_TYPE_FORM)
    assert (result['step_id'] == 'user')
    aioclient_mock.get('https://1.2.3.4:1234', status=302)
    aioclient_mock.post('https://1.2.3.4:1234/api/login', json={'data': 'login successful', 'meta': {'rc': 'ok'}}, headers={'content-type': CONTENT_TYPE_JSON})
    aioclient_mock.get('https://1.2.3.4:1234/api/self/sites', json={'data': [{'desc': 'Site name', 'name': 'site_id', 'role': 'admin'}], 'meta': {'rc': 'ok'}}, headers={'content-type': CONTENT_TYPE_JSON})
    with patch('homeassistant.components.unifi.async_setup_entry'):
        result = (await hass.config_entries.flow.async_configure(result['flow_id'], user_input={CONF_HOST: '1.2.3.4', CONF_USERNAME: 'username', CONF_PASSWORD: 'password', CONF_PORT: 1234, CONF_VERIFY_SSL: True}))
    assert (result['type'] == data_entry_flow.RESULT_TYPE_ABORT)
    assert (result['reason'] == 'configuration_updated')
Test config flow aborts since a connected config entry already exists.
async def test_flow_aborts_configuration_updated(hass, aioclient_mock):
    
    entry = MockConfigEntry(domain=UNIFI_DOMAIN, data={'controller': {'host': '1.2.3.4', 'site': 'office'}})
    entry.add_to_hass(hass)
    entry = MockConfigEntry(domain=UNIFI_DOMAIN, data={'controller': {'host': '1.2.3.4', 'site': 'site_id'}})
    entry.add_to_hass(hass)
    result = (await hass.config_entries.flow.async_init(UNIFI_DOMAIN, context={'source': 'user'}))
    assert (result['type'] == data_entry_flow.RESULT_TYPE_FORM)
    assert (result['step_id'] == 'user')
    aioclient_mock.get('https://1.2.3.4:1234', status=302)
    aioclient_mock.post('https://1.2.3.4:1234/api/login', json={'data': 'login successful', 'meta': {'rc': 'ok'}}, headers={'content-type': CONTENT_TYPE_JSON})
    aioclient_mock.get('https://1.2.3.4:1234/api/self/sites', json={'data': [{'desc': 'Site name', 'name': 'site_id', 'role': 'admin'}], 'meta': {'rc': 'ok'}}, headers={'content-type': CONTENT_TYPE_JSON})
    with patch('homeassistant.components.unifi.async_setup_entry'):
        result = (await hass.config_entries.flow.async_configure(result['flow_id'], user_input={CONF_HOST: '1.2.3.4', CONF_USERNAME: 'username', CONF_PASSWORD: 'password', CONF_PORT: 1234, CONF_VERIFY_SSL: True}))
    assert (result['type'] == data_entry_flow.RESULT_TYPE_ABORT)
    assert (result['reason'] == 'configuration_updated')