|
| 1 | +import os |
| 2 | +from typing import List, Optional |
| 3 | + |
| 4 | +from mache import MachineInfo |
| 5 | + |
| 6 | +from tests.integration.image_checker import _compare_actual_and_expected |
| 7 | + |
| 8 | + |
| 9 | +# Run this test with: |
| 10 | +# cd zppy |
| 11 | +# pytest tests/images/test_image_checker.py |
| 12 | +def test_compare(): |
| 13 | + missing_images: List[str] = [] |
| 14 | + mismatched_images: List[str] = [] |
| 15 | + |
| 16 | + directory: str = "tests/images/" |
| 17 | + # Copied from /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_weekly_comprehensive_v3_www/test_zppy_20250401/v3.LR.historical_0051/image_check_failures_comprehensive_v3/e3sm_diags/atm_monthly_180x360_aave/model_vs_obs_1987-1988/lat_lon/CRU_IPCC/CRU-TREFHT-ANN-land_60S90N.png_* |
| 18 | + image_name: str = "CRU-TREFHT-ANN-land_60S90N" |
| 19 | + path_to_actual_png: str = f"{directory}CRU-TREFHT-ANN-land_60S90N_input_actual.png" |
| 20 | + path_to_expected_png: str = ( |
| 21 | + f"{directory}CRU-TREFHT-ANN-land_60S90N_input_expected.png" |
| 22 | + ) |
| 23 | + |
| 24 | + machine_info = MachineInfo() |
| 25 | + web_portal_base_path: str = machine_info.config.get("web_portal", "base_path") |
| 26 | + web_portal_base_url: str = machine_info.config.get("web_portal", "base_url") |
| 27 | + print(f"web_portal_base_path: {web_portal_base_path}") |
| 28 | + print(f"web_portal_base_url: {web_portal_base_url}") |
| 29 | + user: Optional[str] = os.environ.get("USER") |
| 30 | + if not user: |
| 31 | + raise RuntimeError("USER could not be determined.") |
| 32 | + # Example diff dir URL: https://web.lcrc.anl.gov/public/e3sm/diagnostic_output/ac.forsyth2/test_image_checker_diffs/ |
| 33 | + diff_dir: str = f"{web_portal_base_path}/{user}/test_image_checker_diffs" |
| 34 | + |
| 35 | + _compare_actual_and_expected( |
| 36 | + missing_images, |
| 37 | + mismatched_images, |
| 38 | + image_name, |
| 39 | + path_to_actual_png, |
| 40 | + path_to_expected_png, |
| 41 | + diff_dir, |
| 42 | + ) |
| 43 | + assert missing_images == [] |
| 44 | + assert mismatched_images == ["CRU-TREFHT-ANN-land_60S90N"] |
0 commit comments