|
| 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/model_request_utils.py" |
| 9 | + |
| 10 | +PARSED_WRAPPER_FUNCTIONS = ( |
| 11 | + "post_model_request", |
| 12 | + "get_model_request", |
| 13 | + "delete_model_request", |
| 14 | + "put_model_request", |
| 15 | + "post_model_request_async", |
| 16 | + "get_model_request_async", |
| 17 | + "delete_model_request_async", |
| 18 | + "put_model_request_async", |
| 19 | + "post_model_request_to_endpoint", |
| 20 | + "post_model_request_to_endpoint_async", |
| 21 | +) |
| 22 | + |
| 23 | +RAW_HELPER_FUNCTIONS = ( |
| 24 | + "post_model_response_data", |
| 25 | + "get_model_response_data", |
| 26 | + "delete_model_response_data", |
| 27 | + "put_model_response_data", |
| 28 | + "post_model_response_data_async", |
| 29 | + "get_model_response_data_async", |
| 30 | + "delete_model_response_data_async", |
| 31 | + "put_model_response_data_async", |
| 32 | + "post_model_response_data_to_endpoint", |
| 33 | + "post_model_response_data_to_endpoint_async", |
| 34 | +) |
| 35 | + |
| 36 | + |
| 37 | +def test_parsed_model_request_wrappers_call_parse_response_model(): |
| 38 | + function_sources = collect_function_sources(MODULE_PATH) |
| 39 | + for function_name in PARSED_WRAPPER_FUNCTIONS: |
| 40 | + function_source = function_sources[function_name] |
| 41 | + assert "parse_response_model(" in function_source |
| 42 | + |
| 43 | + |
| 44 | +def test_raw_model_request_helpers_do_not_call_parse_response_model(): |
| 45 | + function_sources = collect_function_sources(MODULE_PATH) |
| 46 | + for function_name in RAW_HELPER_FUNCTIONS: |
| 47 | + function_source = function_sources[function_name] |
| 48 | + assert "parse_response_model(" not in function_source |
0 commit comments