Skip to content

Commit

Permalink
Add tests for diagnostics plugins interfaces.
Browse files Browse the repository at this point in the history
a
  • Loading branch information
ladc committed Feb 25, 2025
1 parent 8c905f2 commit 51f9642
Showing 1 changed file with 0 additions and 76 deletions.
76 changes: 0 additions & 76 deletions pysteps/tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,82 +152,6 @@ def method_getter(name):
pysteps.io.interface.get_method("mch_gif", "io")


def test_postprocessing_interface():
"""Test the postprocessing module interface."""

import pysteps.postprocessing as postprocessing
from pysteps.postprocessing import postprocessors_diagnostics_example1
from pysteps.postprocessing import postprocessors_diagnostics_example2
from pysteps.postprocessing import postprocessors_ensemblestats_example1
from pysteps.postprocessing import postprocessors_ensemblestats_example2

valid_diagnostics_names_func_pair = [
("diagnostics_example1", postprocessors_diagnostics_example1)
]

def method_getter_diagnostics(name):
return pysteps.postprocessing.interface.get_method(name, "diagnostics")

invalid_names = ["bom", "fmi", "knmi", "mch", "mrms", "opera", "saf"]
_generic_interface_test(
method_getter_diagnostics, valid_diagnostics_names_func_pair, invalid_names
)

valid_ensemblestats_names_func_pair = [
("ensemblestats_example1", postprocessors_ensemblestats_example1)
]

def method_getter_ensemblestats(name):
return pysteps.postprocessing.interface.get_method(name, "ensemblestats")

invalid_names = ["bom", "fmi", "knmi", "mch", "mrms", "opera", "saf"]
_generic_interface_test(
method_getter_ensemblestats, valid_ensemblestats_names_func_pair, invalid_names
)

# Test for invalid argument type
with pytest.raises(TypeError):
pysteps.postprocessing.interface.get_method("diagnostics_example1", None)
pysteps.postprocessing.interface.get_method(None, "diagnostics")

# Test for invalid method types
with pytest.raises(ValueError):
pysteps.postprocessing.interface.get_method("diagnostics_example1", "io")

with pytest.raises(TypeError):
pysteps.postprocessing.interface.get_method(24, "diagnostics")

assert isinstance(
pysteps.postprocessing.interface.postprocessors_info()[0],
set,
)

assert isinstance(
pysteps.postprocessing.interface.postprocessors_info()[1],
set,
)

assert isinstance(
postprocessors_diagnostics_example1(filename="example_filename"),
str,
)

assert isinstance(
postprocessors_diagnostics_example2(filename="example_filename"),
list,
)

assert isinstance(
postprocessors_ensemblestats_example1(filename="example_filename"),
str,
)

assert isinstance(
postprocessors_ensemblestats_example2(filename="example_filename"),
list,
)


def test_motion_interface():
"""Test the motion module interface."""

Expand Down

0 comments on commit 51f9642

Please sign in to comment.