Skip to content

Commit b95fb0e

Browse files
Add web request wrapper internal reuse architecture guard
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 9841714 commit b95fb0e

4 files changed

Lines changed: 41 additions & 0 deletions

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ This runs lint, format checks, compile checks, tests, and package build.
187187
- `tests/test_web_payload_helper_usage.py` (web manager payload-helper usage enforcement),
188188
- `tests/test_web_request_helper_usage.py` (web manager request-helper usage enforcement),
189189
- `tests/test_web_request_internal_reuse.py` (web request helper internal reuse of shared job request helpers),
190+
- `tests/test_web_request_wrapper_internal_reuse.py` (web request-wrapper internal reuse of shared job request helpers),
190191
- `tests/test_web_route_constants_usage.py` (web manager route-constant usage enforcement).
191192

192193
## Code quality conventions

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
"tests/test_web_payload_helper_usage.py",
117117
"tests/test_web_fetch_search_usage.py",
118118
"tests/test_web_request_internal_reuse.py",
119+
"tests/test_web_request_wrapper_internal_reuse.py",
119120
"tests/test_web_request_helper_usage.py",
120121
"tests/test_web_route_constants_usage.py",
121122
)

tests/test_ast_function_source_helper_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"tests/test_session_recordings_follow_redirects_boundary.py",
1717
"tests/test_session_request_wrapper_internal_reuse.py",
1818
"tests/test_session_resource_wrapper_internal_reuse.py",
19+
"tests/test_web_request_wrapper_internal_reuse.py",
1920
)
2021

2122

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pytest
2+
3+
from tests.ast_function_source_utils import collect_function_sources
4+
5+
pytestmark = pytest.mark.architecture
6+
7+
8+
MODULE_PATH = "hyperbrowser/client/managers/web_request_utils.py"
9+
10+
SYNC_WRAPPER_TO_JOB_HELPER = {
11+
"start_web_job": "start_job(",
12+
"get_web_job_status": "get_job_status(",
13+
"get_web_job": "get_job(",
14+
}
15+
16+
ASYNC_WRAPPER_TO_JOB_HELPER = {
17+
"start_web_job_async": "start_job_async(",
18+
"get_web_job_status_async": "get_job_status_async(",
19+
"get_web_job_async": "get_job_async(",
20+
}
21+
22+
23+
def test_sync_web_request_wrappers_delegate_to_job_helpers():
24+
function_sources = collect_function_sources(MODULE_PATH)
25+
for wrapper_name, helper_call in SYNC_WRAPPER_TO_JOB_HELPER.items():
26+
wrapper_source = function_sources[wrapper_name]
27+
assert helper_call in wrapper_source
28+
assert "client.transport." not in wrapper_source
29+
assert "parse_response_model(" not in wrapper_source
30+
31+
32+
def test_async_web_request_wrappers_delegate_to_job_helpers():
33+
function_sources = collect_function_sources(MODULE_PATH)
34+
for wrapper_name, helper_call in ASYNC_WRAPPER_TO_JOB_HELPER.items():
35+
wrapper_source = function_sources[wrapper_name]
36+
assert helper_call in wrapper_source
37+
assert "client.transport." not in wrapper_source
38+
assert "parse_response_model(" not in wrapper_source

0 commit comments

Comments
 (0)