Skip to content

Commit 22f7b14

Browse files
Add default-prefix constant usage architecture guard
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 1b3565d commit 22f7b14

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ This runs lint, format checks, compile checks, tests, and package build.
135135
- `tests/test_extension_request_internal_reuse.py` (extension request-helper internal reuse of shared model request helpers),
136136
- `tests/test_extension_route_constants_usage.py` (extension manager route-constant usage enforcement),
137137
- `tests/test_extract_payload_helper_usage.py` (extract start-payload helper usage enforcement),
138+
- `tests/test_file_message_default_constant_usage.py` (extension/session file-message default-prefix constant usage enforcement),
138139
- `tests/test_file_message_prefix_literal_boundary.py` (extension/session file-message prefix literal centralization in shared metadata modules),
139140
- `tests/test_file_open_error_helper_import_boundary.py` (shared file-open error-message helper import boundary enforcement),
140141
- `tests/test_file_open_error_helper_usage.py` (shared file-open error-message helper usage enforcement),

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"tests/test_model_request_wrapper_internal_reuse.py",
5151
"tests/test_tool_mapping_reader_usage.py",
5252
"tests/test_display_helper_usage.py",
53+
"tests/test_file_message_default_constant_usage.py",
5354
"tests/test_file_message_prefix_literal_boundary.py",
5455
"tests/test_file_open_error_helper_import_boundary.py",
5556
"tests/test_file_open_error_helper_usage.py",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
7+
8+
MODULE_EXPECTATIONS = (
9+
(
10+
"hyperbrowser/client/managers/extension_create_utils.py",
11+
(
12+
"EXTENSION_DEFAULT_MISSING_FILE_MESSAGE_PREFIX",
13+
"EXTENSION_DEFAULT_NOT_FILE_MESSAGE_PREFIX",
14+
),
15+
),
16+
(
17+
"hyperbrowser/client/managers/sync_manager/extension.py",
18+
("EXTENSION_DEFAULT_OPEN_FILE_ERROR_PREFIX",),
19+
),
20+
(
21+
"hyperbrowser/client/managers/async_manager/extension.py",
22+
("EXTENSION_DEFAULT_OPEN_FILE_ERROR_PREFIX",),
23+
),
24+
(
25+
"hyperbrowser/client/managers/session_upload_utils.py",
26+
(
27+
"SESSION_DEFAULT_UPLOAD_MISSING_FILE_MESSAGE_PREFIX",
28+
"SESSION_DEFAULT_UPLOAD_NOT_FILE_MESSAGE_PREFIX",
29+
"SESSION_DEFAULT_UPLOAD_OPEN_FILE_ERROR_PREFIX",
30+
),
31+
),
32+
)
33+
34+
FORBIDDEN_DEFAULT_PREFIX_LITERALS = (
35+
'default_prefix="Extension file not found at path"',
36+
'default_prefix="Extension file path must point to a file"',
37+
'default_prefix="Failed to open extension file at path"',
38+
'default_prefix="Upload file not found at path"',
39+
'default_prefix="Upload file path must point to a file"',
40+
'default_prefix="Failed to open upload file at path"',
41+
)
42+
43+
44+
def test_file_message_helpers_use_shared_default_prefix_constants():
45+
for module_path, expected_constant_names in MODULE_EXPECTATIONS:
46+
module_text = Path(module_path).read_text(encoding="utf-8")
47+
for constant_name in expected_constant_names:
48+
assert constant_name in module_text
49+
for forbidden_literal in FORBIDDEN_DEFAULT_PREFIX_LITERALS:
50+
assert forbidden_literal not in module_text

0 commit comments

Comments
 (0)