Skip to content

Commit

Permalink
added some test to pass the code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Loickemajou authored Aug 19, 2024
1 parent a8a401f commit d50b78c
Showing 1 changed file with 14 additions and 40 deletions.
54 changes: 14 additions & 40 deletions pysteps/tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ def test_nowcasts_interface():
for i in range(num_timesteps):
assert numpy.all(forecast[i] == precip)

# Test for invalid method types
with pytest.raises(ValueError):
pysteps.nowcasts.interface.get_method("linear")

assert isinstance(
pysteps.nowcasts.interface.nowcasts_info()[0],
set,
)

assert isinstance(
pysteps.nowcasts.interface.nowcasts_info()[1],
set,
)


def test_utils_interface():
"""Test utils module interface."""
Expand Down Expand Up @@ -360,43 +374,3 @@ def test_tracking_interface():

invalid_names = ["lucas-kanade", "dating"]
_generic_interface_test(method_getter, valid_names_func_pair, invalid_names)


def test_nowcasts_interface():
"""Test the discover_nowcasts and nowcasts_info function."""
from pysteps.nowcasts.interface import discover_nowcasts
from pysteps.nowcasts.interface import nowcasts_info

# Call the function to get nowcasts info
_, nowcasts_in_interface = nowcasts_info()

# Call the function to discover nowcasts
discover_nowcasts()

# Check if the expected methods are added
expected_methods = [
"anvil",
"eulerian",
"extrapolation",
"lagrangian",
"lagrangian_probability",
"linda",
"probability",
"sprog",
"sseps",
"steps",
"dgmr",
]

for method in expected_methods:
if method == "dgmr":
if method not in nowcasts_in_interface:
print(
f"Warning: Method {method} not found in discovered nowcasts. Please install dgmr_plugin through 'pip install dgmr_plugin'"
)
continue
assert (
method in nowcasts_in_interface
), f"Method {method} not found in discovered nowcasts."

print("All expected nowcast methods discovered successfully.")

0 comments on commit d50b78c

Please sign in to comment.