|
| 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/web_request_utils.py" |
| 9 | + |
| 10 | +SYNC_WRAPPER_TO_JOB_HELPER = { |
| 11 | + "start_web_job": "start_job(", |
| 12 | + "get_web_job_status": "get_job_status(", |
| 13 | + "get_web_job": "get_job(", |
| 14 | +} |
| 15 | + |
| 16 | +ASYNC_WRAPPER_TO_JOB_HELPER = { |
| 17 | + "start_web_job_async": "start_job_async(", |
| 18 | + "get_web_job_status_async": "get_job_status_async(", |
| 19 | + "get_web_job_async": "get_job_async(", |
| 20 | +} |
| 21 | + |
| 22 | + |
| 23 | +def test_sync_web_request_wrappers_delegate_to_job_helpers(): |
| 24 | + function_sources = collect_function_sources(MODULE_PATH) |
| 25 | + for wrapper_name, helper_call in SYNC_WRAPPER_TO_JOB_HELPER.items(): |
| 26 | + wrapper_source = function_sources[wrapper_name] |
| 27 | + assert helper_call in wrapper_source |
| 28 | + assert "client.transport." not in wrapper_source |
| 29 | + assert "parse_response_model(" not in wrapper_source |
| 30 | + |
| 31 | + |
| 32 | +def test_async_web_request_wrappers_delegate_to_job_helpers(): |
| 33 | + function_sources = collect_function_sources(MODULE_PATH) |
| 34 | + for wrapper_name, helper_call in ASYNC_WRAPPER_TO_JOB_HELPER.items(): |
| 35 | + wrapper_source = function_sources[wrapper_name] |
| 36 | + assert helper_call in wrapper_source |
| 37 | + assert "client.transport." not in wrapper_source |
| 38 | + assert "parse_response_model(" not in wrapper_source |
0 commit comments