From ac74b64b526fd5156cb65f06bdcd9b9e65d22d73 Mon Sep 17 00:00:00 2001 From: Fabien Maussion Date: Thu, 11 Jul 2024 16:28:54 +0900 Subject: [PATCH] Skip gmap tests if no static key --- salem/tests/__init__.py | 7 +++++++ salem/tests/test_graphics.py | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/salem/tests/__init__.py b/salem/tests/__init__.py index 3d46811..c9b5b29 100644 --- a/salem/tests/__init__.py +++ b/salem/tests/__init__.py @@ -78,6 +78,13 @@ def requires_matplotlib(test): return test if has_matplotlib else unittest.skip(msg)(test) +def requires_static_key(test): + msg = "requires google static map key" + do_test = (("STATIC_MAP_API_KEY" in os.environ) and + (os.environ.get("STATIC_MAP_API_KEY"))) + return test if do_test else unittest.skip(msg)(test) + + def requires_motionless(test): msg = "requires motionless" return test if has_motionless else unittest.skip(msg)(test) diff --git a/salem/tests/test_graphics.py b/salem/tests/test_graphics.py index 68c186c..720e442 100644 --- a/salem/tests/test_graphics.py +++ b/salem/tests/test_graphics.py @@ -38,7 +38,7 @@ GoogleVisibleMap, open_wrf_dataset, open_xr_dataset, python_version, cache_dir, sample_data_dir) from salem.utils import get_demo_file -from salem.tests import (requires_matplotlib, requires_cartopy) +from salem.tests import (requires_matplotlib, requires_cartopy, requires_static_key) # Globals current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -810,6 +810,7 @@ def test_hef_topo_withnan(): @requires_matplotlib +@requires_static_key @pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, tolerance=25) def test_gmap(): g = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, @@ -828,6 +829,7 @@ def test_gmap(): @requires_matplotlib +@requires_static_key @pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, tolerance=25) def test_gmap_transformed(): dem = GeoTiff(get_demo_file('hef_srtm.tif')) @@ -857,6 +859,7 @@ def test_gmap_transformed(): @requires_matplotlib +@requires_static_key @pytest.mark.mpl_image_compare(baseline_dir=baseline_dir, tolerance=10) def test_gmap_llconts(): # This was because some problems were left unnoticed by other tests