From c412de6bf690fe82f53aeacb8bbe93a0d03e11a7 Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Mon, 2 Sep 2024 00:50:16 +0100 Subject: [PATCH] tweaks to tests --- tests/tests_rf/test_v1_apis.py | 13 ++++--------- tests/tests_rf/test_v1_xxxx.py | 22 ++++++---------------- tests/tests_rf/test_v2_apis.py | 10 ++++++++-- tests/tests_rf/test_v2_task.py | 4 +--- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/tests/tests_rf/test_v1_apis.py b/tests/tests_rf/test_v1_apis.py index fd17735d..2ac8e0b0 100644 --- a/tests/tests_rf/test_v1_apis.py +++ b/tests/tests_rf/test_v1_apis.py @@ -7,14 +7,14 @@ import pytest -import evohomeasync as ev1 - from .conftest import _DBG_USE_REAL_AIOHTTP from .const import ExitTestReason if TYPE_CHECKING: from collections.abc import Awaitable + import evohomeasync as ev1 + ####################################################################################### @@ -40,13 +40,8 @@ async def _test_client_apis(evo: ev1.EvohomeClient) -> None: ####################################################################################### +@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason=ExitTestReason.NOT_IMPLEMENTED) async def test_client_apis(evo1: Awaitable[ev1.EvohomeClient]) -> None: """Test _populate_user_data() & _populate_full_data()""" - if not _DBG_USE_REAL_AIOHTTP: - pytest.skip(ExitTestReason.NOT_IMPLEMENTED) - - try: - await _test_client_apis(await evo1) - except ev1.AuthenticationFailedError as err: - pytest.fail(ExitTestReason.AUTHENTICATE_FAIL + f": {err}") + await _test_client_apis(await evo1) diff --git a/tests/tests_rf/test_v1_xxxx.py b/tests/tests_rf/test_v1_xxxx.py index 45e03a90..34b72734 100644 --- a/tests/tests_rf/test_v1_xxxx.py +++ b/tests/tests_rf/test_v1_xxxx.py @@ -8,8 +8,6 @@ import pytest -import evohomeasync as ev1 - from .conftest import _DBG_USE_REAL_AIOHTTP from .const import ExitTestReason from .helpers import should_fail_v1, should_work_v1 @@ -17,6 +15,8 @@ if TYPE_CHECKING: from collections.abc import Awaitable + import evohomeasync as ev1 + ####################################################################################### @@ -961,25 +961,15 @@ async def _test_client_apis(evo: ev1.EvohomeClient) -> None: ####################################################################################### +@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason=ExitTestReason.NOT_IMPLEMENTED) async def test_locations(evo1: Awaitable[ev1.EvohomeClient]) -> None: """Test /locations""" - if not _DBG_USE_REAL_AIOHTTP: - pytest.skip(ExitTestReason.NOT_IMPLEMENTED) - - try: - await _test_url_locations(await evo1) - except ev1.AuthenticationFailedError as err: - pytest.fail(ExitTestReason.AUTHENTICATE_FAIL + f": {err}") + await _test_url_locations(await evo1) +@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason=ExitTestReason.NOT_IMPLEMENTED) async def test_client_apis(evo1: Awaitable[ev1.EvohomeClient]) -> None: """Test _populate_user_data() & _populate_full_data()""" - if not _DBG_USE_REAL_AIOHTTP: - pytest.skip(ExitTestReason.NOT_IMPLEMENTED) - - try: - await _test_client_apis(await evo1) - except ev1.AuthenticationFailedError as err: - pytest.fail(ExitTestReason.AUTHENTICATE_FAIL + f": {err}") + await _test_client_apis(await evo1) diff --git a/tests/tests_rf/test_v2_apis.py b/tests/tests_rf/test_v2_apis.py index 129d541c..554f87c1 100644 --- a/tests/tests_rf/test_v2_apis.py +++ b/tests/tests_rf/test_v2_apis.py @@ -24,6 +24,7 @@ from . import faked_server as faked from .conftest import _DBG_USE_REAL_AIOHTTP, aiohttp from .const import ExitTestReason +from .helpers import instantiate_client_v2 if TYPE_CHECKING: from collections.abc import Awaitable @@ -174,10 +175,15 @@ async def _test_system_apis(evo: ev2.EvohomeClient) -> None: ####################################################################################### -async def test_basics(evo2: Awaitable[ev2.EvohomeClient]) -> None: +async def test_basics( + user_credentials: tuple[str, str], + session: aiohttp.ClientSession | faked.ClientSession, +) -> None: """Test authentication, `user_account()` and `installation()`.""" - await _test_basics_apis(await evo2) + await _test_basics_apis( + await instantiate_client_v2(user_credentials, session, dont_login=True) + ) async def test_sched_(evo2: Awaitable[ev2.EvohomeClient]) -> None: diff --git a/tests/tests_rf/test_v2_task.py b/tests/tests_rf/test_v2_task.py index 65f15734..ed83d4c3 100644 --- a/tests/tests_rf/test_v2_task.py +++ b/tests/tests_rf/test_v2_task.py @@ -190,10 +190,8 @@ async def _test_task_id(evo: ev2.EvohomeClient) -> None: ####################################################################################### +@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason=ExitTestReason.NOT_IMPLEMENTED) async def _out_test_task_id(evo2: Awaitable[ev2.EvohomeClient]) -> None: """Test /location/{locationId}/status""" - if not _DBG_USE_REAL_AIOHTTP: - pytest.skip(ExitTestReason.NOT_IMPLEMENTED) - await _test_task_id(await evo2)