Skip to content

Commit 61bfc4d

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

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ This runs lint, format checks, compile checks, tests, and package build.
121121
- `tests/test_job_wait_helper_boundary.py` (centralization boundary enforcement for wait-for-job helper primitives),
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),
124+
- `tests/test_manager_helper_import_boundary.py` (manager helper-import boundary enforcement for low-level parse modules),
124125
- `tests/test_manager_model_dump_usage.py` (manager serialization centralization),
125126
- `tests/test_manager_parse_boundary.py` (manager response-parse boundary enforcement through shared helper modules),
126127
- `tests/test_manager_transport_boundary.py` (manager transport boundary enforcement through shared request helpers),

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_helper_import_boundary.py",
1920
"tests/test_manager_parse_boundary.py",
2021
"tests/test_manager_transport_boundary.py",
2122
"tests/test_mapping_reader_usage.py",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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_IMPORT_MARKERS = (
14+
"response_utils import",
15+
"session_utils import",
16+
)
17+
18+
19+
def test_managers_do_not_import_low_level_parse_modules():
20+
violating_modules: list[str] = []
21+
for manager_dir in MANAGER_DIRECTORIES:
22+
for module_path in sorted(manager_dir.glob("*.py")):
23+
module_text = module_path.read_text(encoding="utf-8")
24+
if any(marker in module_text for marker in DISALLOWED_IMPORT_MARKERS):
25+
violating_modules.append(module_path.as_posix())
26+
27+
for nested_dir in sorted(
28+
path for path in manager_dir.iterdir() if path.is_dir()
29+
):
30+
for module_path in sorted(nested_dir.glob("*.py")):
31+
module_text = module_path.read_text(encoding="utf-8")
32+
if any(marker in module_text for marker in DISALLOWED_IMPORT_MARKERS):
33+
violating_modules.append(module_path.as_posix())
34+
35+
assert violating_modules == []

0 commit comments

Comments
 (0)