Skip to content

Commit 4b83cf3

Browse files
authored
Merge pull request #161 from ianatha/main
test that robots without S/N are ignored
2 parents 2375f9a + 33b0b9e commit 4b83cf3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
INSIGHT_RESPONSE,
2121
LITTER_ROBOT_4_DATA,
2222
ROBOT_DATA,
23+
ROBOT_DELETED_DATA,
2324
ROBOT_FULL_DATA,
2425
USER_RESPONSE,
2526
get_account,
@@ -75,7 +76,9 @@ def mock_aioresponse() -> aioresponses:
7576
)
7677
mock.get(re.compile(".*/users$"), payload=USER_RESPONSE)
7778
mock.get(
78-
re.compile(".*/robots$"), payload=[ROBOT_DATA, ROBOT_FULL_DATA], repeat=True
79+
re.compile(".*/robots$"),
80+
payload=[ROBOT_DATA, ROBOT_DELETED_DATA, ROBOT_FULL_DATA],
81+
repeat=True,
7982
)
8083
mock.get(re.compile(".*/activity?.*$"), payload=ACTIVITY_RESPONSE, repeat=True)
8184
mock.get(re.compile(".*/insights?.*$"), payload=INSIGHT_RESPONSE, repeat=True)

tests/test_account.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Test account module."""
22
from __future__ import annotations
3+
import logging
34

45
from unittest.mock import patch
56

@@ -28,7 +29,9 @@
2829
ROBOT_COUNT = 4
2930

3031

31-
async def test_account(mock_aioresponse: aioresponses) -> None:
32+
async def test_account(
33+
mock_aioresponse: aioresponses, caplog: pytest.LogCaptureFixture
34+
) -> None:
3235
"""Tests that an account is properly setup."""
3336
account = await get_account()
3437
assert account.user_id is None
@@ -46,7 +49,12 @@ async def test_account(mock_aioresponse: aioresponses) -> None:
4649
payload={"data": {"getLitterRobot4ByUser": [LITTER_ROBOT_4_DATA]}},
4750
repeat=True,
4851
)
52+
caplog.set_level(logging.INFO)
4953
await account.load_robots()
54+
assert (
55+
caplog.messages[-1]
56+
== "skipping robot without serial number (id=00a2d005ceae00, name=Deleted Test)"
57+
)
5058
assert len(account.robots) == ROBOT_COUNT
5159

5260
mock_aioresponse.get(ROBOT_ENDPOINT % ROBOT_ID, payload={})

0 commit comments

Comments
 (0)