Skip to content

Commit

Permalink
tweaks to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdavb committed Sep 1, 2024
1 parent a1d51c7 commit c412de6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 30 deletions.
13 changes: 4 additions & 9 deletions tests/tests_rf/test_v1_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


#######################################################################################

Expand All @@ -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)
22 changes: 6 additions & 16 deletions tests/tests_rf/test_v1_xxxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

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

if TYPE_CHECKING:
from collections.abc import Awaitable

import evohomeasync as ev1


#######################################################################################

Expand Down Expand Up @@ -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)
10 changes: 8 additions & 2 deletions tests/tests_rf/test_v2_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions tests/tests_rf/test_v2_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit c412de6

Please sign in to comment.