Skip to content

Commit 43694ea

Browse files
committed
fix: testing and comments
1 parent 6fee8ce commit 43694ea

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

roborock/web_api.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333

3434
class RoborockApiClient:
3535
_LOGIN_RATES = [
36-
Rate(1, Duration.SECOND), # 1 requests per hour
37-
Rate(3, Duration.MINUTE), # 3 requests per hour
38-
Rate(10, Duration.HOUR), # 10 requests per hour
39-
Rate(20, Duration.DAY), # 20 requests per day
36+
Rate(1, Duration.SECOND),
37+
Rate(3, Duration.MINUTE),
38+
Rate(10, Duration.HOUR),
39+
Rate(20, Duration.DAY),
4040
]
4141
_HOME_DATA_RATES = [
42-
Rate(1, Duration.SECOND), # 1 requests per hour
43-
Rate(5, Duration.MINUTE), # 5 requests per hour
44-
Rate(15, Duration.HOUR), # 15 requests per hour
45-
Rate(40, Duration.DAY), # 40 requests per day
42+
Rate(1, Duration.SECOND),
43+
Rate(5, Duration.MINUTE),
44+
Rate(15, Duration.HOUR),
45+
Rate(40, Duration.DAY),
4646
]
4747

4848
_login_limiter = Limiter(_LOGIN_RATES)
@@ -387,10 +387,10 @@ async def get_home_data_v3(self, user_data: UserData) -> HomeData:
387387
home_request = PreparedRequest(
388388
rriot.r.a,
389389
{
390-
"Authorization": self._get_hawk_authentication(rriot, "/v3/user/homes/" + str(home_id)),
390+
"Authorization": self._get_hawk_authentication(rriot, "/v3/user/homes/" + home_id),
391391
},
392392
)
393-
home_response = await home_request.request("get", "/v3/user/homes/" + str(home_id))
393+
home_response = await home_request.request("get", "/v3/user/homes/" + home_id)
394394
if not home_response.get("success"):
395395
raise RoborockException(home_response)
396396
home_data = home_response.get("result")

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ def mock_rest() -> aioresponses:
264264
yield mocked
265265

266266

267+
@pytest.fixture(autouse=True)
268+
def skip_rate_limit():
269+
"""Don't rate limit tests as they aren't actually hitting the api."""
270+
with (
271+
patch("roborock.web_api.RoborockApiClient._login_limiter.try_acquire"),
272+
patch("roborock.web_api.RoborockApiClient._home_data_limiter.try_acquire"),
273+
):
274+
yield
275+
276+
267277
@pytest.fixture(name="mock_create_local_connection")
268278
def create_local_connection_fixture(request_handler: RequestHandler) -> Generator[None, None, None]:
269279
"""Fixture that overrides the transport creation to wire it up to the mock socket."""

0 commit comments

Comments
 (0)