From f788f0cb2b8508d4a1e641203342e475a1d78706 Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Tue, 20 Aug 2024 10:50:56 +0100 Subject: [PATCH] mypy, ruff --- tests/tests_rf/helpers.py | 2 +- tests/tests_rf/test_v2_task.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/tests_rf/helpers.py b/tests/tests_rf/helpers.py index 36dbea5..8ed80f4 100644 --- a/tests/tests_rf/helpers.py +++ b/tests/tests_rf/helpers.py @@ -282,7 +282,7 @@ async def should_fail( return content -async def wait_for_comm_task(evo: evo2.EvohomeClient, task_id: str) -> bool | None: +async def wait_for_comm_task_v2(evo: evo2.EvohomeClient, task_id: str) -> bool | None: """Wait for a communication task (API call) to complete.""" # invoke via: diff --git a/tests/tests_rf/test_v2_task.py b/tests/tests_rf/test_v2_task.py index 0d61cea..6dca388 100644 --- a/tests/tests_rf/test_v2_task.py +++ b/tests/tests_rf/test_v2_task.py @@ -3,6 +3,7 @@ from __future__ import annotations +import asyncio from datetime import datetime as dt, timedelta as td from http import HTTPMethod, HTTPStatus @@ -26,7 +27,7 @@ instantiate_client, should_fail, should_work, - wait_for_comm_task, + wait_for_comm_task_v2 as wait_for_comm_task, ) ####################################################################################### @@ -107,7 +108,8 @@ async def _test_task_id(evo: evo2.EvohomeClient) -> None: # {'commtaskId': '840367013', 'state': 'Succeeded'} # dtm = dt.now() - _ = await wait_for_comm_task(evo, task_id, timeout=3) + async with asyncio.timeout(3): + _ = await wait_for_comm_task(evo, task_id) # assert (dt.now() - dtm).total_seconds() < 2 # @@ -118,7 +120,9 @@ async def _test_task_id(evo: evo2.EvohomeClient) -> None: SZ_UNTIL_TIME: (dt.now() + td(hours=1)).strftime(API_STRFTIME), } _ = await should_work(evo, HTTPMethod.PUT, PUT_URL, json=new_mode) # HTTP 201 - _ = await wait_for_comm_task(evo, task_id, timeout=3) + + async with asyncio.timeout(3): + _ = await wait_for_comm_task(evo, task_id) status = await should_work(evo, HTTPMethod.GET, GET_URL) new_mode = { # NOTE: different capitalisation, until time