Skip to content

Commit 4736223

Browse files
committed
move constants to const.py to share with other tests
1 parent b459ae9 commit 4736223

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

tests/tests/const.py

+24
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
from __future__ import annotations
44

5+
import logging
56
from pathlib import Path
7+
from typing import Final
8+
9+
from evohome.const import HINT_BAD_CREDS, HINT_CHECK_NETWORK
610

711
TEST_DIR = Path(__file__).resolve().parent
12+
13+
14+
MSG_INVALID_TOKEN: Final = (
15+
"The access_token has been rejected (will re-authenticate): " # noqa: S105
16+
"GET https://tccna.resideo.com/WebAPI/emea/api/v1/userAccount: "
17+
'401 Unauthorized, response=[{"code": "Unauthorized", "message": "Unauthorized"}]'
18+
)
19+
20+
21+
LOG_00 = ("evohomeasync2", logging.WARNING, MSG_INVALID_TOKEN)
22+
23+
LOG_01 = ("evohome.credentials", logging.DEBUG, "Fetching access_token...")
24+
LOG_02 = ("evohome.credentials", logging.DEBUG, " - authenticating with the refresh_token") # fmt: off
25+
LOG_03 = ("evohome.credentials", logging.DEBUG, "Expired/invalid refresh_token")
26+
LOG_04 = ("evohome.credentials", logging.DEBUG, " - authenticating with client_id/secret") # fmt: off
27+
28+
LOG_11 = ("evohome.credentials", logging.ERROR, HINT_BAD_CREDS)
29+
LOG_12 = ("evohome.credentials", logging.ERROR, HINT_CHECK_NETWORK)
30+
31+
LOG_13 = ("evohome.auth", logging.ERROR, HINT_CHECK_NETWORK)

tests/tests/test_v2_urls_cred.py

+3-20
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
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
from cli.auth import CredentialsManager
1313

14-
from evohome.const import HINT_BAD_CREDS, HINT_CHECK_NETWORK
1514
from evohomeasync2 import EvohomeClient, exceptions as exc
1615
from tests.const import (
1716
HEADERS_BASE,
@@ -21,19 +20,15 @@
2120
URL_CRED_V2,
2221
)
2322

23+
from .const import LOG_00, LOG_01, LOG_02, LOG_03, LOG_04, LOG_11, LOG_12, LOG_13
24+
2425
if TYPE_CHECKING:
2526
from collections.abc import AsyncGenerator
2627
from pathlib import Path
2728

2829
from cli.auth import CredentialsManager
2930

3031

31-
MSG_INVALID_TOKEN: Final = (
32-
"The access_token has been rejected (will re-authenticate): " # noqa: S105
33-
"GET https://tccna.resideo.com/WebAPI/emea/api/v1/userAccount: "
34-
'401 Unauthorized, response=[{"code": "Unauthorized", "message": "Unauthorized"}]'
35-
)
36-
3732
_TEST_ACCESS_TOKEN = "-- access token --" # noqa: S105
3833
_TEST_REFRESH_TOKEN = "-- refresh token --" # noqa: S105
3934

@@ -46,18 +41,6 @@ def cache_file(
4641
return tmp_path_factory.mktemp(__name__) / ".evo-cache.tst"
4742

4843

49-
LOG_00 = ("evohomeasync2", logging.WARNING, MSG_INVALID_TOKEN)
50-
51-
LOG_01 = ("evohome.credentials", logging.DEBUG, "Fetching access_token...")
52-
LOG_02 = ("evohome.credentials", logging.DEBUG, " - authenticating with the refresh_token") # fmt: off
53-
LOG_03 = ("evohome.credentials", logging.DEBUG, "Expired/invalid refresh_token")
54-
LOG_04 = ("evohome.credentials", logging.DEBUG, " - authenticating with client_id/secret") # fmt: off
55-
56-
LOG_11 = ("evohome.credentials", logging.ERROR, HINT_BAD_CREDS)
57-
LOG_12 = ("evohome.credentials", logging.ERROR, HINT_CHECK_NETWORK)
58-
59-
LOG_13 = ("evohome.auth", logging.ERROR, HINT_CHECK_NETWORK)
60-
6144
POST_CREDS = (
6245
"https://tccna.resideo.com/Auth/OAuth/Token",
6346
HTTPMethod.POST,

0 commit comments

Comments
 (0)