Skip to content

Commit 8b6a56a

Browse files
Enforce manager parse helper boundary
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent e801443 commit 8b6a56a

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ This runs lint, format checks, compile checks, tests, and package build.
122122
- `tests/test_job_wait_helper_usage.py` (shared wait-for-job defaults helper usage enforcement),
123123
- `tests/test_makefile_quality_targets.py` (Makefile quality-gate target enforcement),
124124
- `tests/test_manager_model_dump_usage.py` (manager serialization centralization),
125+
- `tests/test_manager_parse_boundary.py` (manager response-parse boundary enforcement through shared helper modules),
125126
- `tests/test_manager_transport_boundary.py` (manager transport boundary enforcement through shared request helpers),
126127
- `tests/test_mapping_keys_access_usage.py` (centralized key-iteration boundaries),
127128
- `tests/test_mapping_reader_usage.py` (shared mapping-read parser usage),

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"tests/test_agent_terminal_status_helper_usage.py",
1717
"tests/test_guardrail_ast_utils.py",
1818
"tests/test_manager_model_dump_usage.py",
19+
"tests/test_manager_parse_boundary.py",
1920
"tests/test_manager_transport_boundary.py",
2021
"tests/test_mapping_reader_usage.py",
2122
"tests/test_mapping_keys_access_usage.py",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
7+
8+
MANAGER_DIRECTORIES = (
9+
Path("hyperbrowser/client/managers/sync_manager"),
10+
Path("hyperbrowser/client/managers/async_manager"),
11+
)
12+
13+
DISALLOWED_PARSE_MARKERS = (
14+
"parse_response_model(",
15+
"parse_session_response_model(",
16+
"parse_session_recordings_response_data(",
17+
)
18+
19+
20+
def test_managers_route_parsing_through_shared_helpers():
21+
violating_modules: list[str] = []
22+
for manager_dir in MANAGER_DIRECTORIES:
23+
for module_path in sorted(manager_dir.glob("*.py")):
24+
module_text = module_path.read_text(encoding="utf-8")
25+
if any(marker in module_text for marker in DISALLOWED_PARSE_MARKERS):
26+
violating_modules.append(module_path.as_posix())
27+
28+
for nested_dir in sorted(
29+
path for path in manager_dir.iterdir() if path.is_dir()
30+
):
31+
for module_path in sorted(nested_dir.glob("*.py")):
32+
module_text = module_path.read_text(encoding="utf-8")
33+
if any(marker in module_text for marker in DISALLOWED_PARSE_MARKERS):
34+
violating_modules.append(module_path.as_posix())
35+
36+
assert violating_modules == []

0 commit comments

Comments
 (0)