Skip to content

Commit

Permalink
add a very minimal test
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdavb committed Dec 24, 2024
1 parent b3bbbd2 commit 9da3ecc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/evohomeasync/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def update(
self._user_info = None
self._user_locs = None

if self._user_info is None:
if self._user_info is None: # will handle a bad session_id
url = "accountInfo"
try:
self._user_info = await self.auth.get(url, schema=SCH_GET_ACCOUNT_INFO) # type: ignore[assignment]
Expand Down
2 changes: 1 addition & 1 deletion src/evohomeasync2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def update( # noqa: C901
self._user_info = None
self._user_locs = None

if self._user_info is None:
if self._user_info is None: # will handle a bad access_token
url = "userAccount"
try:
self._user_info = await self.auth.get(url, schema=SCH_USER_ACCOUNT) # type: ignore[assignment]
Expand Down
2 changes: 1 addition & 1 deletion tests/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

#
# normally, we want debug flags to be False
_DBG_DISABLE_STRICT_ASSERTS = False # of response content-type, schema
_DBG_TEST_CRED_URLS = False # avoid 429s: dont invalidate the credential cache
_DBG_USE_REAL_AIOHTTP = False # use 'real' aiohttp to reach vendor's servers
_DBG_DISABLE_STRICT_ASSERTS = False # of response content-type, schema

#
# used to construct the default token cache
Expand Down
44 changes: 44 additions & 0 deletions tests/tests_rf/test_minimal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""evohome-async - a minimal test of instantiation/update of each client."""

from __future__ import annotations

from typing import TYPE_CHECKING

import pytest

from evohome import exceptions as exc
from tests.const import _DBG_USE_REAL_AIOHTTP

from .common import skipif_auth_failed

if TYPE_CHECKING:
from tests.conftest import EvohomeClientv0, EvohomeClientv2


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


@skipif_auth_failed
@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="requires vendor's webserver")
async def test_update_v0(evohome_v0: EvohomeClientv0) -> None:
"""Make a minimal test of instantiation/update of the v0 client."""

with pytest.raises(exc.InvalidConfigError):
assert evohome_v0.user_account

await evohome_v0.update()

assert evohome_v0.user_account


@skipif_auth_failed
@pytest.mark.skipif(not _DBG_USE_REAL_AIOHTTP, reason="requires vendor's webserver")
async def test_update_v2(evohome_v2: EvohomeClientv2) -> None:
"""Make a minimal test of instantiation/update of the v2 client."""

with pytest.raises(exc.InvalidConfigError):
assert evohome_v2.user_account

await evohome_v2.update(_dont_update_status=True)

assert evohome_v2.user_account

0 comments on commit 9da3ecc

Please sign in to comment.