async def test_flow_works(hass, aioclient_mock, mock_discovery):
    'Test config flow.'
    mock_discovery.return_value = '1'
    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')
    assert (result['data_schema']({CONF_USERNAME: '', CONF_PASSWORD: ''}) == {CONF_HOST: 'unifi', CONF_USERNAME: '', CONF_PASSWORD: '', CONF_PORT: 443, CONF_VERIFY_SSL: False})
    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})
    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_CREATE_ENTRY)
    assert (result['title'] == 'Site name')
    assert (result['data'] == {CONF_CONTROLLER: {CONF_HOST: '1.2.3.4', CONF_USERNAME: 'username', CONF_PASSWORD: 'password', CONF_PORT: 1234, CONF_SITE_ID: 'site_id', CONF_VERIFY_SSL: True}})
Test config flow.
async def test_flow_works(hass, aioclient_mock, mock_discovery):
    
    mock_discovery.return_value = '1'
    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')
    assert (result['data_schema']({CONF_USERNAME: , CONF_PASSWORD: }) == {CONF_HOST: 'unifi', CONF_USERNAME: , CONF_PASSWORD: , CONF_PORT: 443, CONF_VERIFY_SSL: False})
    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})
    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_CREATE_ENTRY)
    assert (result['title'] == 'Site name')
    assert (result['data'] == {CONF_CONTROLLER: {CONF_HOST: '1.2.3.4', CONF_USERNAME: 'username', CONF_PASSWORD: 'password', CONF_PORT: 1234, CONF_SITE_ID: 'site_id', CONF_VERIFY_SSL: True}})