Skip to content

Commit

Permalink
Add CI tests for monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaze committed Oct 11, 2024
1 parent 6eb93be commit c83c138
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
27 changes: 27 additions & 0 deletions argopy/tests/test_utils_monitors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest
IPython = pytest.importorskip("IPython", reason="Requires 'IPython'")

from argopy.utils.monitors import badge, fetch_status, monitor_status
from utils import has_ipywidgets, requires_ipywidgets


@pytest.mark.parametrize("insert", [False, True], indirect=False, ids=["insert=%s" % str(i) for i in [False, True]])
def test_badge(insert):
b = badge(label="label", message="message", color="green", insert=insert)
if not insert:
assert isinstance(b, str)
else:
assert isinstance(b, IPython.core.display.Image)


def test_fetch_status():
fs = fetch_status()
results = fs.fetch()
assert isinstance(results, dict)
assert isinstance(fs.text, str)
assert isinstance(fs.html, str)


@requires_ipywidgets
def test_monitor_status():
monitor_status()
8 changes: 4 additions & 4 deletions argopy/utils/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def badge(label="label", message="message", color="green", insert=False):
class fetch_status:
"""Fetch and report web API status"""

def __init__(self, **kwargs):
if "stdout" in kwargs or "insert" in kwargs:
warnings.warn("'fetch_status' signature has changed")
pass
# def __init__(self, **kwargs):
# if "stdout" in kwargs or "insert" in kwargs:
# warnings.warn("'fetch_status' signature has changed")
# pass

def fetch(self):
results = {}
Expand Down

0 comments on commit c83c138

Please sign in to comment.