-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
186 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = "[email protected]" | ||
TEST_PASSWORD: Final = "P@ssw0rd!!" # noqa: S105 | ||
TEST_USERNAME: Final = "[email protected]" # SECRET "[email protected]" | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.