Skip to content

Commit 3939a80

Browse files
authored
Switch Roborock to v4 of the code login api (home-assistant#153593)
1 parent d32a102 commit 3939a80

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

homeassistant/components/roborock/config_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def _request_code(self) -> dict:
8282
assert self._client
8383
errors: dict[str, str] = {}
8484
try:
85-
await self._client.request_code()
85+
await self._client.request_code_v4()
8686
except RoborockAccountDoesNotExist:
8787
errors["base"] = "invalid_email"
8888
except RoborockUrlException:
@@ -111,7 +111,7 @@ async def async_step_code(
111111
code = user_input[CONF_ENTRY_CODE]
112112
_LOGGER.debug("Logging into Roborock account using email provided code")
113113
try:
114-
user_data = await self._client.code_login(code)
114+
user_data = await self._client.code_login_v4(code)
115115
except RoborockInvalidCode:
116116
errors["base"] = "invalid_code"
117117
except RoborockException:

tests/components/roborock/test_config_flow.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def test_config_flow_success(
4646
assert result["type"] is FlowResultType.FORM
4747
assert result["step_id"] == "user"
4848
with patch(
49-
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
49+
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code_v4"
5050
):
5151
result = await hass.config_entries.flow.async_configure(
5252
result["flow_id"], {CONF_USERNAME: USER_EMAIL}
@@ -56,7 +56,7 @@ async def test_config_flow_success(
5656
assert result["step_id"] == "code"
5757
assert result["errors"] == {}
5858
with patch(
59-
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
59+
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login_v4",
6060
return_value=USER_DATA,
6161
):
6262
result = await hass.config_entries.flow.async_configure(
@@ -101,7 +101,7 @@ async def test_config_flow_failures_request_code(
101101
assert result["type"] is FlowResultType.FORM
102102
assert result["step_id"] == "user"
103103
with patch(
104-
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code",
104+
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code_v4",
105105
side_effect=request_code_side_effect,
106106
):
107107
result = await hass.config_entries.flow.async_configure(
@@ -111,7 +111,7 @@ async def test_config_flow_failures_request_code(
111111
assert result["errors"] == request_code_errors
112112
# Recover from error
113113
with patch(
114-
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
114+
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code_v4"
115115
):
116116
result = await hass.config_entries.flow.async_configure(
117117
result["flow_id"], {CONF_USERNAME: USER_EMAIL}
@@ -121,7 +121,7 @@ async def test_config_flow_failures_request_code(
121121
assert result["step_id"] == "code"
122122
assert result["errors"] == {}
123123
with patch(
124-
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
124+
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login_v4",
125125
return_value=USER_DATA,
126126
):
127127
result = await hass.config_entries.flow.async_configure(
@@ -163,7 +163,7 @@ async def test_config_flow_failures_code_login(
163163
assert result["type"] is FlowResultType.FORM
164164
assert result["step_id"] == "user"
165165
with patch(
166-
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
166+
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code_v4"
167167
):
168168
result = await hass.config_entries.flow.async_configure(
169169
result["flow_id"], {CONF_USERNAME: USER_EMAIL}
@@ -174,7 +174,7 @@ async def test_config_flow_failures_code_login(
174174
assert result["errors"] == {}
175175
# Raise exception for invalid code
176176
with patch(
177-
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
177+
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login_v4",
178178
side_effect=code_login_side_effect,
179179
):
180180
result = await hass.config_entries.flow.async_configure(
@@ -183,7 +183,7 @@ async def test_config_flow_failures_code_login(
183183
assert result["type"] is FlowResultType.FORM
184184
assert result["errors"] == code_login_errors
185185
with patch(
186-
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
186+
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login_v4",
187187
return_value=USER_DATA,
188188
):
189189
result = await hass.config_entries.flow.async_configure(
@@ -236,7 +236,7 @@ async def test_reauth_flow(
236236
# Request a new code
237237
with (
238238
patch(
239-
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
239+
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code_v4"
240240
),
241241
patch("homeassistant.components.roborock.async_setup_entry", return_value=True),
242242
):
@@ -250,7 +250,7 @@ async def test_reauth_flow(
250250
new_user_data.rriot.s = "new_password_hash"
251251
with (
252252
patch(
253-
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
253+
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login_v4",
254254
return_value=new_user_data,
255255
),
256256
patch("homeassistant.components.roborock.async_setup_entry", return_value=True),
@@ -280,7 +280,7 @@ async def test_account_already_configured(
280280
assert result["type"] is FlowResultType.FORM
281281
assert result["step_id"] == "user"
282282
with patch(
283-
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
283+
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code_v4"
284284
):
285285
result = await hass.config_entries.flow.async_configure(
286286
result["flow_id"], {CONF_USERNAME: USER_EMAIL}
@@ -289,7 +289,7 @@ async def test_account_already_configured(
289289
assert result["step_id"] == "code"
290290
assert result["type"] is FlowResultType.FORM
291291
with patch(
292-
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
292+
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login_v4",
293293
return_value=USER_DATA,
294294
):
295295
result = await hass.config_entries.flow.async_configure(
@@ -313,7 +313,7 @@ async def test_reauth_wrong_account(
313313
"homeassistant.components.roborock.async_setup_entry", return_value=True
314314
):
315315
with patch(
316-
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
316+
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code_v4"
317317
):
318318
result = await hass.config_entries.flow.async_configure(
319319
result["flow_id"], {CONF_USERNAME: USER_EMAIL}
@@ -324,7 +324,7 @@ async def test_reauth_wrong_account(
324324
new_user_data = deepcopy(USER_DATA)
325325
new_user_data.rruid = "new_rruid"
326326
with patch(
327-
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
327+
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login_v4",
328328
return_value=new_user_data,
329329
):
330330
result = await hass.config_entries.flow.async_configure(
@@ -354,7 +354,7 @@ async def test_discovery_not_setup(
354354
assert result["type"] is FlowResultType.FORM
355355
assert result["step_id"] == "user"
356356
with patch(
357-
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
357+
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code_v4"
358358
):
359359
result = await hass.config_entries.flow.async_configure(
360360
result["flow_id"], {CONF_USERNAME: USER_EMAIL}
@@ -364,7 +364,7 @@ async def test_discovery_not_setup(
364364
assert result["step_id"] == "code"
365365
assert result["errors"] == {}
366366
with patch(
367-
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
367+
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login_v4",
368368
return_value=USER_DATA,
369369
):
370370
result = await hass.config_entries.flow.async_configure(

0 commit comments

Comments
 (0)