Skip to content

Commit 711b94a

Browse files
committed
chore: add tests
1 parent 6e38bd0 commit 711b94a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,21 @@ def mock_rest() -> aioresponses:
271271
status=200,
272272
payload={"api": None, "code": 200, "result": None, "status": "ok", "success": True},
273273
)
274+
mocked.post(
275+
re.compile(r"https://.*iot\.roborock\.com/api/v4/email/code/send.*"),
276+
status=200,
277+
payload={"code": 200, "data": None, "msg": "success"},
278+
)
279+
mocked.post(
280+
re.compile(r"https://.*iot\.roborock\.com/api/v3/key/sign.*"),
281+
status=200,
282+
payload={"code": 200, "data": {"k": "mock_k"}, "msg": "success"},
283+
)
284+
mocked.post(
285+
re.compile(r"https://.*iot\.roborock\.com/api/v4/auth/email/login/code.*"),
286+
status=200,
287+
payload={"code": 200, "data": USER_DATA, "msg": "success"},
288+
)
274289
yield mocked
275290

276291

tests/test_web_api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,11 @@ async def test_execute_scene(mock_rest):
6363
ud = await api.pass_login("password")
6464
await api.execute_scene(ud, 123456)
6565
mock_rest.assert_any_call("https://api-us.roborock.com/user/scene/123456/execute", "post")
66+
67+
68+
async def test_code_login_v4_flow(mock_rest) -> None:
69+
"""Test that we can login with a code and we get back the correct userdata object."""
70+
api = RoborockApiClient(username="test_user@gmail.com")
71+
await api.request_code_v4()
72+
ud = await api.code_login_v4(4123, "US", 1)
73+
assert ud == UserData.from_dict(USER_DATA)

0 commit comments

Comments
 (0)