Assert that a scraping result is valid. Args: result: The scraping result to validate expected_keys: Optional list of keys that should be present
(result: Any, expected_keys: Optional[List[str]] = None)
| 20 | |
| 21 | |
| 22 | def assert_valid_scrape_result(result: Any, expected_keys: Optional[List[str]] = None): |
| 23 | """Assert that a scraping result is valid. |
| 24 | |
| 25 | Args: |
| 26 | result: The scraping result to validate |
| 27 | expected_keys: Optional list of keys that should be present |
| 28 | """ |
| 29 | assert result is not None, "Result should not be None" |
| 30 | assert isinstance(result, (dict, str)), f"Result should be dict or str, got {type(result)}" |
| 31 | |
| 32 | if isinstance(result, dict) and expected_keys: |
| 33 | for key in expected_keys: |
| 34 | assert key in result, f"Expected key '{key}' not found in result" |
| 35 | |
| 36 | |
| 37 | def assert_execution_info_valid(exec_info: Dict[str, Any]): |
no outgoing calls