Skip to content

Commit

Permalink
Skip gmap tests if no static key (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion authored Jul 12, 2024
1 parent 694f5f9 commit 136d56c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions salem/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion salem/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down Expand Up @@ -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,
Expand All @@ -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'))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 136d56c

Please sign in to comment.