Skip to content

Commit 67740ce

Browse files
Add model request function parse boundary architecture guard
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 355ed52 commit 67740ce

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ This runs lint, format checks, compile checks, tests, and package build.
139139
- `tests/test_manager_transport_boundary.py` (manager transport boundary enforcement through shared request helpers),
140140
- `tests/test_mapping_keys_access_usage.py` (centralized key-iteration boundaries),
141141
- `tests/test_mapping_reader_usage.py` (shared mapping-read parser usage),
142+
- `tests/test_model_request_function_parse_boundary.py` (model-request function-level parse boundary enforcement between parsed wrappers and raw helpers),
142143
- `tests/test_model_request_function_transport_boundary.py` (model-request function-level transport boundary enforcement between parsed wrappers and raw helpers),
143144
- `tests/test_model_request_internal_reuse.py` (request-helper internal reuse of shared model request helper primitives),
144145
- `tests/test_model_request_wrapper_internal_reuse.py` (parsed model-request wrapper internal reuse of shared raw response-data helpers),

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"tests/test_manager_transport_boundary.py",
2727
"tests/test_mapping_reader_usage.py",
2828
"tests/test_mapping_keys_access_usage.py",
29+
"tests/test_model_request_function_parse_boundary.py",
2930
"tests/test_model_request_function_transport_boundary.py",
3031
"tests/test_model_request_internal_reuse.py",
3132
"tests/test_model_request_wrapper_internal_reuse.py",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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/model_request_utils.py"
9+
10+
PARSED_WRAPPER_FUNCTIONS = (
11+
"post_model_request",
12+
"get_model_request",
13+
"delete_model_request",
14+
"put_model_request",
15+
"post_model_request_async",
16+
"get_model_request_async",
17+
"delete_model_request_async",
18+
"put_model_request_async",
19+
"post_model_request_to_endpoint",
20+
"post_model_request_to_endpoint_async",
21+
)
22+
23+
RAW_HELPER_FUNCTIONS = (
24+
"post_model_response_data",
25+
"get_model_response_data",
26+
"delete_model_response_data",
27+
"put_model_response_data",
28+
"post_model_response_data_async",
29+
"get_model_response_data_async",
30+
"delete_model_response_data_async",
31+
"put_model_response_data_async",
32+
"post_model_response_data_to_endpoint",
33+
"post_model_response_data_to_endpoint_async",
34+
)
35+
36+
37+
def test_parsed_model_request_wrappers_call_parse_response_model():
38+
function_sources = collect_function_sources(MODULE_PATH)
39+
for function_name in PARSED_WRAPPER_FUNCTIONS:
40+
function_source = function_sources[function_name]
41+
assert "parse_response_model(" in function_source
42+
43+
44+
def test_raw_model_request_helpers_do_not_call_parse_response_model():
45+
function_sources = collect_function_sources(MODULE_PATH)
46+
for function_name in RAW_HELPER_FUNCTIONS:
47+
function_source = function_sources[function_name]
48+
assert "parse_response_model(" not in function_source

0 commit comments

Comments
 (0)