How to use the pybotvac.exceptions.NeatoLoginException function in pybotvac

To help you get started, we’ve selected a few pybotvac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / tests / components / neato / test_config_flow.py View on Github external
async def test_abort_on_invalid_credentials(hass):
    """Test when we have invalid credentials."""
    flow = init_config_flow(hass)

    with patch(
        "homeassistant.components.neato.config_flow.Account",
        side_effect=NeatoLoginException(),
    ):
        result = await flow.async_step_user(
            {
                CONF_USERNAME: USERNAME,
                CONF_PASSWORD: PASSWORD,
                CONF_VENDOR: VENDOR_NEATO,
            }
        )
        assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
        assert result["errors"] == {"base": "invalid_credentials"}

        result = await flow.async_step_import(
            {
                CONF_USERNAME: USERNAME,
                CONF_PASSWORD: PASSWORD,
                CONF_VENDOR: VENDOR_NEATO,
github home-assistant / home-assistant / tests / components / neato / test_init.py View on Github external
async def test_config_entries_not_in_sync_error(hass):
    """The config entry and configuration.yaml are not in sync, the new configuration is wrong."""
    MockConfigEntry(domain=NEATO_DOMAIN, data=VALID_CONFIG).add_to_hass(hass)

    assert hass.config_entries.async_entries(NEATO_DOMAIN)
    with patch(
        "homeassistant.components.neato.config_flow.Account",
        side_effect=NeatoLoginException(),
    ):
        assert not await async_setup_component(
            hass, NEATO_DOMAIN, {NEATO_DOMAIN: DIFFERENT_CONFIG}
        )
    await hass.async_block_till_done()

    entries = hass.config_entries.async_entries(NEATO_DOMAIN)
    assert entries
    assert entries[0].data[CONF_USERNAME] == USERNAME
    assert entries[0].data[CONF_PASSWORD] == PASSWORD
    assert entries[0].data[CONF_VENDOR] == VENDOR_NEATO
github home-assistant / home-assistant / homeassistant / components / neato / __init__.py View on Github external
def login(self):
        """Login to My Neato."""
        _LOGGER.debug("Trying to connect to Neato API")
        try:
            self.my_neato = self._neato(
                self.config[CONF_USERNAME], self.config[CONF_PASSWORD], self._vendor
            )
        except NeatoException as ex:
            if isinstance(ex, NeatoLoginException):
                _LOGGER.error("Invalid credentials")
            else:
                _LOGGER.error("Unable to connect to Neato API")
            self.logged_in = False
            return

        self.logged_in = True
        _LOGGER.debug("Successfully connected to Neato API")
github stianaske / pybotvac / pybotvac / account.py View on Github external
try:
            response = requests.post(urljoin(self._endpoint, 'sessions'),
                                    json={'email': email,
                                        'password': password,
                                        'platform': 'ios',
                                        'token': binascii.hexlify(os.urandom(64)).decode('utf8')},
                                    headers=self._headers)

            response.raise_for_status()
            access_token = response.json()['access_token']

            self._headers['Authorization'] = 'Token token=%s' % access_token
        except (requests.exceptions.ConnectionError,
                requests.exceptions.HTTPError) as ex:
            if isinstance(ex, requests.exceptions.HTTPError) and ex.response.status_code == 403:
                raise NeatoLoginException("Unable to login to neato, check account credentials.")
            else:
                raise NeatoRobotException("Unable to connect to Neato API.")
github dshokouhi / hass-neato-custom-component / neato / config_flow.py View on Github external
def try_login(username, password, vendor):
        """Try logging in to device and return any errors."""
        this_vendor = None
        if vendor == "vorwerk":
            this_vendor = Vorwerk()
        else:  # Neato
            this_vendor = Neato()

        try:
            Account(username, password, this_vendor)
        except NeatoLoginException:
            return "invalid_credentials"
        except NeatoRobotException:
            return "unexpected_error"

        return None
github home-assistant / home-assistant / homeassistant / components / neato / config_flow.py View on Github external
def try_login(username, password, vendor):
        """Try logging in to device and return any errors."""
        this_vendor = None
        if vendor == "vorwerk":
            this_vendor = Vorwerk()
        else:  # Neato
            this_vendor = Neato()

        try:
            Account(username, password, this_vendor)
        except NeatoLoginException:
            return "invalid_credentials"
        except NeatoRobotException:
            return "unexpected_error"

        return None
github dshokouhi / hass-neato-custom-component / neato / __init__.py View on Github external
def login(self):
        """Login to My Neato."""
        _LOGGER.debug("Trying to connect to Neato API")
        try:
            self.my_neato = self._neato(
                self.config[CONF_USERNAME], self.config[CONF_PASSWORD], self._vendor
            )
        except NeatoException as ex:
            if isinstance(ex, NeatoLoginException):
                _LOGGER.error("Invalid credentials")
            else:
                _LOGGER.error("Unable to connect to Neato API")
                raise ConfigEntryNotReady
            self.logged_in = False
            return

        self.logged_in = True
        _LOGGER.debug("Successfully connected to Neato API")

pybotvac

Python package for controlling Neato pybotvac Connected vacuum robot

MIT
Latest version published 8 months ago

Package Health Score

56 / 100
Full package analysis

Similar packages