|
5 | 5 | import logging
|
6 | 6 | from datetime import UTC, datetime as dt, timedelta as td
|
7 | 7 | from http import HTTPMethod, HTTPStatus
|
8 |
| -from typing import TYPE_CHECKING, Final |
| 8 | +from typing import TYPE_CHECKING |
9 | 9 |
|
10 | 10 | import pytest
|
11 | 11 | from aioresponses import aioresponses
|
12 | 12 |
|
13 |
| -from evohome.const import HINT_BAD_CREDS, HINT_CHECK_NETWORK |
| 13 | +from evohome.const import HINT_CHECK_NETWORK |
14 | 14 | from evohomeasync import EvohomeClient, exceptions as exc
|
15 | 15 | from evohomeasync.auth import _APPLICATION_ID
|
16 | 16 | from tests.const import HEADERS_BASE, HEADERS_CRED_V0, URL_CRED_V0
|
17 | 17 |
|
| 18 | +from .const import LOG_04, LOG_11, LOG_12, LOG_90, LOG_91 |
| 19 | + |
18 | 20 | if TYPE_CHECKING:
|
19 | 21 | from collections.abc import AsyncGenerator
|
20 | 22 | from pathlib import Path
|
21 | 23 |
|
22 | 24 | from cli.auth import CredentialsManager
|
23 | 25 |
|
24 | 26 |
|
25 |
| -MSG_INVALID_SESSION: Final = ( |
26 |
| - "The session_id has been rejected (will re-authenticate): " |
27 |
| - "GET https://tccna.resideo.com/WebAPI/api/accountInfo: " |
28 |
| - '401 Unauthorized, response=[{"code": "Unauthorized", "message": "Unauthorized"}]' |
29 |
| -) |
30 |
| - |
31 | 27 | _TEST_SESSION_ID = "-- session id --"
|
32 | 28 |
|
33 | 29 |
|
@@ -77,11 +73,7 @@ async def test_bad1( # bad credentials (client_id/secret)
|
77 | 73 |
|
78 | 74 | assert err.value.status == HTTPStatus.UNAUTHORIZED
|
79 | 75 |
|
80 |
| - assert caplog.record_tuples == [ |
81 |
| - ("evohome.credentials", logging.DEBUG, "Fetching session_id..."), |
82 |
| - ("evohome.credentials", logging.DEBUG, " - authenticating with client_id/secret"), |
83 |
| - ("evohome.credentials", logging.ERROR, HINT_BAD_CREDS), |
84 |
| - ] # fmt: off |
| 76 | + assert caplog.record_tuples == [LOG_90, LOG_04, LOG_11] |
85 | 77 |
|
86 | 78 | assert len(rsp.requests) == 1
|
87 | 79 |
|
@@ -127,12 +119,7 @@ async def test_bad2( # bad session id
|
127 | 119 |
|
128 | 120 | assert err.value.status is None # Connection refused
|
129 | 121 |
|
130 |
| - assert caplog.record_tuples == [ |
131 |
| - ("evohomeasync", logging.WARNING, MSG_INVALID_SESSION), |
132 |
| - ("evohome.credentials", logging.DEBUG, "Fetching session_id..."), |
133 |
| - ("evohome.credentials", logging.DEBUG, " - authenticating with client_id/secret"), |
134 |
| - ("evohome.credentials", logging.ERROR, HINT_CHECK_NETWORK), # Connection refused |
135 |
| - ] # fmt: off |
| 122 | + assert caplog.record_tuples == [LOG_91, LOG_90, LOG_04, LOG_12] |
136 | 123 |
|
137 | 124 | assert len(rsp.requests) == 2 # noqa: PLR2004
|
138 | 125 |
|
|
0 commit comments