From 92c94b4b56b3eeb2598d00443f85d060bc4ccea9 Mon Sep 17 00:00:00 2001 From: David Bonnes Date: Sat, 9 Nov 2024 09:48:28 +0000 Subject: [PATCH] refactor tests --- requirements_dev.txt | 1 + tests/tests_rf/{helpers.py => common.py} | 36 +++- tests/tests_rf/conftest.py | 43 ++-- tests/tests_rf/const.py | 10 + tests/tests_rf/test_token_mgr.py | 191 ------------------ tests/tests_rf/test_v1_apis.py | 3 +- tests/tests_rf/test_v1_auth.py | 99 ++++++++++ tests/tests_rf/test_v1_auth_urls.py | 4 +- tests/tests_rf/test_v1_urls.py | 240 ----------------------- tests/tests_rf/test_v1_xxxx.py | 11 +- tests/tests_rf/test_v2_apis.py | 3 +- tests/tests_rf/test_v2_auth_urls.py | 2 +- tests/tests_rf/test_v2_task.py | 5 +- 13 files changed, 186 insertions(+), 462 deletions(-) rename tests/tests_rf/{helpers.py => common.py} (85%) create mode 100644 tests/tests_rf/const.py delete mode 100644 tests/tests_rf/test_token_mgr.py create mode 100644 tests/tests_rf/test_v1_auth.py delete mode 100644 tests/tests_rf/test_v1_urls.py diff --git a/requirements_dev.txt b/requirements_dev.txt index 06f92321..b1623c93 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -23,6 +23,7 @@ pytest >= 8.3.3 pytest-asyncio >= 0.24.0 # pytest-cov >= 5.0.0 + pytest-freezer >= 0.4.8 pytest-sugar >= 1.0.0 pytest-xdist >= 3.6.1 syrupy >= 4.7.2 diff --git a/tests/tests_rf/helpers.py b/tests/tests_rf/common.py similarity index 85% rename from tests/tests_rf/helpers.py rename to tests/tests_rf/common.py index fa120463..a966592f 100644 --- a/tests/tests_rf/helpers.py +++ b/tests/tests_rf/common.py @@ -5,20 +5,46 @@ import asyncio from http import HTTPMethod, HTTPStatus +from pathlib import Path +from typing import Any, Final import aiohttp import voluptuous as vol import evohomeasync as evo1 import evohomeasync2 as evo2 -from evohomeasync2.auth import Auth -from evohomeasync2.const import URL_BASE as URL_BASE_2 +from evohomeasync2.auth import URL_BASE as URL_BASE_2, Auth -from .conftest import _DBG_DISABLE_STRICT_ASSERTS +from .const import _DBG_DISABLE_STRICT_ASSERTS # version 1 helpers ################################################################### +class SessionManager(evo1.Auth): + """An evohomeasync session manager.""" + + def __init__( + self, + client_id: str, + secret: str, + websession: aiohttp.ClientSession, + /, + token_cache: Path | None = None, + **kwargs: Any, + ) -> None: + """Initialise the session manager.""" + super().__init__(client_id, secret, websession, **kwargs) + + self._token_cache: Final = token_cache + + async def save_session_id(self) -> None: + """Save the (serialized) session id to a cache.""" + + async def load_session_id(self) -> None: + """Save the (serialized) session id from a cache.""" + + + async def should_work_v1( evo: evo1.EvohomeClient, method: HTTPMethod, @@ -32,7 +58,7 @@ async def should_work_v1( response: aiohttp.ClientResponse # unlike _make_request(), make_request() incl. raise_for_status() - response = await evo.auth._make_request(method, url, data=json) + response = await evo.auth.request(method, url, data=json) response.raise_for_status() # TODO: perform this transform in the broker @@ -65,7 +91,7 @@ async def should_fail_v1( try: # unlike _make_request(), make_request() incl. raise_for_status() - response = await evo.auth._make_request(method, url, data=json) + response = await evo.auth.request(method, url, data=json) response.raise_for_status() except aiohttp.ClientResponseError as err: diff --git a/tests/tests_rf/conftest.py b/tests/tests_rf/conftest.py index e93f7b5c..7da9876c 100644 --- a/tests/tests_rf/conftest.py +++ b/tests/tests_rf/conftest.py @@ -17,22 +17,19 @@ import evohomeasync2 as evo2 from evohomeasync2.client import TokenManager +from .common import SessionManager # incl. support for cache file +from .const import _DBG_USE_REAL_AIOHTTP from .faked_server import FakedServer -# -# normally, we want debug flags to be False -_DBG_USE_REAL_AIOHTTP = False -_DBG_DISABLE_STRICT_ASSERTS = False # of response content-type, schema - if TYPE_CHECKING: import aiohttp # used to construct the default token cache -TEST_USERNAME: Final = "username@email.com" -TEST_PASSWORD: Final = "P@ssw0rd!!" # noqa: S105 +TEST_USERNAME: Final = "spotty.blackcat@gmail.com" # SECRET "username@email.com" +TEST_PASSWORD: Final = "ziQajn732m5JYQ!" # "P@ssw0rd!!" # noqa: S105 -_FNC = TypeVar("_F", bound=Callable[..., Any]) +_FNC = TypeVar("_FNC", bound=Callable[..., Any]) # Global flag to indicate if AuthenticationFailedError has been encountered @@ -66,8 +63,8 @@ async def wrapper(*args: Any, **kwargs: Any) -> Any: return wrapper # type: ignore[return-value] -@pytest.fixture(autouse=True) -def patches_for_tests(monkeypatch: pytest.MonkeyPatch) -> None: +@pytest.fixture(autouse=False) +def zpatches_for_tests(monkeypatch: pytest.MonkeyPatch) -> None: """Patch the evohomeasync and evohomeasync2 modules.""" if _DBG_USE_REAL_AIOHTTP: @@ -144,6 +141,24 @@ def token_cache( return token_cache +@pytest.fixture # @pytest_asyncio.fixture(scope="session", loop_scope="session") +async def session_manager( + client_session: aiohttp.ClientSession, + credentials: tuple[str, str], + token_cache: Path, +) -> AsyncGenerator[SessionManager, None]: + """Yield a token manager for the v1 API.""" + + manager = SessionManager(*credentials, client_session, token_cache=token_cache) + + # await manager.load_session_id() # restoresession_id from cache + + try: + yield manager + finally: + await manager.save_session_id() # save auth tokens to cache + + @pytest.fixture # @pytest_asyncio.fixture(scope="session", loop_scope="session") async def token_manager( client_session: aiohttp.ClientSession, @@ -152,14 +167,14 @@ async def token_manager( ) -> AsyncGenerator[TokenManager, None]: """Yield a token manager for the v2 API.""" - token_manager = TokenManager(*credentials, client_session, token_cache=token_cache) + manager = TokenManager(*credentials, client_session, token_cache=token_cache) - await token_manager.load_access_token() # restore auth tokens from cache + # await manager.load_access_token() # restore auth tokens from cache try: - yield token_manager + yield manager finally: - await token_manager.save_access_token() # save auth tokens to cache + await manager.save_access_token() # save auth tokens to cache @pytest.fixture diff --git a/tests/tests_rf/const.py b/tests/tests_rf/const.py new file mode 100644 index 00000000..9004cf93 --- /dev/null +++ b/tests/tests_rf/const.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +"""evohome-async - tests""" + +from __future__ import annotations + +# +# normally, we want debug flags to be False +_DBG_USE_REAL_AIOHTTP = True +_DBG_DISABLE_STRICT_ASSERTS = False # of response content-type, schema + diff --git a/tests/tests_rf/test_token_mgr.py b/tests/tests_rf/test_token_mgr.py deleted file mode 100644 index b907d62b..00000000 --- a/tests/tests_rf/test_token_mgr.py +++ /dev/null @@ -1,191 +0,0 @@ -#!/usr/bin/env python3 -"""evohome-async - validate the evohome-async APIs (methods).""" - -from __future__ import annotations - -import json -from collections.abc import AsyncGenerator -from datetime import datetime as dt -from http import HTTPStatus -from pathlib import Path -from typing import TYPE_CHECKING, Any -from unittest.mock import AsyncMock, patch - -import aiohttp -import pytest - -import evohomeasync2 as evo2 -from evohomeasync2 import exceptions as exc -from evohomeasync2.client import TokenManager - -from .conftest import TEST_PASSWORD, TEST_USERNAME - -if TYPE_CHECKING: - from datetime import datetime as dt - - import aiohttp - - -####################################################################################### - - -@pytest.fixture -async def client_session() -> AsyncGenerator[aiohttp.ClientSession, None]: - """Yield a client session, which may be faked.""" - - def post_side_effect(*args: Any, **kwargs: Any) -> Any: - """Raise an exception.""" - - if args != ("https://tccna.honeywell.com/Auth/OAuth/Token",): - raise aiohttp.ClientResponseError(None, (), status=HTTPStatus.NOT_FOUND) - - data = kwargs["data"] - - if data["grant_type"] == "refresh_token": # mock it is not valid - raise aiohttp.ClientResponseError(None, (), status=HTTPStatus.UNAUTHORIZED) - - # else: data["grant_type"] == "password"... - - if ( - data.get("Username") != TEST_USERNAME - or data.get("Password") != TEST_PASSWORD - ): - raise aiohttp.ClientResponseError(None, (), status=HTTPStatus.BAD_REQUEST) - - raise aiohttp.ClientResponseError(None, (), status=HTTPStatus.TOO_MANY_REQUESTS) - - mock_session = AsyncMock(spec=aiohttp.ClientSession) - mock_session.post = post_side_effect - - try: - yield mock_session - finally: - await mock_session.close() - - -async def test_token_manager_loading( - client_session: aiohttp.ClientSession, - credentials: tuple[str, str], - tmp_path: Path, - token_data: dict[str, Any], -) -> None: - """Test the token manager by loading different token data from the cache.""" - - def tokens_are_null() -> bool: - return ( - token_manager.access_token == "" - and token_manager.access_token_expires <= dt.min - and token_manager.refresh_token == "" - ) - - # we don't use the token_manager fixture in this test - token_cache = tmp_path / ".evo-cache.tst" - - token_manager = TokenManager(*credentials, client_session, token_cache=token_cache) - - assert tokens_are_null() - assert not token_manager.is_token_data_valid() - - # - # Test 0: null token cache (zero-length content in file) - await token_manager.load_access_token() - - assert tokens_are_null() - assert not token_manager.is_token_data_valid() - - # - # Test 1: valid token cache - with token_cache.open("w") as f: - f.write(json.dumps(token_data)) - - await token_manager.load_access_token() - - assert not tokens_are_null() - assert token_manager.is_token_data_valid() - - # - # Test 2: empty token cache (empty dict in file) - with token_cache.open("w") as f: - f.write(json.dumps({})) - - await token_manager.load_access_token() - - assert tokens_are_null() - assert not token_manager.is_token_data_valid() - - # - # Test 1: valid token cache (again) - with token_cache.open("w") as f: - f.write(json.dumps(token_data)) - - await token_manager.load_access_token() - - assert not tokens_are_null() - assert token_manager.is_token_data_valid() - - # - # Test 3: invalid token cache (different username) - with token_cache.open("w") as f: - f.write(json.dumps({f"_{credentials[0]}": token_data[credentials[0]]})) - - await token_manager.load_access_token() - - assert tokens_are_null() - assert not token_manager.is_token_data_valid() - - -async def _test_token_manager_00( - credentials: tuple[str, str], - token_cache: Path, - client_session: aiohttp.ClientSession, -) -> None: - """Test token manager.""" - - token_manager = TokenManager(*credentials, client_session, token_cache=token_cache) - - assert not token_manager.is_token_data_valid() - - await token_manager.get_access_token() - - assert token_manager.is_token_data_valid() - - -async def _test_evo_update_00( - evohome_v2: evo2.EvohomeClientNew, -) -> None: - """Test EvohomeClient2.update().""" - - evo = evohome_v2 - - assert evo._user_info is None - assert evo._install_config is None - - await evo.update(reset_config=False, dont_update_status=False) - - assert evo._user_info is not None - assert evo._install_config is not None # type: ignore[unreachable] - - assert evo.locations[0]._status == {} - - await evo.update(reset_config=True) - - assert evo._user_info is not None - assert evo._install_config is not None - - assert evo.locations[0]._status != {} - - -async def _test_evo_update_01( - evohome_v2: evo2.EvohomeClientNew, -) -> None: - """Test EvohomeClient2.update().""" - - evo = evohome_v2 - - with patch( - "evohomeasync2.auth.AbstractTokenManager._post_access_token_request" - ) as mock_fcn: - mock_fcn.side_effect = exc.AuthenticationFailedError( - "", status=HTTPStatus.TOO_MANY_REQUESTS - ) - await evo.update() diff --git a/tests/tests_rf/test_v1_apis.py b/tests/tests_rf/test_v1_apis.py index 56eb0bb1..e8ab9ba7 100644 --- a/tests/tests_rf/test_v1_apis.py +++ b/tests/tests_rf/test_v1_apis.py @@ -7,7 +7,8 @@ import evohomeasync as evo1 -from .conftest import _DBG_USE_REAL_AIOHTTP, skipif_auth_failed +from .conftest import skipif_auth_failed +from .const import _DBG_USE_REAL_AIOHTTP async def _test_client_apis(evo: evo1.EvohomeClient) -> None: diff --git a/tests/tests_rf/test_v1_auth.py b/tests/tests_rf/test_v1_auth.py new file mode 100644 index 00000000..2647908a --- /dev/null +++ b/tests/tests_rf/test_v1_auth.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +"""evohome-async - validate the evohomeclient v1 session manager.""" + +from __future__ import annotations + +import uuid +from http import HTTPStatus +from typing import TYPE_CHECKING +from unittest.mock import AsyncMock, patch + +import pytest +from aioresponses import aioresponses +from freezegun.api import FrozenDateTimeFactory + +from evohomeasync import exceptions as exc + +from .const import _DBG_USE_REAL_AIOHTTP + +if TYPE_CHECKING: + + from .common import SessionManager + + +@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="is not using the real aiohttp") +async def test_get_session_id( + session_manager: SessionManager, + freezer: FrozenDateTimeFactory, +) -> None: + """Test .get_session_id() and .is_session_valid() methods.""" + + # TODO: ensure cache is empty... + # maybe: session_manager = SessionManager(...) here? + + # + # have not yet called get_session_id (so not loaded cache either) + assert session_manager.is_session_valid() is False + + # + # test HTTPStatus.UNAUTHORIZED -> exc.AuthenticationFailedError + with aioresponses() as rsp: + rsp.post( + "https://tccna.honeywell.com/WebAPI/api/session", + status=HTTPStatus.UNAUTHORIZED, + payload=[{"code": "EmailOrPasswordIncorrect", "message": "xxx"}], + ) + + with pytest.raises(exc.AuthenticationFailedError): + await session_manager.get_session_id() + + assert session_manager.is_session_valid() is False + + # + # test HTTPStatus.OK + session_id = str(uuid.uuid4()).upper() + + with aioresponses() as rsp: + rsp.post( + "https://tccna.honeywell.com/WebAPI/api/session", + payload={"sessionId": session_id, "userInfo": {}}, + ) + + assert await session_manager.get_session_id() == session_id + + assert session_manager.is_session_valid() is True + + # + # check doesn't invoke the URL again, as session_id still valid + freezer.tick(600) # advance time by 5 minutes + + with patch("aiohttp.ClientSession.post", new_callable=AsyncMock) as mok: + assert await session_manager.get_session_id() == session_id + + mok.assert_not_called() + + assert session_manager.is_session_valid() is True + + # + # check does invoke the URL, as session_id now expired + assert session_manager.is_session_valid() is True + + freezer.tick(1200) # advance time by another 10 minutes, 15 total + + assert session_manager.is_session_valid() is False + + with aioresponses() as rsp: + rsp.post( + "https://tccna.honeywell.com/WebAPI/api/session", + payload={"sessionId": session_id, "userInfo": {}}, + ) + + assert await session_manager.get_session_id() == session_id + + assert session_manager.is_session_valid() is True + + # + # test _clear_session_id() + session_manager._clear_session_id() + + assert session_manager.is_session_valid() is False diff --git a/tests/tests_rf/test_v1_auth_urls.py b/tests/tests_rf/test_v1_auth_urls.py index ae475c09..91351948 100644 --- a/tests/tests_rf/test_v1_auth_urls.py +++ b/tests/tests_rf/test_v1_auth_urls.py @@ -13,12 +13,12 @@ from evohomeasync.auth import _APPLICATION_ID, HOSTNAME from evohomeasync.schema import SCH_LOCATION_RESPONSE, SCH_USER_ACCOUNT_RESPONSE -from .conftest import _DBG_USE_REAL_AIOHTTP +from .const import _DBG_USE_REAL_AIOHTTP if TYPE_CHECKING: import aiohttp - from evohomeasync.schema import ErrorResponse, LocationResponse, SessionResponse + from evohomeasync.schema import ErrorResponse URL_AUTH = f"https://{HOSTNAME}/WebAPI/api/session" diff --git a/tests/tests_rf/test_v1_urls.py b/tests/tests_rf/test_v1_urls.py deleted file mode 100644 index 3ec164fb..00000000 --- a/tests/tests_rf/test_v1_urls.py +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/env python3 -"""evohome-async - validate the evohomeclient v1 session manager.""" - -from __future__ import annotations - -import random -import string -from http import HTTPMethod, HTTPStatus -from typing import TYPE_CHECKING - -import pytest - -from evohomeasync.auth import _APPLICATION_ID, HEADERS_BASE, HOSTNAME -from evohomeasync.schema import SCH_LOCATION_RESPONSE, SCH_USER_ACCOUNT_RESPONSE - -from .conftest import _DBG_USE_REAL_AIOHTTP - -if TYPE_CHECKING: - import aiohttp - - from evohomeasync.schema import ErrorResponse, LocationResponse, SessionResponse - - -URL_AUTH = f"https://{HOSTNAME}/WebAPI/api/session" -URL_BASE = f"https://{HOSTNAME}/WebAPI/api/" - - -@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="is not using the real aiohttp") -async def test_url_session_bad1( # invalid/unknown credentials - client_session: aiohttp.ClientSession, - credentials: tuple[str, str], -) -> None: - """Test the authentication flow with bad credentials.""" - - # invalid credentials -> HTTPStatus.UNAUTHORIZED - url = URL_AUTH - - data = { - "applicationId": _APPLICATION_ID, - "username": credentials[0] + random.choice(string.ascii_letters), # noqa: S311 - "password": credentials[1], - } - - async with client_session.request( - HTTPMethod.POST, url, headers=HEADERS_BASE, json=data - ) as rsp: - assert rsp.status == HTTPStatus.UNAUTHORIZED - - response: list[ErrorResponse] = await rsp.json() - - """ - [{ - 'code': 'EmailOrPasswordIncorrect', - 'message': 'The email or password provided is incorrect.' - }] - """ - - assert response[0]["code"] == "EmailOrPasswordIncorrect" - assert response[0]["message"] and isinstance(response[0]["message"], str) - - # assert SCH_ERROR_RESPONSE(result), result - - -@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="is not using the real aiohttp") -async def test_url_session_bad2( # invalid/expired session id - client_session: aiohttp.ClientSession, -) -> None: - """Test the authentication flow with an invalid session id,""" - - # pre-requisite data - session_id = "-- bad / expired session id --" + random.choice(string.ascii_letters) # noqa: S311 - user_id = 1234567 - - # invalid/expired session id -> HTTPStatus.UNAUTHORIZED - url = URL_BASE + f"locations?userId={user_id}&allData=True" - - headers = HEADERS_BASE | {"sessionId": session_id} - - async with client_session.request(HTTPMethod.GET, url, headers=headers) as rsp: - assert rsp.status == HTTPStatus.UNAUTHORIZED - - response: list[ErrorResponse] = await rsp.json() - - """ - [{ - 'code': 'Unauthorized', - 'message': 'Unauthorized' - }] - """ - - assert response[0]["code"] == "Unauthorized" - assert response[0]["message"] and isinstance(response[0]["message"], str) - - # assert SCH_ERROR_RESPONSE(result), result - - -@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="is not using the real aiohttp") -async def test_url_session_good( - client_session: aiohttp.ClientSession, - credentials: tuple[str, str], -) -> None: - """Test the authentication flow (and authorization) with good credentials.""" - - # valid credentials -> HTTPStatus.OK - url = URL_AUTH - - data = { - "applicationId": _APPLICATION_ID, - "username": credentials[0], - "password": credentials[1], - } - - async with client_session.request( - HTTPMethod.POST, url, headers=HEADERS_BASE, json=data - ) as rsp: - assert rsp.status in [ - HTTPStatus.OK, - HTTPStatus.TOO_MANY_REQUESTS, - ] - - response: SessionResponse = await rsp.json() - - """ - [{ - 'code': 'TooManyRequests', - 'message': 'Request count limitation exceeded, please try again later.' - }] - """ - - if rsp.status == HTTPStatus.TOO_MANY_REQUESTS: - assert response[0]["code"] == "TooManyRequests" - assert response[0]["message"] and isinstance(response[0]["message"], str) - pytest.skip("Too many requests") - - """ - { - 'sessionId': 'A80FF794-C042-42BC-A63E-7A509C9AA6C9', - 'userInfo': { - 'userID': 2263181, - 'username': 'spotty.blackcat@gmail.com', - 'firstname': 'David', - 'lastname': 'Smith', - 'streetAddress': '1 Main Street', - 'city': 'London', - 'zipcode': 'E1 1AA', - 'country': 'GB', - 'telephone': '', - 'userLanguage': 'en-GB', - 'isActivated': True, - 'deviceCount': 0, - 'tenantID': 5, - 'securityQuestion1': 'NotUsed', - 'securityQuestion2': 'NotUsed', - 'securityQuestion3': 'NotUsed', - 'latestEulaAccepted': False - } - } - """ - - assert response["sessionId"] and isinstance(response["sessionId"], str) - assert response["userInfo"]["username"] == credentials[0] - - assert SCH_USER_ACCOUNT_RESPONSE(response["userInfo"]), response["userInfo"] - - # ################################################################################# - - # Check the session id by accessing a resource... - session_id = response["sessionId"] - user_id = response["userInfo"]["userID"] - - # valid session id -> HTTPStatus.OK - url = URL_BASE + f"locations?userId={user_id}&allData=True" - - headers = HEADERS_BASE | {"sessionId": session_id} - - async with client_session.request(HTTPMethod.GET, url, headers=headers) as rsp: - assert rsp.status in [ - HTTPStatus.OK, - HTTPStatus.TOO_MANY_REQUESTS, - ] - - response: list[LocationResponse] = await rsp.json() - - if rsp.status == HTTPStatus.TOO_MANY_REQUESTS: - assert response[0]["code"] == "TooManyRequests" - assert response[0]["message"] and isinstance(response[0]["message"], str) - pytest.skip("Too many requests") - - """ - [ - { - "locationID": 1234567, - "name": "My Home", - "streetAddress": "1 Main Street", - "city": "London", - "state": "", - "country": "GB", - "zipcode": "E1 1AA", - "type": "Residential", - "hasStation": true, - "devices": [{}], # list of ?DeviceResponse - "oneTouchButtons": [], - "weather": { - "condition": "Cloudy", - "temperature": 13.0, - "units": "Celsius", - "humidity": 96, - "phrase": "Cloudy" - }, - "daylightSavingTimeEnabled": true, - "timeZone": { - "id": "GMT Standard Time", - "displayName": "(UTC+00:00) Dublin, Edinburgh, Lisbon, London", - "offsetMinutes": 0, - "currentOffsetMinutes": 0, - "usingDaylightSavingTime": true - }, - "oneTouchActionsSuspended": false, - "isLocationOwner": true, - "locationOwnerID": 1234568, - "locationOwnerName": "David Smith", - "locationOwnerUserName": "username@email.com", - "canSearchForContractors": true, - "contractor": { - "info": { - "contractorID": 1839 - }, - "monitoring": { - "levelOfAccess": "Partial", - "contactPreferences": [] - } - } - } - ] - """ - - assert response[0]["locationID"] and isinstance(response[0]["locationID"], int) - assert response[0]["devices"] and isinstance(response[0]["devices"], list) - - assert SCH_LOCATION_RESPONSE(response[0]), response[0] diff --git a/tests/tests_rf/test_v1_xxxx.py b/tests/tests_rf/test_v1_xxxx.py index c169f277..bb9fad6e 100644 --- a/tests/tests_rf/test_v1_xxxx.py +++ b/tests/tests_rf/test_v1_xxxx.py @@ -9,8 +9,9 @@ import evohomeasync as evo1 -from .conftest import _DBG_USE_REAL_AIOHTTP, skipif_auth_failed -from .helpers import should_fail_v1, should_work_v1 +from .common import should_fail_v1, should_work_v1 +from .conftest import skipif_auth_failed +from .const import _DBG_USE_REAL_AIOHTTP async def _test_url_locations(evo: evo1.EvohomeClient) -> None: @@ -81,10 +82,10 @@ async def test_client_apis(evohome_v1: evo1.EvohomeClient) -> None: USER_DATA = { - "sessionId": "BE5F40A6-1234-1234-1234-A708947D638B", + "sessionId": "BE5F40A6-1234-1234-1234-A708947D6399", "userInfo": { - "userID": 2263181, - "username": "null@gmail.com", + "userID": 1234567, + "username": "username@email.com", "firstname": "David", "lastname": "Smith", "streetAddress": "1 Main Street", diff --git a/tests/tests_rf/test_v2_apis.py b/tests/tests_rf/test_v2_apis.py index 62790456..9e2e6581 100644 --- a/tests/tests_rf/test_v2_apis.py +++ b/tests/tests_rf/test_v2_apis.py @@ -20,7 +20,8 @@ from evohomeasync2.zone import Zone from . import faked_server as faked -from .conftest import _DBG_USE_REAL_AIOHTTP, skipif_auth_failed +from .conftest import skipif_auth_failed +from .const import _DBG_USE_REAL_AIOHTTP ####################################################################################### diff --git a/tests/tests_rf/test_v2_auth_urls.py b/tests/tests_rf/test_v2_auth_urls.py index eeb69ffd..e8764f6b 100644 --- a/tests/tests_rf/test_v2_auth_urls.py +++ b/tests/tests_rf/test_v2_auth_urls.py @@ -13,7 +13,7 @@ from evohomeasync2.auth import _APPLICATION_ID, HOSTNAME, SCH_OAUTH_TOKEN from evohomeasync2.schema import SCH_USER_ACCOUNT -from .conftest import _DBG_USE_REAL_AIOHTTP +from .const import _DBG_USE_REAL_AIOHTTP if TYPE_CHECKING: import aiohttp diff --git a/tests/tests_rf/test_v2_task.py b/tests/tests_rf/test_v2_task.py index 99bcb616..b11f6ce2 100644 --- a/tests/tests_rf/test_v2_task.py +++ b/tests/tests_rf/test_v2_task.py @@ -20,8 +20,9 @@ ) from evohomeasync2.schema.helpers import pascal_case -from .conftest import _DBG_USE_REAL_AIOHTTP, skipif_auth_failed -from .helpers import should_fail, should_work +from .common import should_fail, should_work +from .conftest import skipif_auth_failed +from .const import _DBG_USE_REAL_AIOHTTP #######################################################################################