Skip to content

Commit ee8b831

Browse files
Refactor default constant boundary inventory derivation
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 9aa0e12 commit ee8b831

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

tests/test_file_message_default_constant_import_boundary.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
import pytest
44

5+
from tests.test_file_message_default_constant_usage import MODULE_EXPECTATIONS
6+
57
pytestmark = pytest.mark.architecture
68

79

8-
EXPECTED_EXTENSION_DEFAULT_CONSTANT_CONSUMERS = (
9-
"hyperbrowser/client/managers/async_manager/extension.py",
10-
"hyperbrowser/client/managers/extension_create_utils.py",
10+
EXPECTED_EXTENSION_EXTRA_CONSUMERS = (
1111
"hyperbrowser/client/managers/extension_operation_metadata.py",
12-
"hyperbrowser/client/managers/sync_manager/extension.py",
1312
"tests/test_extension_create_metadata_usage.py",
1413
"tests/test_extension_operation_metadata.py",
1514
"tests/test_extension_operation_metadata_usage.py",
@@ -18,9 +17,8 @@
1817
"tests/test_file_open_error_helper_usage.py",
1918
)
2019

21-
EXPECTED_SESSION_DEFAULT_CONSTANT_CONSUMERS = (
20+
EXPECTED_SESSION_EXTRA_CONSUMERS = (
2221
"hyperbrowser/client/managers/session_operation_metadata.py",
23-
"hyperbrowser/client/managers/session_upload_utils.py",
2422
"tests/test_file_message_default_constant_import_boundary.py",
2523
"tests/test_file_message_default_constant_usage.py",
2624
"tests/test_file_open_error_helper_usage.py",
@@ -44,11 +42,29 @@ def _discover_modules_with_text(fragment: str) -> list[str]:
4442
return discovered_modules
4543

4644

45+
def _runtime_consumers_for_prefix(prefix: str) -> list[str]:
46+
runtime_modules: list[str] = []
47+
for module_path, expected_default_prefix_constants in MODULE_EXPECTATIONS:
48+
if not any(
49+
constant_name.startswith(prefix)
50+
for constant_name in expected_default_prefix_constants
51+
):
52+
continue
53+
runtime_modules.append(module_path)
54+
return runtime_modules
55+
56+
4757
def test_extension_default_message_constants_are_centralized():
4858
discovered_modules = _discover_modules_with_text("EXTENSION_DEFAULT_")
49-
assert discovered_modules == list(EXPECTED_EXTENSION_DEFAULT_CONSTANT_CONSUMERS)
59+
expected_modules = sorted(
60+
[*_runtime_consumers_for_prefix("EXTENSION_DEFAULT_"), *EXPECTED_EXTENSION_EXTRA_CONSUMERS]
61+
)
62+
assert discovered_modules == expected_modules
5063

5164

5265
def test_session_default_message_constants_are_centralized():
5366
discovered_modules = _discover_modules_with_text("SESSION_DEFAULT_UPLOAD_")
54-
assert discovered_modules == list(EXPECTED_SESSION_DEFAULT_CONSTANT_CONSUMERS)
67+
expected_modules = sorted(
68+
[*_runtime_consumers_for_prefix("SESSION_DEFAULT_UPLOAD_"), *EXPECTED_SESSION_EXTRA_CONSUMERS]
69+
)
70+
assert discovered_modules == expected_modules

0 commit comments

Comments
 (0)