'Test device connection using discovery.'

@mock.patch('homeassistant.helpers.discovery.load_platform')
@mock.patch('libpurecoollink.dyson.DysonAccount.devices', return_value=[_get_dyson_account_device_available()])
@mock.patch('libpurecoollink.dyson.DysonAccount.login', return_value=True)
def test_dyson_discovery(self, mocked_login, mocked_devices, mocked_discovery):

    dyson.setup(self.hass, {dyson.DOMAIN: {dyson.CONF_USERNAME: 'email', dyson.CONF_PASSWORD: 'password', dyson.CONF_LANGUAGE: 'FR', dyson.CONF_TIMEOUT: 5, dyson.CONF_RETRY: 2}})
    self.assertEqual(mocked_login.call_count, 1)
    self.assertEqual(mocked_devices.call_count, 1)
    self.assertEqual(len(self.hass.data[dyson.DYSON_DEVICES]), 1)
    self.assertEqual(mocked_discovery.call_count, 3)
