Skip to content

Commit 7325143

Browse files
committed
move more constants around
1 parent 4736223 commit 7325143

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

tests/tests/const.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
TEST_DIR = Path(__file__).resolve().parent
1212

1313

14+
MSG_INVALID_SESSION: Final = (
15+
"The session_id has been rejected (will re-authenticate): "
16+
"GET https://tccna.resideo.com/WebAPI/api/accountInfo: "
17+
'401 Unauthorized, response=[{"code": "Unauthorized", "message": "Unauthorized"}]'
18+
)
19+
1420
MSG_INVALID_TOKEN: Final = (
1521
"The access_token has been rejected (will re-authenticate): " # noqa: S105
1622
"GET https://tccna.resideo.com/WebAPI/emea/api/v1/userAccount: "
@@ -26,6 +32,10 @@
2632
LOG_04 = ("evohome.credentials", logging.DEBUG, " - authenticating with client_id/secret") # fmt: off
2733

2834
LOG_11 = ("evohome.credentials", logging.ERROR, HINT_BAD_CREDS)
29-
LOG_12 = ("evohome.credentials", logging.ERROR, HINT_CHECK_NETWORK)
35+
LOG_12 = ("evohome.credentials", logging.ERROR, HINT_CHECK_NETWORK) # usu. Conn refused
3036

3137
LOG_13 = ("evohome.auth", logging.ERROR, HINT_CHECK_NETWORK)
38+
39+
40+
LOG_90 = ("evohome.credentials", logging.DEBUG, "Fetching session_id...")
41+
LOG_91 = ("evohomeasync", logging.WARNING, MSG_INVALID_SESSION)

tests/tests/test_v0_urls_cred.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,25 @@
55
import logging
66
from datetime import UTC, datetime as dt, timedelta as td
77
from http import HTTPMethod, HTTPStatus
8-
from typing import TYPE_CHECKING, Final
8+
from typing import TYPE_CHECKING
99

1010
import pytest
1111
from aioresponses import aioresponses
1212

13-
from evohome.const import HINT_BAD_CREDS, HINT_CHECK_NETWORK
13+
from evohome.const import HINT_CHECK_NETWORK
1414
from evohomeasync import EvohomeClient, exceptions as exc
1515
from evohomeasync.auth import _APPLICATION_ID
1616
from tests.const import HEADERS_BASE, HEADERS_CRED_V0, URL_CRED_V0
1717

18+
from .const import LOG_04, LOG_11, LOG_12, LOG_90, LOG_91
19+
1820
if TYPE_CHECKING:
1921
from collections.abc import AsyncGenerator
2022
from pathlib import Path
2123

2224
from cli.auth import CredentialsManager
2325

2426

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-
3127
_TEST_SESSION_ID = "-- session id --"
3228

3329

@@ -77,11 +73,7 @@ async def test_bad1( # bad credentials (client_id/secret)
7773

7874
assert err.value.status == HTTPStatus.UNAUTHORIZED
7975

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]
8577

8678
assert len(rsp.requests) == 1
8779

@@ -127,12 +119,7 @@ async def test_bad2( # bad session id
127119

128120
assert err.value.status is None # Connection refused
129121

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]
136123

137124
assert len(rsp.requests) == 2 # noqa: PLR2004
138125

0 commit comments

Comments
 (0)