mirror of
https://github.com/home-assistant/core.git
synced 2025-06-28 00:47:10 +00:00
Add handling for RoborockTooFrequentCodeRequests
for roborock integration (#123759)
* Add handling for RoborockTooFrequentCodeRequests * Add tests for coverage
This commit is contained in:
parent
d8cbb3540f
commit
097162eceb
@ -12,6 +12,7 @@ from roborock.exceptions import (
|
||||
RoborockException,
|
||||
RoborockInvalidCode,
|
||||
RoborockInvalidEmail,
|
||||
RoborockTooFrequentCodeRequests,
|
||||
RoborockUrlException,
|
||||
)
|
||||
from roborock.web_api import RoborockApiClient
|
||||
@ -83,6 +84,8 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
errors["base"] = "unknown_url"
|
||||
except RoborockInvalidEmail:
|
||||
errors["base"] = "invalid_email_format"
|
||||
except RoborockTooFrequentCodeRequests:
|
||||
errors["base"] = "too_frequent_code_requests"
|
||||
except RoborockException:
|
||||
_LOGGER.exception("Unexpected exception")
|
||||
errors["base"] = "unknown_roborock"
|
||||
|
@ -22,6 +22,7 @@
|
||||
"invalid_code": "The code you entered was incorrect, please check it and try again.",
|
||||
"invalid_email": "There is no account associated with the email you entered, please try again.",
|
||||
"invalid_email_format": "There is an issue with the formatting of your email - please try again.",
|
||||
"too_frequent_code_requests": "You have attempted to request too many codes. Try again later.",
|
||||
"unknown_roborock": "There was an unknown roborock exception - please check your logs.",
|
||||
"unknown_url": "There was an issue determining the correct url for your roborock account - please check your logs.",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
|
@ -4,6 +4,7 @@ from copy import deepcopy
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from roborock import RoborockTooFrequentCodeRequests
|
||||
from roborock.exceptions import (
|
||||
RoborockAccountDoesNotExist,
|
||||
RoborockException,
|
||||
@ -71,6 +72,7 @@ async def test_config_flow_success(
|
||||
(RoborockException(), {"base": "unknown_roborock"}),
|
||||
(RoborockAccountDoesNotExist(), {"base": "invalid_email"}),
|
||||
(RoborockInvalidEmail(), {"base": "invalid_email_format"}),
|
||||
(RoborockTooFrequentCodeRequests(), {"base": "too_frequent_code_requests"}),
|
||||
(RoborockUrlException(), {"base": "unknown_url"}),
|
||||
(Exception(), {"base": "unknown"}),
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user