Skip to content

Commit 5b80104

Browse files
Add session parse usage boundary architecture guard
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent f256647 commit 5b80104

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ This runs lint, format checks, compile checks, tests, and package build.
152152
- `tests/test_response_parse_usage_boundary.py` (centralized `parse_response_model(...)` usage boundary enforcement),
153153
- `tests/test_schema_injection_helper_usage.py` (shared schema injection helper usage enforcement in payload builders),
154154
- `tests/test_session_operation_metadata_usage.py` (session manager operation-metadata usage enforcement),
155+
- `tests/test_session_parse_usage_boundary.py` (centralized session parse-helper usage boundary enforcement),
155156
- `tests/test_session_profile_update_helper_usage.py` (session profile-update parameter helper usage enforcement),
156157
- `tests/test_session_request_helper_usage.py` (session manager request-helper usage enforcement),
157158
- `tests/test_session_route_constants_usage.py` (session manager route-constant usage enforcement),

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"tests/test_computer_action_request_internal_reuse.py",
8585
"tests/test_schema_injection_helper_usage.py",
8686
"tests/test_session_operation_metadata_usage.py",
87+
"tests/test_session_parse_usage_boundary.py",
8788
"tests/test_session_route_constants_usage.py",
8889
"tests/test_session_request_helper_usage.py",
8990
"tests/test_session_profile_update_helper_usage.py",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
7+
8+
ALLOWED_PARSE_SESSION_RESPONSE_MODEL_MODULES = {
9+
"hyperbrowser/client/managers/session_request_utils.py",
10+
"hyperbrowser/client/managers/session_utils.py",
11+
}
12+
13+
ALLOWED_PARSE_SESSION_RECORDINGS_MODULES = {
14+
"hyperbrowser/client/managers/session_request_utils.py",
15+
"hyperbrowser/client/managers/session_utils.py",
16+
}
17+
18+
19+
def test_parse_session_response_model_usage_is_centralized():
20+
violating_modules: list[str] = []
21+
for module_path in sorted(
22+
Path("hyperbrowser/client/managers").rglob("*.py")
23+
):
24+
module_text = module_path.read_text(encoding="utf-8")
25+
if "parse_session_response_model(" not in module_text:
26+
continue
27+
normalized_path = module_path.as_posix()
28+
if normalized_path not in ALLOWED_PARSE_SESSION_RESPONSE_MODEL_MODULES:
29+
violating_modules.append(normalized_path)
30+
31+
assert violating_modules == []
32+
33+
34+
def test_parse_session_recordings_response_data_usage_is_centralized():
35+
violating_modules: list[str] = []
36+
for module_path in sorted(
37+
Path("hyperbrowser/client/managers").rglob("*.py")
38+
):
39+
module_text = module_path.read_text(encoding="utf-8")
40+
if "parse_session_recordings_response_data(" not in module_text:
41+
continue
42+
normalized_path = module_path.as_posix()
43+
if normalized_path not in ALLOWED_PARSE_SESSION_RECORDINGS_MODULES:
44+
violating_modules.append(normalized_path)
45+
46+
assert violating_modules == []

0 commit comments

Comments
 (0)