From c83c138f999a8281f8a2920322633384065a36bd Mon Sep 17 00:00:00 2001 From: Guillaume Maze Date: Fri, 11 Oct 2024 16:01:55 +0200 Subject: [PATCH] Add CI tests for monitors --- argopy/tests/test_utils_monitors.py | 27 +++++++++++++++++++++++++++ argopy/utils/monitors.py | 8 ++++---- 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 argopy/tests/test_utils_monitors.py diff --git a/argopy/tests/test_utils_monitors.py b/argopy/tests/test_utils_monitors.py new file mode 100644 index 00000000..c01a3be0 --- /dev/null +++ b/argopy/tests/test_utils_monitors.py @@ -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() diff --git a/argopy/utils/monitors.py b/argopy/utils/monitors.py index 43b9b586..a78228ed 100644 --- a/argopy/utils/monitors.py +++ b/argopy/utils/monitors.py @@ -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 = {}