Skip to content

Commit f256647

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

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ This runs lint, format checks, compile checks, tests, and package build.
149149
- `tests/test_pyproject_architecture_marker.py` (pytest marker registration enforcement),
150150
- `tests/test_readme_examples_listing.py` (README example-listing consistency enforcement),
151151
- `tests/test_request_helper_parse_import_boundary.py` (request-helper import boundary enforcement for direct response parsing imports),
152+
- `tests/test_response_parse_usage_boundary.py` (centralized `parse_response_model(...)` usage boundary enforcement),
152153
- `tests/test_schema_injection_helper_usage.py` (shared schema injection helper usage enforcement in payload builders),
153154
- `tests/test_session_operation_metadata_usage.py` (session manager operation-metadata usage enforcement),
154155
- `tests/test_session_profile_update_helper_usage.py` (session profile-update parameter helper usage enforcement),

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"tests/test_contributing_architecture_guard_listing.py",
5252
"tests/test_readme_examples_listing.py",
5353
"tests/test_request_helper_parse_import_boundary.py",
54+
"tests/test_response_parse_usage_boundary.py",
5455
"tests/test_examples_syntax.py",
5556
"tests/test_docs_python3_commands.py",
5657
"tests/test_extension_create_helper_usage.py",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
7+
8+
ALLOWED_PARSE_RESPONSE_MODEL_MODULES = {
9+
"hyperbrowser/client/managers/model_request_utils.py",
10+
"hyperbrowser/client/managers/response_utils.py",
11+
"hyperbrowser/client/managers/session_utils.py",
12+
}
13+
14+
15+
def test_parse_response_model_usage_is_centralized():
16+
violating_modules: list[str] = []
17+
for module_path in sorted(
18+
Path("hyperbrowser/client/managers").rglob("*.py")
19+
):
20+
module_text = module_path.read_text(encoding="utf-8")
21+
if "parse_response_model(" not in module_text:
22+
continue
23+
normalized_path = module_path.as_posix()
24+
if normalized_path not in ALLOWED_PARSE_RESPONSE_MODEL_MODULES:
25+
violating_modules.append(normalized_path)
26+
27+
assert violating_modules == []

0 commit comments

Comments
 (0)