Skip to content

Commit a296b8c

Browse files
Refine list parsing caller and runtime inventories
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent ff283fa commit a296b8c

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

tests/test_list_parsing_helper_usage.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,26 @@
77
pytestmark = pytest.mark.architecture
88

99
HYPERBROWSER_ROOT = Path(__file__).resolve().parents[1] / "hyperbrowser"
10-
ALLOWED_PARSE_MAPPING_LIST_CALL_FILES = {
10+
LIST_PARSING_HELPER_RUNTIME_MODULES = {
1111
Path("client/managers/extension_utils.py"),
1212
Path("client/managers/list_parsing_utils.py"),
1313
Path("client/managers/session_utils.py"),
1414
}
15-
ALLOWED_READ_PLAIN_LIST_CALL_FILES = {
16-
Path("client/managers/extension_utils.py"),
17-
Path("client/managers/list_parsing_utils.py"),
18-
Path("client/managers/session_utils.py"),
15+
LIST_PARSING_HELPER_CALLER_MODULES = {
16+
path
17+
for path in LIST_PARSING_HELPER_RUNTIME_MODULES
18+
if path != Path("client/managers/list_parsing_utils.py")
1919
}
20+
ALLOWED_PARSE_MAPPING_LIST_CALL_FILES = LIST_PARSING_HELPER_CALLER_MODULES
21+
ALLOWED_READ_PLAIN_LIST_CALL_FILES = LIST_PARSING_HELPER_CALLER_MODULES
2022

2123

2224
def _python_files() -> list[Path]:
2325
return sorted(HYPERBROWSER_ROOT.rglob("*.py"))
2426

2527

2628
def test_parse_mapping_list_items_usage_is_centralized():
29+
files_with_calls: set[Path] = set()
2730
violations: list[str] = []
2831

2932
for path in _python_files():
@@ -32,15 +35,18 @@ def test_parse_mapping_list_items_usage_is_centralized():
3235
helper_calls = collect_name_call_lines(module, "parse_mapping_list_items")
3336
if not helper_calls:
3437
continue
38+
files_with_calls.add(relative_path)
3539
if relative_path in ALLOWED_PARSE_MAPPING_LIST_CALL_FILES:
3640
continue
3741
for line in helper_calls:
3842
violations.append(f"{relative_path}:{line}")
3943

4044
assert violations == []
45+
assert files_with_calls == ALLOWED_PARSE_MAPPING_LIST_CALL_FILES
4146

4247

4348
def test_read_plain_list_items_usage_is_centralized():
49+
files_with_calls: set[Path] = set()
4450
violations: list[str] = []
4551

4652
for path in _python_files():
@@ -49,9 +55,11 @@ def test_read_plain_list_items_usage_is_centralized():
4955
helper_calls = collect_name_call_lines(module, "read_plain_list_items")
5056
if not helper_calls:
5157
continue
58+
files_with_calls.add(relative_path)
5259
if relative_path in ALLOWED_READ_PLAIN_LIST_CALL_FILES:
5360
continue
5461
for line in helper_calls:
5562
violations.append(f"{relative_path}:{line}")
5663

5764
assert violations == []
65+
assert files_with_calls == ALLOWED_READ_PLAIN_LIST_CALL_FILES

tests/test_list_parsing_helpers_import_boundary.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import pytest
44

55
from tests.test_list_parsing_helper_usage import (
6-
ALLOWED_PARSE_MAPPING_LIST_CALL_FILES,
7-
ALLOWED_READ_PLAIN_LIST_CALL_FILES,
6+
LIST_PARSING_HELPER_RUNTIME_MODULES,
87
)
98

109
pytestmark = pytest.mark.architecture
@@ -33,10 +32,7 @@ def test_list_parsing_helper_imports_are_centralized():
3332

3433
expected_runtime_modules = sorted(
3534
f"hyperbrowser/{path.as_posix()}"
36-
for path in {
37-
*ALLOWED_PARSE_MAPPING_LIST_CALL_FILES,
38-
*ALLOWED_READ_PLAIN_LIST_CALL_FILES,
39-
}
35+
for path in LIST_PARSING_HELPER_RUNTIME_MODULES
4036
if path != Path("client/managers/list_parsing_utils.py")
4137
)
4238
expected_modules = sorted(

0 commit comments

Comments
 (0)