Skip to content

Commit

Permalink
tweaks & fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdavb committed Nov 2, 2024
1 parent 43c8d76 commit c4141a8
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 50 deletions.
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ repos:

- id: secrets
name: check secrets
entry: '#.*(secret|password|pwd)'
entry: '#.*(SECRET|PASSWORD|PWD)'
language: pygrep
args: [-i]
exclude: .pre-commit-config.yaml # avoid false +ve

- id: style_1
Expand Down
4 changes: 2 additions & 2 deletions src/evohomeasync2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def save_access_token(self) -> None:
class EvohomeClientNew: # requires a Token Manager
"""Provide a client to access the Honeywell TCC API."""

_installation_config: _EvoListT | None = None # all locations
_installation_config: _EvoListT | None = None # all locations
_user_information: _EvoDictT | None = None

def __init__(
Expand Down Expand Up @@ -115,7 +115,7 @@ async def update(
information & installation configuration.
If `disable_status_update` is True, does not update the status of each location
(but will still retreive configuration data, if required).
(but will still retrieve configuration data, if required).
"""

if reset_config:
Expand Down
2 changes: 1 addition & 1 deletion src/evohomeasync2/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def use_daylight_save_switching(self) -> bool:
async def update(self) -> _EvoDictT:
"""Get the latest state of the location and update its status.
Will also update teh status of its gateways, their TCSs, and their DHW/zones.
Will also update the status of its gateways, their TCSs, and their DHW/zones.
Returns the raw JSON of the latest state.
"""
Expand Down
7 changes: 5 additions & 2 deletions tests/tests_rf/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ async def evohome_v1(

try:
yield evo
finally:
pass

except evo1.AuthenticationFailed as err:
if not _DBG_USE_REAL_AIOHTTP:
raise
pytest.skip(f"Unable to authenticate: {err}")


@pytest.fixture
Expand Down
File renamed without changes.
20 changes: 4 additions & 16 deletions tests/tests_rf/test_v1_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@

from __future__ import annotations

from typing import TYPE_CHECKING

import pytest

import evohomeasync as evohome
import evohomeasync as evo1

from .conftest import _DBG_USE_REAL_AIOHTTP

if TYPE_CHECKING:
import aiohttp


async def _test_client_apis(evo: evohome.EvohomeClient) -> None:
async def _test_client_apis(evo: evo1.EvohomeClient) -> None:
"""Instantiate a client, and logon to the vendor API."""

user_data = await evo._populate_user_data()
Expand All @@ -34,17 +29,10 @@ async def _test_client_apis(evo: evohome.EvohomeClient) -> None:
# _LOGGER.warning("get_temperatures() OK")


async def test_client_apis(
credentials: tuple[str, str], client_session: aiohttp.ClientSession
) -> None:
async def test_client_apis(evohome_v1: evo1.EvohomeClient) -> None:
"""Test _populate_user_data() & _populate_full_data()"""

if not _DBG_USE_REAL_AIOHTTP:
pytest.skip("Mocked server not implemented for this API")

try:
await _test_client_apis(
await instantiate_client_v1(*credentials, session=client_session)
)
except evohome.AuthenticationFailed:
pytest.skip("Unable to authenticate")
await _test_client_apis(evohome_v1)
32 changes: 7 additions & 25 deletions tests/tests_rf/test_v1_xxxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@
from __future__ import annotations

from http import HTTPMethod, HTTPStatus
from typing import TYPE_CHECKING

import pytest

import evohomeasync as evohome
import evohomeasync as evo1

from .conftest import _DBG_USE_REAL_AIOHTTP
from .helpers import should_fail_v1, should_work_v1

if TYPE_CHECKING:
import aiohttp


async def _test_url_locations(evo: evohome.EvohomeClient) -> None:
async def _test_url_locations(evo: evo1.EvohomeClient) -> None:
# evo.broker._headers["sessionId"] = evo.user_info["sessionId"] # what is this?
user_id: int = evo.user_info["userID"] # type: ignore[assignment]

Expand Down Expand Up @@ -48,7 +44,7 @@ async def _test_url_locations(evo: evohome.EvohomeClient) -> None:
)


async def _test_client_apis(evo: evohome.EvohomeClient) -> None:
async def _test_client_apis(evo: evo1.EvohomeClient) -> None:
"""Instantiate a client, and logon to the vendor API."""

user_data = await evo._populate_user_data()
Expand All @@ -62,36 +58,22 @@ async def _test_client_apis(evo: evohome.EvohomeClient) -> None:
assert temps


async def test_locations(
credentials: tuple[str, str], client_session: aiohttp.ClientSession
) -> None:
async def test_locations(evohome_v1: evo1.EvohomeClient) -> None:
"""Test /locations"""

if not _DBG_USE_REAL_AIOHTTP:
pytest.skip("Mocked server not implemented for this API")

try:
await _test_url_locations(
await instantiate_client_v1(*credentials, session=client_session)
)
except evohome.AuthenticationFailed as err:
pytest.skip(f"Unable to authenticate: {err}")
await _test_url_locations(evohome_v1)


async def test_client_apis(
credentials: tuple[str, str], client_session: aiohttp.ClientSession
) -> None:
async def test_client_apis(evohome_v1: evo1.EvohomeClient) -> None:
"""Test _populate_user_data() & _populate_full_data()"""

if not _DBG_USE_REAL_AIOHTTP:
pytest.skip("Mocked server not implemented for this API")

try:
await _test_client_apis(
await instantiate_client_v1(*credentials, session=client_session)
)
except evohome.AuthenticationFailed:
pytest.skip("Unable to authenticate")
await _test_client_apis(evohome_v1)


USER_DATA = {
Expand Down
3 changes: 1 addition & 2 deletions tests/tests_rf/test_v2_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ async def _test_task_id(evo: evo2.EvohomeClient) -> None:
gwy: Gateway
tcs: ControlSystem

_ = await evo.user_account()
_ = await evo._installation(disable_status_update=True)
_ = await evo.update(disable_status_update=True)

for loc in evo.locations:
for gwy in loc.gateways:
Expand Down

0 comments on commit c4141a8

Please sign in to comment.