def test_io_interface():
    """Test the io module interface."""

    from pysteps.io import import_bom_rf3
    from pysteps.io import import_fmi_geotiff
    from pysteps.io import import_fmi_pgm
    from pysteps.io import import_knmi_hdf5
    from pysteps.io import import_mch_gif
    from pysteps.io import import_mch_hdf5
    from pysteps.io import import_mch_metranet
    from pysteps.io import import_mrms_grib
    from pysteps.io import import_opera_hdf5
    from pysteps.io import import_saf_crri

    from pysteps.io import initialize_forecast_exporter_geotiff
    from pysteps.io import initialize_forecast_exporter_kineros
    from pysteps.io import initialize_forecast_exporter_netcdf

    # Test importers
    valid_names_func_pair = [
        ("bom_rf3", import_bom_rf3),
        ("fmi_geotiff", import_fmi_geotiff),
        ("fmi_pgm", import_fmi_pgm),
        ("knmi_hdf5", import_knmi_hdf5),
        ("mch_gif", import_mch_gif),
        ("mch_hdf5", import_mch_hdf5),
        ("mch_metranet", import_mch_metranet),
        ("mrms_grib", import_mrms_grib),
        ("opera_hdf5", import_opera_hdf5),
        ("saf_crri", import_saf_crri),
    ]

    def method_getter(name):
        return pysteps.io.interface.get_method(name, "importer")

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

    # Test exporters
    def method_getter(name):
        return pysteps.io.interface.get_method(name, "exporter")

    valid_names_func_pair = [
        ("geotiff", initialize_forecast_exporter_geotiff),
        ("kineros", initialize_forecast_exporter_kineros),
        ("netcdf", initialize_forecast_exporter_netcdf),
    ]
    invalid_names = ["hdf"]

    _generic_interface_test(method_getter, valid_names_func_pair, invalid_names)

    # Test for invalid argument type
    with pytest.raises(TypeError):
        pysteps.io.interface.get_method("mch_gif", None)
        pysteps.io.interface.get_method(None, "importer")

    # Test for invalid method types
    with pytest.raises(ValueError):
        pysteps.io.interface.get_method("mch_gif", "io")
Test the io module interface.
pysteps/tests/test_interfaces.py