Skip to content

Commit ccce142

Browse files
committed
style: clean up imports and formatting in test utilities
- Remove unused base64 import in route tests. - Reorder imports in test utilities to adhere to consistent project conventions. - Improve readability of logical blocks by adjusting whitespace and line breaks. Generated-by: aiautocommit
1 parent dfd309e commit ccce142

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

tests/integration/clerk.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ def is_publishable_key(key: str) -> bool:
9191
PUBLISHABLE_KEY_TEST_PREFIX
9292
)
9393

94-
has_valid_postfix = base64_decode(
95-
key.split("_")[2] if len(key.split("_")) > 2 else ""
96-
).decode("utf-8").endswith("$")
94+
has_valid_postfix = (
95+
base64_decode(key.split("_")[2] if len(key.split("_")) > 2 else "")
96+
.decode("utf-8")
97+
.endswith("$")
98+
)
9799

98100
return has_valid_prefix and has_valid_postfix
99101

@@ -219,4 +221,3 @@ def teardown_clerk_testing_token(
219221
frontend_api_url = parsed_result.frontend_api
220222

221223
page.unroute(f"https://{frontend_api_url}/v1/**")
222-

tests/routes/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import base64
21
import json
32
import typing as t
43

@@ -162,6 +161,7 @@ def distribution_headers(distribution) -> dict[str, str]:
162161
def decode_cookie(response: Response):
163162
"decode a signed cookie into a dict for inspection and assertion"
164163
from app.routes.middleware import SESSION_SECRET_KEY
164+
165165
from tests.utils import starlette_session_decode
166166

167167
signer = itsdangerous.Signer(SESSION_SECRET_KEY)

tests/utils.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import base64
2-
import typing as t
32

43
from tenacity import retry, stop_after_attempt
54

5+
from app.configuration.clerk import clerk
6+
from app.environments import is_testing
7+
from app.utils.geolocation import get_cached_public_ip
8+
9+
from tests.constants import (
10+
CLERK_ALL_USERS_TO_PRESERVE,
11+
)
12+
13+
from .log import log
14+
615

716
def base64_decode(original_b64_string: str | bytes, url_safe: bool = False) -> bytes:
817
"""
@@ -37,17 +46,6 @@ def starlette_session_decode(decoded_signed_value: bytes) -> bytes:
3746
return base64_decode(data, url_safe=True)
3847

3948

40-
from app.configuration.clerk import clerk
41-
from app.environments import is_testing
42-
from app.utils.geolocation import get_cached_public_ip
43-
44-
from tests.constants import (
45-
CLERK_ALL_USERS_TO_PRESERVE,
46-
)
47-
48-
from .log import log
49-
50-
5149
def get_public_ip_address() -> str | None:
5250
"""
5351
Get the current public IP address of this server. Helpful when you have geolocation stuff that is

0 commit comments

Comments
 (0)