|
| 1 | +from pathlib import Path |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +pytestmark = pytest.mark.architecture |
| 6 | + |
| 7 | + |
| 8 | +ALLOWED_PARSE_SESSION_RESPONSE_MODEL_MODULES = { |
| 9 | + "hyperbrowser/client/managers/session_request_utils.py", |
| 10 | + "hyperbrowser/client/managers/session_utils.py", |
| 11 | +} |
| 12 | + |
| 13 | +ALLOWED_PARSE_SESSION_RECORDINGS_MODULES = { |
| 14 | + "hyperbrowser/client/managers/session_request_utils.py", |
| 15 | + "hyperbrowser/client/managers/session_utils.py", |
| 16 | +} |
| 17 | + |
| 18 | + |
| 19 | +def test_parse_session_response_model_usage_is_centralized(): |
| 20 | + violating_modules: list[str] = [] |
| 21 | + for module_path in sorted( |
| 22 | + Path("hyperbrowser/client/managers").rglob("*.py") |
| 23 | + ): |
| 24 | + module_text = module_path.read_text(encoding="utf-8") |
| 25 | + if "parse_session_response_model(" not in module_text: |
| 26 | + continue |
| 27 | + normalized_path = module_path.as_posix() |
| 28 | + if normalized_path not in ALLOWED_PARSE_SESSION_RESPONSE_MODEL_MODULES: |
| 29 | + violating_modules.append(normalized_path) |
| 30 | + |
| 31 | + assert violating_modules == [] |
| 32 | + |
| 33 | + |
| 34 | +def test_parse_session_recordings_response_data_usage_is_centralized(): |
| 35 | + violating_modules: list[str] = [] |
| 36 | + for module_path in sorted( |
| 37 | + Path("hyperbrowser/client/managers").rglob("*.py") |
| 38 | + ): |
| 39 | + module_text = module_path.read_text(encoding="utf-8") |
| 40 | + if "parse_session_recordings_response_data(" not in module_text: |
| 41 | + continue |
| 42 | + normalized_path = module_path.as_posix() |
| 43 | + if normalized_path not in ALLOWED_PARSE_SESSION_RECORDINGS_MODULES: |
| 44 | + violating_modules.append(normalized_path) |
| 45 | + |
| 46 | + assert violating_modules == [] |
0 commit comments